Fix format

wsc-dfc
Elias Fleckenstein 2021-05-13 08:24:07 +02:00
parent ce0d81a825
commit d082423166
3 changed files with 41 additions and 33 deletions

View File

@ -50,7 +50,8 @@ static void log_mod_deprecation(const ModSpec &spec, const std::string &warning)
auto handling_mode = get_deprecated_handling_mode();
if (handling_mode != DeprecatedHandlingMode::Ignore) {
std::ostringstream os;
os << warning << " (" << spec.name << " at " << spec.path << ")" << std::endl;
os << warning << " (" << spec.name << " at " << spec.path << ")"
<< std::endl;
if (handling_mode == DeprecatedHandlingMode::Error) {
throw ModError(os.str());
@ -89,7 +90,8 @@ void parseModContents(ModSpec &spec)
if (info.exists("name"))
spec.name = info.get("name");
else
log_mod_deprecation(spec, "Mods not having a mod.conf file with the name is deprecated.");
log_mod_deprecation(spec, "Mods not having a mod.conf file with "
"the name is deprecated.");
if (info.exists("author"))
spec.author = info.get("author");
@ -130,7 +132,8 @@ void parseModContents(ModSpec &spec)
std::ifstream is((spec.path + DIR_DELIM + "depends.txt").c_str());
if (is.good())
log_mod_deprecation(spec, "depends.txt is deprecated, please use mod.conf instead.");
log_mod_deprecation(spec, "depends.txt is deprecated, "
"please use mod.conf instead.");
while (is.good()) {
std::string dep;
@ -152,8 +155,10 @@ void parseModContents(ModSpec &spec)
if (info.exists("description"))
spec.desc = info.get("description");
else if (fs::ReadFile(spec.path + DIR_DELIM + "description.txt", spec.desc))
log_mod_deprecation(spec, "description.txt is deprecated, please use mod.conf instead.");
else if (fs::ReadFile(spec.path + DIR_DELIM + "description.txt",
spec.desc))
log_mod_deprecation(spec, "description.txt is deprecated, please "
"use mod.conf instead.");
}
}

View File

@ -48,7 +48,7 @@ ClientActiveObject *ClientObjectRef::get_cao(ClientObjectRef *ref)
GenericCAO *ClientObjectRef::get_generic_cao(ClientObjectRef *ref, lua_State *L)
{
ClientActiveObject *obj = get_cao(ref);
if (! obj)
if (!obj)
return nullptr;
ClientEnvironment &env = getClient(L)->getEnv();
GenericCAO *gcao = env.getGenericCAO(obj->getId());
@ -59,7 +59,7 @@ int ClientObjectRef::l_get_pos(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
ClientActiveObject *cao = get_cao(ref);
if (! cao)
if (!cao)
return 0;
push_v3f(L, cao->getPosition() / BS);
return 1;
@ -69,7 +69,7 @@ int ClientObjectRef::l_get_velocity(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
push_v3f(L, gcao->getVelocity() / BS);
return 1;
@ -79,7 +79,7 @@ int ClientObjectRef::l_get_acceleration(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
push_v3f(L, gcao->getAcceleration() / BS);
return 1;
@ -89,7 +89,7 @@ int ClientObjectRef::l_get_rotation(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
push_v3f(L, gcao->getRotation());
return 1;
@ -99,7 +99,7 @@ int ClientObjectRef::l_is_player(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
lua_pushboolean(L, gcao->isPlayer());
return 1;
@ -109,7 +109,7 @@ int ClientObjectRef::l_is_local_player(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
lua_pushboolean(L, gcao->isLocalPlayer());
return 1;
@ -119,7 +119,7 @@ int ClientObjectRef::l_get_name(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
lua_pushstring(L, gcao->getName().c_str());
return 1;
@ -129,10 +129,10 @@ int ClientObjectRef::l_get_attach(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
ClientActiveObject *parent = gcao->getParent();
if (! parent)
if (!parent)
return 0;
push_objectRef(L, parent->getId());
return 1;
@ -140,10 +140,11 @@ int ClientObjectRef::l_get_attach(lua_State *L)
int ClientObjectRef::l_get_nametag(lua_State *L)
{
log_deprecated(L,"Deprecated call to get_nametag, use get_properties().nametag instead");
log_deprecated(L, "Deprecated call to get_nametag, use get_properties().nametag "
"instead");
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
ObjectProperties *props = gcao->getProperties();
lua_pushstring(L, props->nametag.c_str());
@ -152,10 +153,11 @@ int ClientObjectRef::l_get_nametag(lua_State *L)
int ClientObjectRef::l_get_item_textures(lua_State *L)
{
log_deprecated(L,"Deprecated call to get_item_textures, use get_properties().textures instead");
log_deprecated(L, "Deprecated call to get_item_textures, use "
"get_properties().textures instead");
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
ObjectProperties *props = gcao->getProperties();
lua_newtable(L);
@ -168,10 +170,11 @@ int ClientObjectRef::l_get_item_textures(lua_State *L)
int ClientObjectRef::l_get_max_hp(lua_State *L)
{
log_deprecated(L,"Deprecated call to get_max_hp, use get_properties().hp_max instead");
log_deprecated(L, "Deprecated call to get_max_hp, use get_properties().hp_max "
"instead");
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
ObjectProperties *props = gcao->getProperties();
lua_pushnumber(L, props->hp_max);
@ -182,7 +185,7 @@ int ClientObjectRef::l_get_properties(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
ObjectProperties *prop = gcao->getProperties();
push_object_properties(L, prop);
@ -193,7 +196,7 @@ int ClientObjectRef::l_set_properties(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
ObjectProperties prop = *gcao->getProperties();
read_object_properties(L, 2, nullptr, &prop, getClient(L)->idef());
@ -205,7 +208,7 @@ int ClientObjectRef::l_get_hp(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
lua_pushnumber(L, gcao->getHp());
return 1;
@ -215,7 +218,7 @@ int ClientObjectRef::l_punch(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
PointedThing pointed(gcao->getId(), v3f(0, 0, 0), v3s16(0, 0, 0), 0);
getClient(L)->interact(INTERACT_START_DIGGING, pointed);
@ -226,7 +229,7 @@ int ClientObjectRef::l_rightclick(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
PointedThing pointed(gcao->getId(), v3f(0, 0, 0), v3s16(0, 0, 0), 0);
getClient(L)->interact(INTERACT_PLACE, pointed);
@ -237,7 +240,7 @@ int ClientObjectRef::l_remove(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
ClientActiveObject *cao = get_cao(ref);
if (! cao)
if (!cao)
return 0;
getClient(L)->getEnv().removeActiveObject(cao->getId());
@ -248,12 +251,12 @@ int ClientObjectRef::l_set_nametag_images(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
if (! gcao)
if (!gcao)
return 0;
gcao->nametag_images.clear();
if(lua_istable(L, 2)){
if (lua_istable(L, 2)) {
lua_pushnil(L);
while(lua_next(L, 2) != 0){
while (lua_next(L, 2) != 0) {
gcao->nametag_images.push_back(lua_tostring(L, -1));
lua_pop(L, 1);
}
@ -333,7 +336,6 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
luamethod(ClientObjectRef, get_properties),
luamethod(ClientObjectRef, set_properties),
luamethod(ClientObjectRef, get_hp),
luamethod(ClientObjectRef, get_max_hp),
luamethod(ClientObjectRef, punch),
luamethod(ClientObjectRef, get_max_hp), luamethod(ClientObjectRef, punch),
luamethod(ClientObjectRef, rightclick),
luamethod(ClientObjectRef, set_nametag_images), {0, 0}};

View File

@ -43,7 +43,8 @@ public:
Inventory *createDetachedInventory(const std::string &name, IItemDefManager *idef,
const std::string &player = "");
bool removeDetachedInventory(const std::string &name);
bool checkDetachedInventoryAccess(const InventoryLocation &loc, const std::string &player) const;
bool checkDetachedInventoryAccess(
const InventoryLocation &loc, const std::string &player) const;
void sendDetachedInventories(const std::string &peer_name, bool incremental,
std::function<void(const std::string &, Inventory *)> apply_cb);