CraftingDialogTC::CraftingDialogTC(CraftingDialog &craftingDialog, unsigned int dialogId) : BasicServerCommand(SC_CRAFTINGDIALOG_TC) {
    addStringToBuffer(craftingDialog.getTitle());
    CraftingDialog::index_t numberOfGroups = craftingDialog.getGroupsSize();
    addUnsignedCharToBuffer(numberOfGroups);

    for (auto it = craftingDialog.getGroupsBegin(); it != craftingDialog.getGroupsEnd(); ++it) {
        addStringToBuffer(*it);
    }

    CraftingDialog::index_t numberOfCraftables = craftingDialog.getCraftablesSize();
    addUnsignedCharToBuffer(numberOfCraftables);

    for (auto it = craftingDialog.getCraftablesBegin(); it != craftingDialog.getCraftablesEnd(); ++it) {
        uint8_t craftableId = it->first;
        Craftable &craftable = *it->second;
        addUnsignedCharToBuffer(craftableId);
        addUnsignedCharToBuffer(craftable.getGroup());
        addShortIntToBuffer(craftable.getItem());
        addStringToBuffer(craftable.getName());
        addShortIntToBuffer(craftable.getDecisecondsToCraft());
        addUnsignedCharToBuffer(craftable.getCraftedStackSize());

        Craftable::index_t numberOfIngredients = craftable.getIngredientsSize();
        addUnsignedCharToBuffer(numberOfIngredients);

        for (auto it2 = craftable.getIngredientsBegin(); it2 != craftable.getIngredientsEnd(); ++it2) {
            Ingredient &ingredient = **it2;
            addShortIntToBuffer(ingredient.getItem());
            addUnsignedCharToBuffer(ingredient.getNumber());
        }
    }

    addIntToBuffer(dialogId);
}
InputDialogTC::InputDialogTC(InputDialog &inputDialog, unsigned int dialogId) : BasicServerCommand(SC_INPUTDIALOG_TC) {
    addStringToBuffer(inputDialog.getTitle());
    addStringToBuffer(inputDialog.getDescription());
    addUnsignedCharToBuffer(inputDialog.isMultiline() ? 1 : 0);
    addShortIntToBuffer(inputDialog.getMaxChars());
    addIntToBuffer(dialogId);
}
MerchantDialogTC::MerchantDialogTC(MerchantDialog &merchantDialog, unsigned int dialogId) : BasicServerCommand(SC_MERCHANTDIALOG_TC) {
    addStringToBuffer(merchantDialog.getTitle());
    MerchantDialog::index_type size = merchantDialog.getOffersSize();
    addUnsignedCharToBuffer(size);

    for (auto it = merchantDialog.getOffersBegin(); it != merchantDialog.getOffersEnd(); ++it) {
        OfferProduct &product = *(OfferProduct *)*it;
        addShortIntToBuffer(product.getItem());
        addStringToBuffer(product.getName());
        addIntToBuffer(product.getPrice());
        addShortIntToBuffer(product.getStack());
    }

    size = merchantDialog.getPrimaryRequestsSize();
    addUnsignedCharToBuffer(size);

    for (auto it = merchantDialog.getPrimaryRequestsBegin(); it != merchantDialog.getPrimaryRequestsEnd(); ++it) {
        addShortIntToBuffer((*it)->getItem());
        addStringToBuffer((*it)->getName());
        addIntToBuffer((*it)->getPrice());
    }

    size = merchantDialog.getSecondaryRequestsSize();
    addUnsignedCharToBuffer(size);

    for (auto it = merchantDialog.getSecondaryRequestsBegin(); it != merchantDialog.getSecondaryRequestsEnd(); ++it) {
        addShortIntToBuffer((*it)->getItem());
        addStringToBuffer((*it)->getName());
        addIntToBuffer((*it)->getPrice());
    }

    addIntToBuffer(dialogId);
}
AdminViewPlayersTC::AdminViewPlayersTC() : BasicServerCommand(SC_ADMINVIEWPLAYERS_TC) {
    World::PLAYERVECTOR::iterator titerator;
    unsigned short int count = World::get()->Players.size();
    addShortIntToBuffer(count);

    for (titerator = World::get()->Players.begin(); titerator < World::get()->Players.end(); ++titerator) {
        addStringToBuffer((*titerator)->name);
        addStringToBuffer((*titerator)->last_ip);
    }
}
SelectionDialogTC::SelectionDialogTC(SelectionDialog &selectionDialog, unsigned int dialogId) : BasicServerCommand(SC_SELECTIONDIALOG_TC) {
    addStringToBuffer(selectionDialog.getTitle());
    addStringToBuffer(selectionDialog.getText());
    SelectionDialog::index_type size = selectionDialog.getOptionsSize();
    addUnsignedCharToBuffer(size);

    for (auto it = selectionDialog.getOptionsBegin(); it != selectionDialog.getOptionsEnd(); ++it) {
        addShortIntToBuffer((*it)->getItem());
        addStringToBuffer((*it)->getName());
    }

    addIntToBuffer(dialogId);
}
 BBPlayerTC(TYPE_OF_CHARACTER_ID id, std::string name, int posx, int posy, int posz) : BasicServerCommand(BB_PLAYER_TC) {
     addIntToBuffer(id);
     addStringToBuffer(name);
     addIntToBuffer(posx);
     addIntToBuffer(posy);
     addIntToBuffer(posz);
     std::cout<<"sended data of new player: "<<name<<std::endl;
 }
AppearanceTC::AppearanceTC(Character *cc, Player *receivingPlayer) : BasicServerCommand(SC_APPEARANCE_TC) {
    addIntToBuffer(cc->id);

    if (cc->character == Character::player) {
        Player *player = dynamic_cast<Player *>(cc);

        if (receivingPlayer->knows(player)) {
            addStringToBuffer(player->name);
        } else {
            std::string german = "Jemand";
            std::string english = "Someone";
            addStringToBuffer(receivingPlayer->nls(german, english));
        }
    } else if (cc->character == Character::monster) {
        Monster *monster = dynamic_cast<Monster *>(cc);
        addStringToBuffer(receivingPlayer->nls(monster->nameDe, monster->name));
    } else {
        addStringToBuffer(cc->name);
    }

    addShortIntToBuffer(cc->race);
    addUnsignedCharToBuffer(cc->getAttribute(Character::sex));
    addShortIntToBuffer(cc->getAttribute(Character::hitpoints));
    addUnsignedCharToBuffer(RaceSizes->getRelativeSize(cc->race, cc->getAttribute(Character::height)));
    addUnsignedCharToBuffer(cc->hair);
    addUnsignedCharToBuffer(cc->beard);
    addUnsignedCharToBuffer(cc->hairred);
    addUnsignedCharToBuffer(cc->hairgreen);
    addUnsignedCharToBuffer(cc->hairblue);
    addUnsignedCharToBuffer(cc->skinred);
    addUnsignedCharToBuffer(cc->skingreen);
    addUnsignedCharToBuffer(cc->skinblue);

    for (unsigned char i = 0; i < MAX_BODY_ITEMS + MAX_BELT_SLOTS; ++i) {
        addShortIntToBuffer(cc->GetItemAt(i).getId());
    }

    uint8_t deathflag = cc->IsAlive() ? 0 : 1;
    addUnsignedCharToBuffer(deathflag);
}
SayTC::SayTC(int16_t x, int16_t y, int16_t z, std::string text) : BasicServerCommand(SC_SAY_TC) {
    addShortIntToBuffer(x);
    addShortIntToBuffer(y);
    addShortIntToBuffer(z);
    addStringToBuffer(text);
}
 BBTalkTC(TYPE_OF_CHARACTER_ID id, std::string name, uint8_t tt, std::string msg) : BasicServerCommand(BB_TALK_TC) {
     addIntToBuffer(id);
     addStringToBuffer(name);
     addUnsignedCharToBuffer(tt);
     addStringToBuffer(msg);
 }
 BBLogOutTC(TYPE_OF_CHARACTER_ID id, std::string name) : BasicServerCommand(BB_LOGOUT_TC) {
     addIntToBuffer(id);
     addStringToBuffer(name);
 }
Example #11
0
CharDescription::CharDescription(TYPE_OF_CHARACTER_ID id, std::string description) : BasicServerCommand(SC_LOOKATCHARRESULT_TC) {
    addIntToBuffer(id);
    addStringToBuffer(description);
}
Example #12
0
MessageDialogTC::MessageDialogTC(MessageDialog &messageDialog, unsigned int dialogId) : BasicServerCommand(SC_MESSAGEDIALOG_TC) {
    addStringToBuffer(messageDialog.getTitle());
    addStringToBuffer(messageDialog.getText());
    addIntToBuffer(dialogId);
}
Example #13
0
LookAtTileTC::LookAtTileTC(short int x, short int y, short int z, const std::string &lookAt) : BasicServerCommand(SC_LOOKATTILE_TC) {
    addShortIntToBuffer(x);
    addShortIntToBuffer(y);
    addShortIntToBuffer(z);
    addStringToBuffer(lookAt);
}
 BBSendAttribTC(TYPE_OF_CHARACTER_ID id, std::string attr, short int value) : BasicServerCommand(BB_SENDATTRIB_TC) {
     addIntToBuffer(id);
     addStringToBuffer(attr);
     addShortIntToBuffer(value);
 }
 BBMessageTC(std::string msg, uint8_t id) : BasicServerCommand(BB_MESSAGE_TC) {
     addStringToBuffer(msg);
     addUnsignedCharToBuffer(id);
 }
Example #16
0
WhisperTC::WhisperTC(int16_t x, int16_t y, int16_t z, std::string text) : BasicServerCommand(SC_WHISPER_TC) {
    addShortIntToBuffer(x);
    addShortIntToBuffer(y);
    addShortIntToBuffer(z);
    addStringToBuffer(text);
}
Example #17
0
IntroduceTC::IntroduceTC(TYPE_OF_CHARACTER_ID id, std::string name) : BasicServerCommand(SC_INTRODUCE_TC) {
    addIntToBuffer(id);
    addStringToBuffer(name);
}
 BBSendActionTC(TYPE_OF_CHARACTER_ID id, std::string name, uint8_t type, std::string desc) : BasicServerCommand(BB_SENDACTION_TC) {
     addIntToBuffer(id);
     addStringToBuffer(name);
     addUnsignedCharToBuffer(type);
     addStringToBuffer(desc);
 }
Example #19
0
InformTC::InformTC(Character::informType type, std::string text) : BasicServerCommand(SC_INFORM_TC) {
    addUnsignedCharToBuffer(type);
    addStringToBuffer(text);
}
Example #20
0
QByteArray & HWProto::addStringListToBuffer(QByteArray & buf, const QStringList & strList)
{
    for (int i = 0; i < strList.size(); i++)
        addStringToBuffer(buf, strList[i]);
    return buf;
}
Example #21
0
UpdateAttribTC::UpdateAttribTC(TYPE_OF_CHARACTER_ID id, std::string name, short int value) : BasicServerCommand(SC_UPDATEATTRIB_TC) {
    addIntToBuffer(id);
    addStringToBuffer(name);
    addShortIntToBuffer(value);
}