mirror of
				https://github.com/ErikasKontenis/SabrehavenServer.git
				synced 2025-10-31 03:56:22 +01:00 
			
		
		
		
	prepare fake players mechanism
This commit is contained in:
		| @@ -1,3 +1,108 @@ | |||||||
|  | local fakePlayers = { | ||||||
|  | 	{x = 32864, y = 31997, z = 7}, | ||||||
|  | 	{x = 32864, y = 31998, z = 7}, | ||||||
|  | 	{x = 32865, y = 31999, z = 7}, | ||||||
|  | 	{x = 32871, y = 31999, z = 7}, | ||||||
|  | 	{x = 32872, y = 32000, z = 7}, | ||||||
|  | 	{x = 32825, y = 32065, z = 7}, | ||||||
|  | 	{x = 32828, y = 32065, z = 7}, | ||||||
|  | 	{x = 32885, y = 32050, z = 7}, | ||||||
|  | 	{x = 32885, y = 32049, z = 7}, | ||||||
|  | 	{x = 32823, y = 31887, z = 7}, | ||||||
|  | 	{x = 32691, y = 31716, z = 7}, | ||||||
|  | 	{x = 32705, y = 31787, z = 7}, | ||||||
|  | 	{x = 32716, y = 31928, z = 7}, | ||||||
|  | 	{x = 32880, y = 31845, z = 7}, | ||||||
|  | 	{x = 32879, y = 31845, z = 7}, | ||||||
|  | 	{x = 32882, y = 31840, z = 7}, | ||||||
|  | 	{x = 32655, y = 32109, z = 8}, | ||||||
|  | 	{x = 32665, y = 32109, z = 8}, | ||||||
|  | 	{x = 32254, y = 32019, z = 7}, | ||||||
|  | 	{x = 32255, y = 32020, z = 7}, | ||||||
|  | 	{x = 32245, y = 32021, z = 7}, | ||||||
|  | 	{x = 32238, y = 32330, z = 7}, | ||||||
|  | 	{x = 32238, y = 32331, z = 7}, | ||||||
|  | 	{x = 32273, y = 32396, z = 7}, | ||||||
|  | 	{x = 32465, y = 32315, z = 7}, | ||||||
|  | 	{x = 32225, y = 31740, z = 7}, | ||||||
|  | 	{x = 32230, y = 31739, z = 7}, | ||||||
|  | 	{x = 32257, y = 31838, z = 7}, | ||||||
|  | 	{x = 32258, y = 31840, z = 7}, | ||||||
|  | 	{x = 32258, y = 31844, z = 7}, | ||||||
|  | 	{x = 32260, y = 31846, z = 7}, | ||||||
|  | 	{x = 32261, y = 31848, z = 7}, | ||||||
|  | 	{x = 32231, y = 31701, z = 7}, | ||||||
|  | 	{x = 32516, y = 31599, z = 7}, | ||||||
|  | 	{x = 32486, y = 31590, z = 7}, | ||||||
|  | 	{x = 32493, y = 31590, z = 7}, | ||||||
|  | 	{x = 32503, y = 31670, z = 7}, | ||||||
|  | 	{x = 32579, y = 31928, z = 0}, | ||||||
|  | 	{x = 32596, y = 31922, z = 0}, | ||||||
|  | 	{x = 32621, y = 31921, z = 1}, | ||||||
|  | 	{x = 32651, y = 31942, z = 7}, | ||||||
|  | 	{x = 32531, y = 32721, z = 7}, | ||||||
|  | 	{x = 32531, y = 32720, z = 7}, | ||||||
|  | 	{x = 32530, y = 32720, z = 7}, | ||||||
|  | 	{x = 32537, y = 32813, z = 7}, | ||||||
|  | 	{x = 32537, y = 32814, z = 7}, | ||||||
|  | 	{x = 32537, y = 32759, z = 7}, | ||||||
|  | 	{x = 32538, y = 32759, z = 7}, | ||||||
|  | 	{x = 33023, y = 32872, z = 7}, | ||||||
|  | 	{x = 33023, y = 32871, z = 7}, | ||||||
|  | 	{x = 33023, y = 32870, z = 7}, | ||||||
|  | 	{x = 33275, y = 32829, z = 7}, | ||||||
|  | 	{x = 33238, y = 32555, z = 7}, | ||||||
|  | 	{x = 33237, y = 32555, z = 7}, | ||||||
|  | 	{x = 33187, y = 32343, z = 7}, | ||||||
|  | 	{x = 33187, y = 32342, z = 7}, | ||||||
|  | 	{x = 33152, y = 32354, z = 7}, | ||||||
|  | 	{x = 33154, y = 32354, z = 7}, | ||||||
|  | 	{x = 33076, y = 32345, z = 7}, | ||||||
|  | 	{x = 32655, y = 31648, z = 10}, | ||||||
|  | 	{x = 32656, y = 31648, z = 10}, | ||||||
|  | 	{x = 32657, y = 31648, z = 10}, | ||||||
|  | 	{x = 33262, y = 31866, z = 7}, | ||||||
|  | 	{x = 33263, y = 31866, z = 7}, | ||||||
|  | 	{x = 33244, y = 31904, z = 7}, | ||||||
|  | 	{x = 33245, y = 31903, z = 7}, | ||||||
|  | 	{x = 33219, y = 31926, z = 7}, | ||||||
|  | 	{x = 33298, y = 31839, z = 7}, | ||||||
|  | 	{x = 33298, y = 31838, z = 7}, | ||||||
|  | 	{x = 33358, y = 31692, z = 9}, | ||||||
|  | 	{x = 33359, y = 31692, z = 9}, | ||||||
|  | 	{x = 33360, y = 31692, z = 9}, | ||||||
|  | 	{x = 33362, y = 31696, z = 9}, | ||||||
|  | 	{x = 33366, y = 31696, z = 9}, | ||||||
|  | 	{x = 33318, y = 31728, z = 7}, | ||||||
|  | 	{x = 33318, y = 31729, z = 7}, | ||||||
|  | 	{x = 33273, y = 31680, z = 7}, | ||||||
|  | 	{x = 33169, y = 31737, z = 7}, | ||||||
|  | 	{x = 33274, y = 31791, z = 6}, | ||||||
|  | 	{x = 33321, y = 32419, z = 7}, | ||||||
|  | 	{x = 33318, y = 32406, z = 7}, | ||||||
|  | 	{x = 32372, y = 32840, z = 7}, | ||||||
|  | 	{x = 32371, y = 32839, z = 7}, | ||||||
|  | 	{x = 32369, y = 32838, z = 7}, | ||||||
|  | 	{x = 32347, y = 32691, z = 7}, | ||||||
|  | 	{x = 32348, y = 32692, z = 7}, | ||||||
|  | 	{x = 32157, y = 32783, z = 7}, | ||||||
|  | 	{x = 32225, y = 32880, z = 7}, | ||||||
|  | 	{x = 32386, y = 32695, z = 7}, | ||||||
|  | 	{x = 32314, y = 32830, z = 8}, | ||||||
|  | 	{x = 32593, y = 31885, z = 12}, | ||||||
|  | 	{x = 32593, y = 31884, z = 12}, | ||||||
|  | 	{x = 32586, y = 31919, z = 10}, | ||||||
|  | 	{x = 32547, y = 31921, z = 10}, | ||||||
|  | 	{x = 32763, y = 31941, z = 7}, | ||||||
|  | 	{x = 32763, y = 31942, z = 7}, | ||||||
|  | 	{x = 32700, y = 31842, z = 7}, | ||||||
|  | 	{x = 32700, y = 31841, z = 7}, | ||||||
|  | 	{x = 32991, y = 32377, z = 7}, | ||||||
|  | 	{x = 32314, y = 32282, z = 7} | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| function onLogin(player) | function onLogin(player) | ||||||
| 	local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!" | 	local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!" | ||||||
| 	if player:getLastLoginSaved() <= 0 then | 	if player:getLastLoginSaved() <= 0 then | ||||||
| @@ -40,6 +145,16 @@ function onLogin(player) | |||||||
| 		player:setStorageValue(43434, 0) | 		player:setStorageValue(43434, 0) | ||||||
| 	end | 	end | ||||||
| 	 | 	 | ||||||
|  | 	-- FakePlayer | ||||||
|  | 	if player:isFakePlayer() then | ||||||
|  | 		local inFightCondition = Condition(CONDITION_INFIGHT) | ||||||
|  | 		inFightCondition:setParameter(CONDITION_PARAM_TICKS, 2000 * 60 * 1000) | ||||||
|  | 		player:addCondition(inFightCondition) | ||||||
|  | 		player:teleportTo(fakePlayers[1]) | ||||||
|  | 		table.remove(fakePlayers, 1) | ||||||
|  | 		-- TODO give random bps, lvls, mls | ||||||
|  | 	end | ||||||
|  | 	 | ||||||
| 	-- Events | 	-- Events | ||||||
| 	player:registerEvent("PlayerDeath") | 	player:registerEvent("PlayerDeath") | ||||||
| 	player:registerEvent("kills") | 	player:registerEvent("kills") | ||||||
|   | |||||||
| @@ -196,7 +196,7 @@ function onStartup() | |||||||
| 	end | 	end | ||||||
| 	 | 	 | ||||||
| 	spawnRashid() | 	spawnRashid() | ||||||
| 	addEvent(function () Game.setGameState(GAME_STATE_CLOSED) end, 5000) | 	--addEvent(function () Game.setGameState(GAME_STATE_CLOSED) end, 5000) | ||||||
| 	setGlobalStorageValue(17657, 0) -- reset POI levers | 	setGlobalStorageValue(17657, 0) -- reset POI levers | ||||||
| 	setGlobalStorageValue(8420, monsterOfTheDay[math.random(1, #monsterOfTheDay)].id) | 	setGlobalStorageValue(8420, monsterOfTheDay[math.random(1, #monsterOfTheDay)].id) | ||||||
| 	setGlobalStorageValue(8421, math.random(10, 25)) | 	setGlobalStorageValue(8421, math.random(10, 25)) | ||||||
|   | |||||||
| @@ -190,7 +190,7 @@ bool IOLoginData::preloadPlayer(Player* player, const std::string& name) | |||||||
| bool IOLoginData::loadPlayerById(Player* player, uint32_t id) | bool IOLoginData::loadPlayerById(Player* player, uint32_t id) | ||||||
| { | { | ||||||
| 	std::ostringstream query; | 	std::ostringstream query; | ||||||
| 	query << "SELECT `id`, `name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `blessings`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `conditions`, `skulltime`, `skull`, `town_id`, `balance`, `offlinetraining_time`, `offlinetraining_skill`, `stamina`, `skill_fist`, `skill_fist_tries`, `skill_club`, `skill_club_tries`, `skill_sword`, `skill_sword_tries`, `skill_axe`, `skill_axe_tries`, `skill_dist`, `skill_dist_tries`, `skill_shielding`, `skill_shielding_tries`, `skill_fishing`, `skill_fishing_tries` FROM `players` WHERE `id` = " << id; | 	query << "SELECT `id`, `name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `blessings`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `conditions`, `skulltime`, `skull`, `town_id`, `balance`, `offlinetraining_time`, `offlinetraining_skill`, `stamina`, `skill_fist`, `skill_fist_tries`, `skill_club`, `skill_club_tries`, `skill_sword`, `skill_sword_tries`, `skill_axe`, `skill_axe_tries`, `skill_dist`, `skill_dist_tries`, `skill_shielding`, `skill_shielding_tries`, `skill_fishing`, `skill_fishing_tries`, `fake_player` FROM `players` WHERE `id` = " << id; | ||||||
| 	return loadPlayer(player, Database::getInstance()->storeQuery(query.str())); | 	return loadPlayer(player, Database::getInstance()->storeQuery(query.str())); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -198,7 +198,7 @@ bool IOLoginData::loadPlayerByName(Player* player, const std::string& name) | |||||||
| { | { | ||||||
| 	Database* db = Database::getInstance(); | 	Database* db = Database::getInstance(); | ||||||
| 	std::ostringstream query; | 	std::ostringstream query; | ||||||
| 	query << "SELECT `id`, `name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `blessings`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `conditions`, `skulltime`, `skull`, `town_id`, `balance`, `offlinetraining_time`, `offlinetraining_skill`, `stamina`, `skill_fist`, `skill_fist_tries`, `skill_club`, `skill_club_tries`, `skill_sword`, `skill_sword_tries`, `skill_axe`, `skill_axe_tries`, `skill_dist`, `skill_dist_tries`, `skill_shielding`, `skill_shielding_tries`, `skill_fishing`, `skill_fishing_tries` FROM `players` WHERE `name` = " << db->escapeString(name); | 	query << "SELECT `id`, `name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `blessings`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `conditions`, `skulltime`, `skull`, `town_id`, `balance`, `offlinetraining_time`, `offlinetraining_skill`, `stamina`, `skill_fist`, `skill_fist_tries`, `skill_club`, `skill_club_tries`, `skill_sword`, `skill_sword_tries`, `skill_axe`, `skill_axe_tries`, `skill_dist`, `skill_dist_tries`, `skill_shielding`, `skill_shielding_tries`, `skill_fishing`, `skill_fishing_tries`, `fake_player` FROM `players` WHERE `name` = " << db->escapeString(name); | ||||||
| 	return loadPlayer(player, db->storeQuery(query.str())); | 	return loadPlayer(player, db->storeQuery(query.str())); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -320,6 +320,7 @@ bool IOLoginData::loadPlayer(Player* player, DBResult_ptr result) | |||||||
|  |  | ||||||
| 	player->lastLoginSaved = result->getNumber<time_t>("lastlogin"); | 	player->lastLoginSaved = result->getNumber<time_t>("lastlogin"); | ||||||
| 	player->lastLogout = result->getNumber<time_t>("lastlogout"); | 	player->lastLogout = result->getNumber<time_t>("lastlogout"); | ||||||
|  | 	player->isFakePlayer = result->getNumber<int32_t>("fake_player") == 1; | ||||||
|  |  | ||||||
| 	player->offlineTrainingTime = result->getNumber<int32_t>("offlinetraining_time") * 1000; | 	player->offlineTrainingTime = result->getNumber<int32_t>("offlinetraining_time") * 1000; | ||||||
| 	player->offlineTrainingSkill = result->getNumber<int32_t>("offlinetraining_skill"); | 	player->offlineTrainingSkill = result->getNumber<int32_t>("offlinetraining_skill"); | ||||||
|   | |||||||
| @@ -2105,6 +2105,7 @@ void LuaScriptInterface::registerFunctions() | |||||||
| 	registerMethod("Player", "save", LuaScriptInterface::luaPlayerSave); | 	registerMethod("Player", "save", LuaScriptInterface::luaPlayerSave); | ||||||
|  |  | ||||||
| 	registerMethod("Player", "isPzLocked", LuaScriptInterface::luaPlayerIsPzLocked); | 	registerMethod("Player", "isPzLocked", LuaScriptInterface::luaPlayerIsPzLocked); | ||||||
|  | 	registerMethod("Player", "isFakePlayer", LuaScriptInterface::luaPlayerIsFakePlayer); | ||||||
|  |  | ||||||
| 	registerMethod("Player", "getClient", LuaScriptInterface::luaPlayerGetClient); | 	registerMethod("Player", "getClient", LuaScriptInterface::luaPlayerGetClient); | ||||||
| 	registerMethod("Player", "getHouse", LuaScriptInterface::luaPlayerGetHouse); | 	registerMethod("Player", "getHouse", LuaScriptInterface::luaPlayerGetHouse); | ||||||
| @@ -7111,6 +7112,7 @@ int LuaScriptInterface::luaPlayerIsPlayer(lua_State* L) | |||||||
| 	return 1; | 	return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| int LuaScriptInterface::luaPlayerGetGuid(lua_State* L) | int LuaScriptInterface::luaPlayerGetGuid(lua_State* L) | ||||||
| { | { | ||||||
| 	// player:getGuid() | 	// player:getGuid() | ||||||
| @@ -8741,6 +8743,19 @@ int LuaScriptInterface::luaPlayerIsPzLocked(lua_State* L) | |||||||
| 	return 1; | 	return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int LuaScriptInterface::luaPlayerIsFakePlayer(lua_State* L) | ||||||
|  | { | ||||||
|  | 	// player:isFakePlayer() | ||||||
|  | 	Player* player = getUserdata<Player>(L, 1); | ||||||
|  | 	if (player) { | ||||||
|  | 		pushBoolean(L, player->isFakePlayer); | ||||||
|  | 	} | ||||||
|  | 	else { | ||||||
|  | 		lua_pushnil(L); | ||||||
|  | 	} | ||||||
|  | 	return 1; | ||||||
|  | } | ||||||
|  |  | ||||||
| int LuaScriptInterface::luaPlayerGetClient(lua_State* L) | int LuaScriptInterface::luaPlayerGetClient(lua_State* L) | ||||||
| { | { | ||||||
| 	// player:getClient() | 	// player:getClient() | ||||||
|   | |||||||
| @@ -925,6 +925,7 @@ class LuaScriptInterface | |||||||
| 		static int luaPlayerSave(lua_State* L); | 		static int luaPlayerSave(lua_State* L); | ||||||
|  |  | ||||||
| 		static int luaPlayerIsPzLocked(lua_State* L); | 		static int luaPlayerIsPzLocked(lua_State* L); | ||||||
|  | 		static int luaPlayerIsFakePlayer(lua_State* L); | ||||||
|  |  | ||||||
| 		static int luaPlayerGetClient(lua_State* L); | 		static int luaPlayerGetClient(lua_State* L); | ||||||
| 		static int luaPlayerGetHouse(lua_State* L); | 		static int luaPlayerGetHouse(lua_State* L); | ||||||
|   | |||||||
| @@ -1180,7 +1180,7 @@ void Player::onThink(uint32_t interval) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	lastWalkingTime += interval; | 	lastWalkingTime += interval; | ||||||
| 	if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer()) { | 	if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer() && !isFakePlayer) { | ||||||
| 		idleTime += interval; | 		idleTime += interval; | ||||||
| 		const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES); | 		const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES); | ||||||
| 		if ((!pzLocked && OTSYS_TIME() - lastPong >= 60000) || idleTime > (kickAfterMinutes * 60000) + 60000) { | 		if ((!pzLocked && OTSYS_TIME() - lastPong >= 60000) || idleTime > (kickAfterMinutes * 60000) + 60000) { | ||||||
|   | |||||||
| @@ -154,6 +154,8 @@ class Player final : public Creature, public Cylinder | |||||||
| 			return staminaMinutes; | 			return staminaMinutes; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		bool isFakePlayer = false; | ||||||
|  |  | ||||||
| 		bool addOfflineTrainingTries(skills_t skill, uint64_t tries); | 		bool addOfflineTrainingTries(skills_t skill, uint64_t tries); | ||||||
|  |  | ||||||
| 		void addOfflineTrainingTime(int32_t addTime) { | 		void addOfflineTrainingTime(int32_t addTime) { | ||||||
| @@ -277,7 +279,7 @@ class Player final : public Creature, public Cylinder | |||||||
| 			return (getID() == 0); | 			return (getID() == 0); | ||||||
| 		} | 		} | ||||||
| 		void disconnect() { | 		void disconnect() { | ||||||
| 			if (client) { | 			if (client && !isFakePlayer) { | ||||||
| 				client->disconnect(); | 				client->disconnect(); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -43,7 +43,7 @@ extern Chat* g_chat; | |||||||
| void ProtocolGame::release() | void ProtocolGame::release() | ||||||
| { | { | ||||||
| 	//dispatcher thread | 	//dispatcher thread | ||||||
| 	if (player && player->client == shared_from_this()) { | 	if (player && player->client == shared_from_this() && !player->isFakePlayer) { | ||||||
| 		player->client.reset(); | 		player->client.reset(); | ||||||
| 		player->decrementReferenceCounter(); | 		player->decrementReferenceCounter(); | ||||||
| 		player = nullptr; | 		player = nullptr; | ||||||
| @@ -60,7 +60,6 @@ void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingS | |||||||
| 	if (!foundPlayer || g_config.getBoolean(ConfigManager::ALLOW_CLONES)) { | 	if (!foundPlayer || g_config.getBoolean(ConfigManager::ALLOW_CLONES)) { | ||||||
| 		player = new Player(getThis()); | 		player = new Player(getThis()); | ||||||
| 		player->setName(name); | 		player->setName(name); | ||||||
|  |  | ||||||
| 		player->incrementReferenceCounter(); | 		player->incrementReferenceCounter(); | ||||||
| 		player->setID(); | 		player->setID(); | ||||||
|  |  | ||||||
| @@ -102,6 +101,7 @@ void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingS | |||||||
| 				} else { | 				} else { | ||||||
| 					ss << "Your account has been permanently banned by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason; | 					ss << "Your account has been permanently banned by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				disconnectClient(ss.str()); | 				disconnectClient(ss.str()); | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| @@ -227,7 +227,9 @@ void ProtocolGame::logout(bool displayEffect, bool forced) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if (!player->isFakePlayer) { | ||||||
| 		disconnect(); | 		disconnect(); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	g_game.removeCreature(player); | 	g_game.removeCreature(player); | ||||||
| } | } | ||||||
| @@ -313,7 +315,18 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg) | |||||||
| 	Game::updatePremium(account); | 	Game::updatePremium(account); | ||||||
|  |  | ||||||
| 	g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem))); | 	g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem))); | ||||||
|  | 	if (characterName == "Sabrehaven") { | ||||||
|  | 		std::ostringstream query; | ||||||
|  | 		Database* db = Database::getInstance(); | ||||||
|  | 		query << "SELECT `name`, `account_id` FROM `players` WHERE `fake_player` = 1 group by `account_id` limit 101"; | ||||||
|  | 		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))); | ||||||
|  | 			} while (result->next()); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| void ProtocolGame::onConnect() | void ProtocolGame::onConnect() | ||||||
|   | |||||||
| @@ -122,6 +122,10 @@ void ProtocolStatus::sendStatusString() | |||||||
| 	std::map<uint32_t, uint32_t> listIP; | 	std::map<uint32_t, uint32_t> listIP; | ||||||
|  |  | ||||||
| 	for (const auto& it : g_game.getPlayers()) { | 	for (const auto& it : g_game.getPlayers()) { | ||||||
|  | 		if (it.second->isFakePlayer) { | ||||||
|  | 			real++; | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
| 			if (it.second->getIP() != 0) { | 			if (it.second->getIP() != 0) { | ||||||
| 				auto ip = listIP.find(it.second->getIP()); | 				auto ip = listIP.find(it.second->getIP()); | ||||||
| 				if (ip != listIP.end()) { | 				if (ip != listIP.end()) { | ||||||
| @@ -129,12 +133,14 @@ void ProtocolStatus::sendStatusString() | |||||||
| 					if (listIP[it.second->getIP()] < 5) { | 					if (listIP[it.second->getIP()] < 5) { | ||||||
| 						real++; | 						real++; | ||||||
| 					} | 					} | ||||||
| 			} else { | 				} | ||||||
|  | 				else { | ||||||
| 					listIP[it.second->getIP()] = 1; | 					listIP[it.second->getIP()] = 1; | ||||||
| 					real++; | 					real++; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
| 	players.append_attribute("online") = std::to_string(real).c_str(); | 	players.append_attribute("online") = std::to_string(real).c_str(); | ||||||
|  |  | ||||||
| 	players.append_attribute("max") = std::to_string(g_config.getNumber(ConfigManager::MAX_PLAYERS)).c_str(); | 	players.append_attribute("max") = std::to_string(g_config.getNumber(ConfigManager::MAX_PLAYERS)).c_str(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ErikasKontenis
					ErikasKontenis