• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ HOUSE_PROTECTION

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
650
Solutions
14
Reaction score
88
Hello, I wanted to move the HOUSE_PROTECTION( if someone doesn't have invitation can't throw any items inside a house) so I move it from 0.3.7 to 0.3.6, but I have after for short time a mess. I added the code to housetile.cpp, but there is something like "creature* actor" and it wants to add this to function "queryAdd" so I add it everywhere, where this function is player.cpp, cylinder.h e.t.c.

So please let me know which files are enough to edit.

Very thanks.

bump

nobody can help me?
 
Last edited by a moderator:
Hello, I wanted to move the HOUSE_PROTECTION( if someone doesn't have invitation can't throw any items inside a house) so I move it from 0.3.7 to 0.3.6, but I have after for short time a mess. I added the code to housetile.cpp, but there is something like "creature* actor" and it wants to add this to function "queryAdd" so I add it everywhere, where this function is player.cpp, cylinder.h e.t.c.

So please let me know which files are enough to edit.

Very thanks.

bump

nobody can help me?

That TFS version hasn't been supported for years and ppl move on and "forget" about the older versions.
How are we supposed to help if all you have is a mess? :p
Upload the code or re-do the changes.

A tip is to open the files with ex MSVC and left click on the function and "find all references".
That way you know what files you will have to add / remove code from.
 
That TFS version hasn't been supported for years and ppl move on and "forget" about the older versions.
How are we supposed to help if all you have is a mess? :p
Upload the code or re-do the changes.

A tip is to open the files with ex MSVC and left click on the function and "find all references".
That way you know what files you will have to add / remove code from.
IMO we should force people to use atleast 1.x.
 
Okay this is the part of the code from housetile.cpp:
Code:
    if(actor && g_config.getBool(ConfigManager::HOUSE_PROTECTION))
       {
           if(const Player* player = actor->getPlayer())
           {
               if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
                   return RET_PLAYERISNOTINVITED;
           }
       }
From "queryAdd" function.

So the problem is that I don't know where I should implement:
Code:
actor/Creature* actor
cause when I add it to housetile.h it wants to add this to cylinder.h and others.

If you take a 8.6 source you can see there is no implemented "actor" in housetile.cpp/.h

b.t.w I only add it to housetile.cpp this part of the code so:
1) I should add "actor" to housetile.h
2) If is it too here:
Code:
return Tile::__queryAdd(index, thing, count, flags, actor);
Need I edit tile.cpp and tile.h too?
 
Okay this is the part of the code from housetile.cpp:
Code:
    if(actor && g_config.getBool(ConfigManager::HOUSE_PROTECTION))
       {
           if(const Player* player = actor->getPlayer())
           {
               if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
                   return RET_PLAYERISNOTINVITED;
           }
       }
From "queryAdd" function.

So the problem is that I don't know where I should implement:
Code:
actor/Creature* actor
cause when I add it to housetile.h it wants to add this to cylinder.h and others.

If you take a 8.6 source you can see there is no implemented "actor" in housetile.cpp/.h

b.t.w I only add it to housetile.cpp this part of the code so:
1) I should add "actor" to housetile.h
2) If is it too here:
Code:
return Tile::__queryAdd(index, thing, count, flags, actor);
Need I edit tile.cpp and tile.h too?

Post housetile.cpp and .h from both 0.3.7 and 0.3.6
You might need to modify more functions, but do as I said and find all the references to see where "actor" is gotten from.
 
yeah I was looking for but, there is already something with "actor".

Okay this is from 0.3.6:
housetile.cpp:
Code:
#include "otpch.h"
#include "housetile.h"

#include "house.h"
#include "game.h"
#include "configmanager.h"

extern ConfigManager g_config;
extern Game g_game;

HouseTile::HouseTile(int32_t x, int32_t y, int32_t z, House* _house):
   DynamicTile(x, y, z)
{
   house = _house;
   setFlag(TILESTATE_HOUSE);
}

void HouseTile::__addThing(Creature* actor, int32_t index, Thing* thing)
{
   Tile::__addThing(actor, index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::__internalAddThing(uint32_t index, Thing* thing)
{
   Tile::__internalAddThing(index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::updateHouse(Item* item)
{
   if(item->getTile() != this)
       return;

   Door* door = item->getDoor();
   if(door && door->getDoorId())
       house->addDoor(door);
   else if(BedItem* bed = item->getBed())
       house->addBed(bed);
}

ReturnValue HouseTile::__queryAdd(int32_t index, const Thing* thing, uint32_t count, uint32_t flags) const
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player))
               return RET_PLAYERISNOTINVITED;
       }
       else
           return RET_NOTPOSSIBLE;
   }
   else if(thing->getItem())
   {
       const uint32_t itemLimit = g_config.getNumber(ConfigManager::ITEMLIMIT_HOUSETILE);
       if(itemLimit && getThingCount() > itemLimit)
           return RET_TILEISFULL;
   }

   return Tile::__queryAdd(index, thing, count, flags);
}

Cylinder* HouseTile::__queryDestination(int32_t& index, const Thing* thing, Item** destItem, uint32_t& flags)
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasFlag(PlayerFlag_CanEditHouses))
           {
               Tile* destTile = g_game.getTile(house->getEntry());
               if(!destTile)
               {
                   std::cout << "[Error - HouseTile::__queryDestination] Tile at house entry position for house: "
                       << house->getName() << " (" << house->getId() << ") does not exist." << std::endl;
                   destTile = g_game.getTile(player->getMasterPosition());
                   if(!destTile)
                       destTile = &(Tile::nullTile);
               }

               index = -1;
               *destItem = NULL;
               return destTile;
           }
       }
   }

   return Tile::__queryDestination(index, thing, destItem, flags);
}

0.3.6 housetile.h:
Code:
#ifndef __HOUSETILE__
#define __HOUSETILE__
#include "tile.h"

class House;
class HouseTile : public DynamicTile
{
   public:
       HouseTile(int32_t x, int32_t y, int32_t z, House* _house);
       virtual ~HouseTile() {}

       //cylinder implementations
       virtual ReturnValue __queryAdd(int32_t index, const Thing* thing, uint32_t count,
           uint32_t flags) const;
       virtual Cylinder* __queryDestination(int32_t& index, const Thing* thing, Item** destItem,
           uint32_t& flags);

       virtual void __addThing(Creature* actor, int32_t index, Thing* thing);
       virtual void __internalAddThing(uint32_t index, Thing* thing);

       House* getHouse() {return house;}

   private:
       void updateHouse(Item* item);
       House* house;
};
#endif

0.3.7 housetile.cpp:
Code:
#include "otpch.h"
#include "housetile.h"

#include "house.h"
#include "game.h"
#include "configmanager.h"

extern ConfigManager g_config;
extern Game g_game;

HouseTile::HouseTile(int32_t x, int32_t y, int32_t z, House* _house):
   DynamicTile(x, y, z)
{
   house = _house;
   setFlag(TILESTATE_HOUSE);
}

void HouseTile::__addThing(Creature* actor, int32_t index, Thing* thing)
{
   Tile::__addThing(actor, index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::__internalAddThing(uint32_t index, Thing* thing)
{
   Tile::__internalAddThing(index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::updateHouse(Item* item)
{
   if(item->getTile() != this)
       return;

   if(Door* door = item->getDoor())
   {
       if(door->getDoorId() != 0)
           house->addDoor(door);
   }
   else if(BedItem* bed = item->getBed())
       house->addBed(bed);
}

ReturnValue HouseTile::__queryAdd(int32_t index, const Thing* thing, uint32_t count, uint32_t flags, Creature* actor/* = NULL*/) const
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanMoveAnywhere))
               return RET_PLAYERISNOTINVITED;
       }
       else
           return RET_NOTPOSSIBLE;
   }
   else if(thing->getItem())
   {
       const uint32_t itemLimit = g_config.getNumber(ConfigManager::HOUSE_TILE_LIMIT);
       if(itemLimit && getItemCount() > itemLimit)
           return RET_TILEISFULL;

       if(actor && g_config.getBool(ConfigManager::HOUSE_PROTECTION))
       {
           if(const Player* player = actor->getPlayer())
           {
               if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
                   return RET_PLAYERISNOTINVITED;
           }
       }
   }

   return Tile::__queryAdd(index, thing, count, flags, actor);
}

ReturnValue HouseTile::__queryRemove(const Thing* thing, uint32_t count, uint32_t flags, Creature* actor/* = NULL*/) const
{
   if(thing->getItem() && actor && g_config.getBool(ConfigManager::HOUSE_PROTECTION))
   {
       if(const Player* player = actor->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
               return RET_PLAYERISNOTINVITED;
       }
   }

   return Tile::__queryRemove(thing, count, flags, actor);
}

Cylinder* HouseTile::__queryDestination(int32_t& index, const Thing* thing, Item** destItem, uint32_t& flags)
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanMoveAnywhere))
           {
               Tile* destTile = g_game.getTile(house->getEntry());
               if(!destTile)
               {
                   std::clog << "[Error - HouseTile::__queryDestination] Tile at house entry position for house: "
                       << house->getName() << " (" << house->getId() << ") does not exist." << std::endl;
                   destTile = g_game.getTile(player->getMasterPosition());
                   if(!destTile)
                       destTile = &(Tile::nullTile);
               }

               index = -1;
               *destItem = NULL;
               return destTile;
           }
       }
   }

   return Tile::__queryDestination(index, thing, destItem, flags);
}

0.3.7 housetile.h:
Code:
#ifndef __HOUSETILE__
#define __HOUSETILE__
#include "tile.h"

class House;
class HouseTile : public DynamicTile
{
   public:
       HouseTile(int32_t x, int32_t y, int32_t z, House* _house);
       virtual ~HouseTile() {}

       virtual HouseTile* getHouseTile() {return this;}
       virtual const HouseTile* getHouseTile() const {return this;}
       virtual House* getHouse() {return house;}
       virtual const House* getHouse() const {return house;}

       //cylinder implementations
       virtual ReturnValue __queryAdd(int32_t index, const Thing* thing, uint32_t count,
           uint32_t flags, Creature* actor = NULL) const;
       virtual Cylinder* __queryDestination(int32_t& index, const Thing* thing, Item** destItem,
           uint32_t& flags);
       virtual ReturnValue __queryRemove(const Thing* thing, uint32_t count, uint32_t flags, Creature* actor = NULL) const;

       virtual void __addThing(Creature* actor, int32_t index, Thing* thing);
       virtual void __internalAddThing(uint32_t index, Thing* thing);

   private:
       void updateHouse(Item* item);
       House* house;
};
#endif
 
yeah I was looking for but, there is already something with "actor".

Okay this is from 0.3.6:
housetile.cpp:
Code:
#include "otpch.h"
#include "housetile.h"

#include "house.h"
#include "game.h"
#include "configmanager.h"

extern ConfigManager g_config;
extern Game g_game;

HouseTile::HouseTile(int32_t x, int32_t y, int32_t z, House* _house):
   DynamicTile(x, y, z)
{
   house = _house;
   setFlag(TILESTATE_HOUSE);
}

void HouseTile::__addThing(Creature* actor, int32_t index, Thing* thing)
{
   Tile::__addThing(actor, index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::__internalAddThing(uint32_t index, Thing* thing)
{
   Tile::__internalAddThing(index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::updateHouse(Item* item)
{
   if(item->getTile() != this)
       return;

   Door* door = item->getDoor();
   if(door && door->getDoorId())
       house->addDoor(door);
   else if(BedItem* bed = item->getBed())
       house->addBed(bed);
}

ReturnValue HouseTile::__queryAdd(int32_t index, const Thing* thing, uint32_t count, uint32_t flags) const
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player))
               return RET_PLAYERISNOTINVITED;
       }
       else
           return RET_NOTPOSSIBLE;
   }
   else if(thing->getItem())
   {
       const uint32_t itemLimit = g_config.getNumber(ConfigManager::ITEMLIMIT_HOUSETILE);
       if(itemLimit && getThingCount() > itemLimit)
           return RET_TILEISFULL;
   }

   return Tile::__queryAdd(index, thing, count, flags);
}

Cylinder* HouseTile::__queryDestination(int32_t& index, const Thing* thing, Item** destItem, uint32_t& flags)
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasFlag(PlayerFlag_CanEditHouses))
           {
               Tile* destTile = g_game.getTile(house->getEntry());
               if(!destTile)
               {
                   std::cout << "[Error - HouseTile::__queryDestination] Tile at house entry position for house: "
                       << house->getName() << " (" << house->getId() << ") does not exist." << std::endl;
                   destTile = g_game.getTile(player->getMasterPosition());
                   if(!destTile)
                       destTile = &(Tile::nullTile);
               }

               index = -1;
               *destItem = NULL;
               return destTile;
           }
       }
   }

   return Tile::__queryDestination(index, thing, destItem, flags);
}

0.3.6 housetile.h:
Code:
#ifndef __HOUSETILE__
#define __HOUSETILE__
#include "tile.h"

class House;
class HouseTile : public DynamicTile
{
   public:
       HouseTile(int32_t x, int32_t y, int32_t z, House* _house);
       virtual ~HouseTile() {}

       //cylinder implementations
       virtual ReturnValue __queryAdd(int32_t index, const Thing* thing, uint32_t count,
           uint32_t flags) const;
       virtual Cylinder* __queryDestination(int32_t& index, const Thing* thing, Item** destItem,
           uint32_t& flags);

       virtual void __addThing(Creature* actor, int32_t index, Thing* thing);
       virtual void __internalAddThing(uint32_t index, Thing* thing);

       House* getHouse() {return house;}

   private:
       void updateHouse(Item* item);
       House* house;
};
#endif

0.3.7 housetile.cpp:
Code:
#include "otpch.h"
#include "housetile.h"

#include "house.h"
#include "game.h"
#include "configmanager.h"

extern ConfigManager g_config;
extern Game g_game;

HouseTile::HouseTile(int32_t x, int32_t y, int32_t z, House* _house):
   DynamicTile(x, y, z)
{
   house = _house;
   setFlag(TILESTATE_HOUSE);
}

void HouseTile::__addThing(Creature* actor, int32_t index, Thing* thing)
{
   Tile::__addThing(actor, index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::__internalAddThing(uint32_t index, Thing* thing)
{
   Tile::__internalAddThing(index, thing);
   if(!thing->getParent())
       return;

   if(Item* item = thing->getItem())
       updateHouse(item);
}

void HouseTile::updateHouse(Item* item)
{
   if(item->getTile() != this)
       return;

   if(Door* door = item->getDoor())
   {
       if(door->getDoorId() != 0)
           house->addDoor(door);
   }
   else if(BedItem* bed = item->getBed())
       house->addBed(bed);
}

ReturnValue HouseTile::__queryAdd(int32_t index, const Thing* thing, uint32_t count, uint32_t flags, Creature* actor/* = NULL*/) const
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanMoveAnywhere))
               return RET_PLAYERISNOTINVITED;
       }
       else
           return RET_NOTPOSSIBLE;
   }
   else if(thing->getItem())
   {
       const uint32_t itemLimit = g_config.getNumber(ConfigManager::HOUSE_TILE_LIMIT);
       if(itemLimit && getItemCount() > itemLimit)
           return RET_TILEISFULL;

       if(actor && g_config.getBool(ConfigManager::HOUSE_PROTECTION))
       {
           if(const Player* player = actor->getPlayer())
           {
               if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
                   return RET_PLAYERISNOTINVITED;
           }
       }
   }

   return Tile::__queryAdd(index, thing, count, flags, actor);
}

ReturnValue HouseTile::__queryRemove(const Thing* thing, uint32_t count, uint32_t flags, Creature* actor/* = NULL*/) const
{
   if(thing->getItem() && actor && g_config.getBool(ConfigManager::HOUSE_PROTECTION))
   {
       if(const Player* player = actor->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
               return RET_PLAYERISNOTINVITED;
       }
   }

   return Tile::__queryRemove(thing, count, flags, actor);
}

Cylinder* HouseTile::__queryDestination(int32_t& index, const Thing* thing, Item** destItem, uint32_t& flags)
{
   if(const Creature* creature = thing->getCreature())
   {
       if(const Player* player = creature->getPlayer())
       {
           if(!house->isInvited(player) && !player->hasCustomFlag(PlayerCustomFlag_CanMoveAnywhere))
           {
               Tile* destTile = g_game.getTile(house->getEntry());
               if(!destTile)
               {
                   std::clog << "[Error - HouseTile::__queryDestination] Tile at house entry position for house: "
                       << house->getName() << " (" << house->getId() << ") does not exist." << std::endl;
                   destTile = g_game.getTile(player->getMasterPosition());
                   if(!destTile)
                       destTile = &(Tile::nullTile);
               }

               index = -1;
               *destItem = NULL;
               return destTile;
           }
       }
   }

   return Tile::__queryDestination(index, thing, destItem, flags);
}

0.3.7 housetile.h:
Code:
#ifndef __HOUSETILE__
#define __HOUSETILE__
#include "tile.h"

class House;
class HouseTile : public DynamicTile
{
   public:
       HouseTile(int32_t x, int32_t y, int32_t z, House* _house);
       virtual ~HouseTile() {}

       virtual HouseTile* getHouseTile() {return this;}
       virtual const HouseTile* getHouseTile() const {return this;}
       virtual House* getHouse() {return house;}
       virtual const House* getHouse() const {return house;}

       //cylinder implementations
       virtual ReturnValue __queryAdd(int32_t index, const Thing* thing, uint32_t count,
           uint32_t flags, Creature* actor = NULL) const;
       virtual Cylinder* __queryDestination(int32_t& index, const Thing* thing, Item** destItem,
           uint32_t& flags);
       virtual ReturnValue __queryRemove(const Thing* thing, uint32_t count, uint32_t flags, Creature* actor = NULL) const;

       virtual void __addThing(Creature* actor, int32_t index, Thing* thing);
       virtual void __internalAddThing(uint32_t index, Thing* thing);

   private:
       void updateHouse(Item* item);
       House* house;
};
#endif

Look where the function is called.
 
Back
Top