error: no matching function for call to 'House::getDescription()'

0

witam mam problem i za bardzo nie ogarniam jak to naprawić

protocol76.cpp: In member function 'void Protocol76::parseLookAt(NetworkMessage&)':
protocol76.cpp:1438:80: error: no matching function for call to 'House::getDescription()'
protocol76.cpp:1438:80: note: candidate is:
In file included from player.h:13:0,
                 from spells.h:6,
                 from game.h:19,
                 from protocol.h:5,
                 from protocol76.h:5,
                 from protocol76.cpp:8:
houses.h:46:14: note: std::string House::getDescription(uint32_t) const
houses.h:46:14: note:   candidate expects 1 argument, 0 provided
 
void Protocol76::parseLookAt(NetworkMessage &msg)
{
	Position LookPos = msg.GetPosition();
	uint16_t ItemNum = msg.GetU16();
	uint8_t stackpos = msg.GetByte();

	NetworkMessage newmsg;
	std::stringstream ss;

	Item *item = nullptr;
	Creature *creature = nullptr;
	OTSYS_THREAD_LOCK_CLASS lockClass(game->gameLock, "Protocol76::parseLookAt()");

	if(LookPos.x != 0xFFFF) {
        Tile* tile = game->getTile(LookPos.x, LookPos.y, LookPos.z);
        if(tile){
            item = dynamic_cast<Item*>(tile->getTopThing());
			creature = dynamic_cast<Creature*>(tile->getTopThing());
		}
	}
	else {
		//from container/inventory
		if(LookPos.y & 0x40) {
			unsigned char from_cid = LookPos.y & 0x0F;
			unsigned char slot = LookPos.z;

			Container *parentcontainer = player->getContainer(from_cid);
			if(!parentcontainer)
				return;

			item = parentcontainer->getItem(slot);
		}
		else {
			unsigned char from_cid = static_cast<unsigned char>(LookPos.y);
			item = player->getItem(from_cid);
		}
	}

	Player *toPlayer = dynamic_cast<Player*>(creature);
       if((item && (!toPlayer)) || (item && toPlayer && toPlayer != player && toPlayer->access > player->access && toPlayer->gmInvisible))
       {
        Tile* doorTile = game->getTile(LookPos);
        Thing* doorThing = doorTile? doorTile->getTopThing() : nullptr;
        Item* doorItem = doorThing? dynamic_cast<Item*>(doorThing) : nullptr;
		if (doorItem && Item::items[doorItem->getID()].isDoor && doorTile && doorTile->getHouse())
			AddTextMessage(newmsg, MSG_INFO_DESCR, doorTile->getHouse()->getDescription().c_str());
		else
		{
			bool fullDescription = false;
			if(LookPos.x == 0xFFFF) {
				fullDescription = true;
			}
			else if(std::abs(player->pos.x - LookPos.x) <= 1 && std::abs(player->pos.y - LookPos.y) <= 1 &&
				LookPos.z == player->pos.z) {
				fullDescription = true;
			}

			std::stringstream ss;
			ss << "You see " << item->getDescription(fullDescription);
			if (player->access >= g_config.ACCESS_LOOK)
			     ss << "\nId: " << Item::items.reverseLookUp(ItemNum)
			     << ". Pos: " << LookPos.x << ' ' << LookPos.y << ' ' << LookPos.z << '.';

			AddTextMessage(newmsg,MSG_INFO_DESCR, ss.str().c_str());
		}
	}
	else if(creature) {
		if(player == creature) {
			std::stringstream ss;
			ss << "You see " << creature->getDescription(true);
			AddTextMessage(newmsg,MSG_INFO_DESCR, ss.str().c_str());
		}
#ifdef _BBK_GM_INVISIBLE
        else
        {
            Player* gm = dynamic_cast<Player*>(creature);
            if(gm && gm->gmInvisible && player->access < g_config.ACCESS_PROTECT)
            {
                std::stringstream ss;
                Tile* tile = game->getTile(gm->pos);
                if(tile)
                {
                    Item *item = tile->getTopTopItem();
                    if(item)
                    {
                        ss << "You see " << item->getDescription(true);
                    }
                    else
                    {
                        Item *thing = dynamic_cast<Item*>(tile->getTopDownItem());
                        if(thing)
                            ss << "You see " << thing->getDescription(true);
                        else
                            ss << "You see " << tile->ground->getDescription(true);
                    }
                }
                else
                    ss << "Yyy..";

                AddTextMessage(newmsg,MSG_INFO_DESCR, ss.str().c_str());
            }
            else
            {
                std::stringstream ss;
                ss << "You see " << creature->getDescription().c_str();
                AddTextMessage(newmsg,MSG_INFO_DESCR, ss.str().c_str());
            }
        }
    }
#else
        else
        {
            std::stringstream ss;
            ss << "You see " << creature->getDescription().c_str();
            AddTextMessage(newmsg,MSG_INFO_DESCR, ss.str().c_str());
        }
    }
#endif //_BBK_GM_INVISIBLE
	sendNetworkMessage(&newmsg);
} 
1

Dlaczego nikt nie odpowiada w moim wątku? - nie każdemu chce się szukac 80 linii w kodzie.

Funkcja getDescription wymaga 1 argumentu, podajesz zero.

0
kq napisał(a):

Dlaczego nikt nie odpowiada w moim wątku? - nie każdemu chce się szukac 80 linii w kodzie.

Funkcja getDescription wymaga 1 argumentu, podajesz zero.

nie bardzo rozumiem
mam dodać np int getDescription;

1
Matthew John Miernik napisał(a):
kq napisał(a):

Funkcja getDescription wymaga 1 argumentu, podajesz zero.

nie bardzo rozumiem
mam dodać np int getDescription;

Tam gdzie wołasz funkcję getDescription() masz podać jeden argument, bo funkcja tego oczekuje. W tej chwili nic nie przekazujesz do funkcji. Jeśli to Ci nic nie mówi to najwyraźniej nie jest to Twój kod.

1

nie bardzo rozumiem
mam dodać np int getDescription;

Metoda getDescription() nie ma definicji bezargumentowej.

0
twonek napisał(a):
Matthew John Miernik napisał(a):
kq napisał(a):

Funkcja getDescription wymaga 1 argumentu, podajesz zero.

nie bardzo rozumiem
mam dodać np int getDescription;

Tam gdzie wołasz funkcję getDescription() masz podać jeden argument, bo funkcja tego oczekuje. W tej chwili nic nie przekazujesz do funkcji. Jeśli to Ci nic nie mówi to najwyraźniej nie jest to Twój kod.

carlosmay napisał(a):

nie bardzo rozumiem
mam dodać np int getDescription;

Metoda getDescription() nie ma definicji bezargumentowej.

nie mój kod

chodzi o to ? zeby zmienić to
ss << "You see " << item->getDescription(fullDescription);
na
ss << "You see " << item->getDescription(uint32_t lookDistance);

w house cpp mam tak
std::string House::getDescription(uint32_t lookDistance) const

i house.h
std::string getDescription(uint32_t lookDistance) const;

0

zmieniłem troche kod na
AddTextMessage(newmsg, MSG_INFO_DESCR, doorTile->getHouse()->getDescription(uint32_t lookDistance).c_str());//

teraz takie cos wywala
protocol76.cpp: In member function 'void Protocol76::parseLookAt(NetworkMessage&)':
protocol76.cpp:1438:89: error: expected primary-expression before 'lookDistance'

1
doorTile->getHouse()->getDescription(uint32_t lookDistance).c_str() 

Definiowanie zmiennej w liście argumentów wywołania funkcji nie jest dozwolone.
Jaką wartość ma deklarowana zmienna lookDistance skoro utworzona została w nawiasie wywołania metody?

Można wyobrazić sobie to tak:

void print(int a)
{
	std::cout << a;
}

int main()
{
	print(int b);
	int c = 5;
	print(c);
}

// czyli int a = int b; - błąd 
// czyli int a = c; - OK 

1 użytkowników online, w tym zalogowanych: 0, gości: 1