• 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 1.3 Help with new functions

TomCrusher

Jeg er ingenting
Premium User
Joined
Dec 31, 2008
Messages
663
Reaction score
18
Location
Norway
Hello,

Working with custom functions and stuck with crashes after sending these via protocolgame. Has someone idea what I doing wrong?
Here is these:
C++:
void ProtocolGame::removeKnownCreature(uint32_t id)
{
    knownCreatureSet.insert(id);
    for (auto it = knownCreatureSet.begin(), end = knownCreatureSet.end(); it != end; ++it) {
        Creature* creature = g_game.getCreatureByID(*it);
        if (!canSee(creature)) {
            knownCreatureSet.erase(id);
            //g_game.removeCreature(id);
            return;
        }
        else {
            bool known;
            uint32_t removedKnown;
            checkCreatureAsKnown(id, known, removedKnown);
        }
    }       
}

void ProtocolGame::sendUpdateCreature(const Creature* creature, const Position& pos, uint32_t stackpos) //change name system
{
    for (auto it = knownCreatureSet.begin(), end = knownCreatureSet.end(); it != end; ++it) {
        Creature* creature = g_game.getCreatureByID(*it);
        if(it != knownCreatureSet.end()) {
              if(canSee(creature)){
                   if(creature == player){
                        NetworkMessage msg;
                        RemoveTileThing(msg, pos, stackpos);
                        removeKnownCreature(creature->getID());
                        sendMapDescription(pos);
                   }
                   else {
                    g_game.removeCreature(creature); //RemoveTileThing(creature, pos, stackpos);
                    removeKnownCreature(creature->getID());
                    sendAddCreature(creature, pos, stackpos, false);
                }
            }
            else {
                removeKnownCreature(creature->getID());
            }
        }
    }
}

void ProtocolGame::sendCreatureEmblem(const Creature* creature)
{
    if(!canSee(creature))
        return;

    uint32_t stackpos = creature->getTile()->getClientIndexOfCreature(player, creature);
    if(stackpos >= 10)
        return;

    NetworkMessage msg;
    for (auto it = knownCreatureSet.begin(), end = knownCreatureSet.end(); it != end; ++it) {
        Creature* creature = g_game.getCreatureByID(*it);
        if(it != knownCreatureSet.end()) {
            RemoveTileThing(msg, creature->getPosition(), stackpos);
            msg.addByte(0x6A);

            msg.addPosition(creature->getPosition());
            msg.addByte(stackpos);
            AddCreature(msg, creature, false, creature->getID());
        }   
    }
}
 
Top