mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-11-02 04:46:23 +01:00
finalize fake characters logic
This commit is contained in:
@@ -1180,11 +1180,13 @@ void Player::onThink(uint32_t interval)
|
||||
}
|
||||
|
||||
lastWalkingTime += interval;
|
||||
if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer() && !isFakePlayer) {
|
||||
if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer()) {
|
||||
idleTime += interval;
|
||||
const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES);
|
||||
if ((!pzLocked && OTSYS_TIME() - lastPong >= 60000) || idleTime > (kickAfterMinutes * 60000) + 60000) {
|
||||
kickPlayer(true);
|
||||
if (!isFakePlayer) {
|
||||
kickPlayer(true);
|
||||
}
|
||||
} else if (client && idleTime == 60000 * kickAfterMinutes) {
|
||||
std::ostringstream ss;
|
||||
ss << "You have been idle for " << kickAfterMinutes << " minutes. You will be disconnected in one minute if you are still idle then.";
|
||||
@@ -1192,6 +1194,17 @@ void Player::onThink(uint32_t interval)
|
||||
}
|
||||
}
|
||||
|
||||
if (isFakePlayer && idleTime > uniform_random(60000, 120000)) {
|
||||
uint32_t r = uniform_random(0, 1);
|
||||
Direction dir = DIRECTION_NORTH;
|
||||
if (r == 0) {
|
||||
dir = DIRECTION_SOUTH;
|
||||
}
|
||||
|
||||
g_game.internalCreatureTurn(this, dir);
|
||||
resetIdleTime();
|
||||
}
|
||||
|
||||
if (g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) {
|
||||
checkSkullTicks();
|
||||
}
|
||||
@@ -1615,7 +1628,12 @@ void Player::dropLoot(Container* corpse, Creature*)
|
||||
|
||||
void Player::death(Creature* lastHitCreature)
|
||||
{
|
||||
loginPosition = town->getTemplePosition();
|
||||
if (isFakePlayer) {
|
||||
loginPosition = g_game.map.towns.getTown(10)->getTemplePosition(); // Isle of solitude
|
||||
}
|
||||
else {
|
||||
loginPosition = town->getTemplePosition();
|
||||
}
|
||||
|
||||
if (skillLoss) {
|
||||
//Magic level loss
|
||||
|
||||
@@ -279,7 +279,7 @@ class Player final : public Creature, public Cylinder
|
||||
return (getID() == 0);
|
||||
}
|
||||
void disconnect() {
|
||||
if (client && !isFakePlayer) {
|
||||
if (client) {
|
||||
client->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ extern Chat* g_chat;
|
||||
void ProtocolGame::release()
|
||||
{
|
||||
//dispatcher thread
|
||||
if (player && player->client == shared_from_this() && !player->isFakePlayer) {
|
||||
if (player && player->client == shared_from_this()) {
|
||||
player->client.reset();
|
||||
player->decrementReferenceCounter();
|
||||
player = nullptr;
|
||||
@@ -53,12 +53,18 @@ void ProtocolGame::release()
|
||||
Protocol::release();
|
||||
}
|
||||
|
||||
void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingSystem_t operatingSystem)
|
||||
void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingSystem_t operatingSystem, bool isFake)
|
||||
{
|
||||
//dispatcher thread
|
||||
Player* foundPlayer = g_game.getPlayerByName(name);
|
||||
if (!foundPlayer || g_config.getBoolean(ConfigManager::ALLOW_CLONES)) {
|
||||
player = new Player(getThis());
|
||||
if (!isFake) {
|
||||
player = new Player(getThis());
|
||||
}
|
||||
else
|
||||
{
|
||||
player = new Player(nullptr);
|
||||
}
|
||||
player->setName(name);
|
||||
player->incrementReferenceCounter();
|
||||
player->setID();
|
||||
@@ -161,6 +167,7 @@ void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingS
|
||||
connect(foundPlayer->getID(), operatingSystem);
|
||||
}
|
||||
}
|
||||
|
||||
OutputMessagePool::getInstance().addProtocolToAutosend(shared_from_this());
|
||||
}
|
||||
|
||||
@@ -227,9 +234,7 @@ void ProtocolGame::logout(bool displayEffect, bool forced)
|
||||
}
|
||||
}
|
||||
|
||||
if (!player->isFakePlayer) {
|
||||
disconnect();
|
||||
}
|
||||
disconnect();
|
||||
|
||||
g_game.removeCreature(player);
|
||||
}
|
||||
@@ -314,19 +319,20 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
|
||||
//Update premium days
|
||||
Game::updatePremium(account);
|
||||
|
||||
g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem)));
|
||||
if (characterName == "Sabrehaven") {
|
||||
if (characterName == "King Tibianus") {
|
||||
std::ostringstream query;
|
||||
Database* db = Database::getInstance();
|
||||
query << "SELECT `name`, `account_id` FROM `players` WHERE `fake_player` = 1 group by `account_id` limit 101";
|
||||
query << "SELECT `name`, `account_id` FROM `players` WHERE `fake_player` = 1 group by `account_id` limit 197";
|
||||
DBResult_ptr result;
|
||||
if ((result = db->storeQuery(query.str()))) {
|
||||
do {
|
||||
g_scheduler.addEvent(createSchedulerTask(uniform_random(1000, 60000), std::bind(&ProtocolGame::login, getThis(), result->getString("name"), result->getNumber<uint32_t>("account_id"), operatingSystem)));
|
||||
//g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), result->getString("name"), result->getNumber<uint32_t>("account_id"), operatingSystem)));
|
||||
g_scheduler.addEvent(createSchedulerTask(uniform_random(1000, 1000 * 60), std::bind(&ProtocolGame::login, getThis(), result->getString("name"), result->getNumber<uint32_t>("account_id"), operatingSystem, true)));
|
||||
} while (result->next());
|
||||
}
|
||||
}
|
||||
else {
|
||||
g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem, false)));
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolGame::onConnect()
|
||||
@@ -1461,6 +1467,10 @@ void ProtocolGame::sendSkills()
|
||||
|
||||
void ProtocolGame::sendPing()
|
||||
{
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkMessage msg;
|
||||
if (player->getOperatingSystem() >= CLIENTOS_OTCLIENT_LINUX) {
|
||||
msg.addByte(0x1D);
|
||||
|
||||
@@ -59,7 +59,7 @@ class ProtocolGame final : public Protocol
|
||||
|
||||
explicit ProtocolGame(Connection_ptr connection) : Protocol(connection) {}
|
||||
|
||||
void login(const std::string& name, uint32_t accnumber, OperatingSystem_t operatingSystem);
|
||||
void login(const std::string& name, uint32_t accnumber, OperatingSystem_t operatingSystem, bool isFake);
|
||||
void logout(bool displayEffect, bool forced);
|
||||
|
||||
uint16_t getVersion() const {
|
||||
|
||||
Reference in New Issue
Block a user