• 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!

[C++][TFS 0.3.6] Problem with protocolgame.cpp

KylerXX

Active Member
Joined
Jun 24, 2010
Messages
439
Reaction score
30
protocolgame.cpp
Code:
void ProtocolGame::AddCreature(NetworkMessage_ptr msg, const Creature* creature, bool known, uint32_t remove)
{
	if(!known)
	{
		msg->AddU16(0x61);
		msg->AddU32(remove);
		msg->AddU32(creature->getID());
        if(!creature->getStorage(848438, -1))
        {
            msg->AddString(creature->getHideName() ? "" : creature->getName());
        }
        else
        {
        msg->AddString("El culeado");
        }

	}
	else
	{
		msg->AddU16(0x62);
		msg->AddU32(creature->getID());
	}

	if(!creature->getHideHealth())
		msg->AddByte((int32_t)std::ceil(((float)creature->getHealth()) * 100 / std::max(creature->getMaxHealth(), (int32_t)1)));
	else
		msg->AddByte(0x00);

	msg->AddByte((uint8_t)creature->getDirection());
	AddCreatureOutfit(msg, creature, creature->getCurrentOutfit());

	LightInfo lightInfo;
	creature->getCreatureLight(lightInfo);
	msg->AddByte(player->hasCustomFlag(PlayerCustomFlag_HasFullLight) ? 0xFF : lightInfo.level);
	msg->AddByte(lightInfo.color);

	msg->AddU16(creature->getStepSpeed());
	msg->AddByte(player->getSkullClient(creature));
	msg->AddByte(player->getPartyShield(creature));
	if(!known)
		msg->AddByte(0x00); // war emblem

	msg->AddByte(!player->canWalkthrough(creature));
}


Why this part of the code dont work:
Code:
if(!creature->getStorage(848438, -1))
        {
            msg->AddString(creature->getHideName() ? "" : creature->getName());
        }
        else
        {
        msg->AddString("El culeado");
        }

Shows this error:
Code:
../protocolgame.cpp: In member function `void ProtocolGame::AddCreature(NetworkMessage_ptr, const Creature*, bool, uint32_t)':

../protocolgame.cpp:2662: error: no matching function for call to `Creature::getStorage(int, int) const'

../creature.h:324: note: candidates are: virtual bool Creature::getStorage(uint32_t, std::string&) const
 
cause as you can see values are stored as strings
change -1 to "-1" or something
also if it would still complain then use uint32_t(848438) instead of 848438
 
Still the error:
Code:
 ../protocolgame.cpp: In member function `void ProtocolGame::AddCreature(NetworkMessage_ptr, const Creature*, bool, uint32_t)':

../protocolgame.cpp:2662: error: no matching function for call to `Creature::getStorage(uint32_t, const char[3]) const'

../creature.h:324: note: candidates are: virtual bool Creature::getStorage(uint32_t, std::string&) const
 
Code:
../protocolgame.cpp:2662:52: warning: multi-character character constant
../protocolgame.cpp: In member function `void ProtocolGame::AddCreature(NetworkMessage_ptr, const Creature*, bool, uint32_t)':
../protocolgame.cpp:2662: error: no matching function for call to `Creature::getStorage(uint32_t, int) const'

../creature.h:324: note: candidates are: virtual bool Creature::getStorage(uint32_t, std::string&) const
 
[cpp]
std::string value = "-1";

if(!creature->getStorage(uint32_t(848438), value))
msg->AddString(creature->getHideName() ? "" : creature->getName());
else
msg->AddString("El culeado");
[/cpp]


I'm not sure that it will works.
 
Back
Top