void BulletManager::tick(int nFps) { if (m_playerBody == 0) { createPlayerBody(); } }
Player* GhostGame::parseAddPlayerExPacket(Packet* packet) { int id = Packet::getInt(packet->getData()); ULL sId = Packet::getULongLong(packet->getData() + ID_SIZE); int x = Packet::getShort(packet->getData() + ID_SIZE + SID_SIZE); int y = Packet::getShort(packet->getData() + ID_SIZE + SID_SIZE + 2); char name[NAME_SIZE]; memcpy(name, packet->getData() + ID_SIZE + SID_SIZE + 4, sizeof(char) * NAME_SIZE); name[NAME_SIZE - 1] = '\0'; Player* player; std::map<int, Player*>::iterator it = players.find(id); if (it == players.end()) { player = new Player(id); players.insert(std::make_pair(id, player)); server->getPlayers()->insert(std::make_pair(id, player)); } else { // The player is local. player = it->second; } player->setSId(sId); player->setName(name); createPlayerBody(player); b2Vec2 position; position.Set(x, y); player->getBody()->SetTransform(position, 0.0f); players.insert(std::make_pair(id, player)); sessions.insert(std::make_pair(sId, player)); return player; }