void Appear_Reply(NetworkClient &client, net::Packet &packet)
{
std::shared_ptr<Map> map = client.game.map;//(client.map.lock());
uint8_t charAmount = packet.getChar();
packet.skip(1); // break
for(int i = 0; i < charAmount; ++i)
{
std::string name = packet.getBreakString();
uint16_t id = packet.getShort();
std::shared_ptr<Character> character = client.GetCharacterByID(id);
if(!character.get())
{
character.reset(new Character());
}
character->name = name;
character->id = id;
character->map_id = packet.getShort();
character->x = packet.getShort();
character->y = packet.getShort();
character->direction = Direction(packet.getChar());
packet.getChar(); // ?
packet.getFixedString(3); // guild tag
character->level = packet.getChar();
character->gender = Gender(packet.getChar());
packet.getChar(); // hair style
packet.getChar(); // hair color
character->skin = Skin(packet.getChar());
character->max_hp = packet.getShort();
character->hp = packet.getShort();
character->max_tp = packet.getShort();
character->tp = packet.getShort();
for(int i = 0; i < 9; i++) packet.getShort(); // paperdoll
character->sit_state = SitState(packet.getChar());
packet.getChar(); // visiblity
packet.skip(1); // break
if(character->sit_state == SitState::Floor)
{
character->Sit(SitState::Floor);
}
map->AddObject(character);
}
while(packet.readPos() < packet.length())
{
uint8_t index = packet.getChar();
std::shared_ptr<NPC> npc = client.GetNPCByIndex(index);
if(!npc.get())
{
npc.reset(new NPC());
//map->AddObject(npc);
}
npc->index = index;
npc->id = packet.getShort();
npc->x = packet.getChar();
npc->y = packet.getChar();
npc->direction = Direction(packet.getChar());
}
}