Ir para conteúdo

[Encerrado] Warning passwordtype


SkyDarkyes

Posts Recomendados

 

 

-- The Forgotten Server Config
-- Account manager
accountManager = true
namelockManager = true
newPlayerChooseVoc = false
newPlayerSpawnPosX = 95
newPlayerSpawnPosY = 117
newPlayerSpawnPosZ = 7
newPlayerTownId = 1
newPlayerLevel = 1
newPlayerMagicLevel = 0
generateAccountNumber = false
-- Unjustified kills
-- NOTE: *Banishment and *BlackSkull variables are >summed up<
-- (dailyFragsToRedSkull + dailyFragsToBanishment) with their
-- *RedSkull equivalents.
-- Auto banishing works only if useBlackSkull set to negative.
-- advancedFragList is not advised if you use huge frags
-- requirements.
useFragHandler = true
redSkullLength = 30 * 24 * 60 * 60
blackSkullLength = 45 * 24 * 60 * 60
dailyFragsToRedSkull = 3
weeklyFragsToRedSkull = 5
monthlyFragsToRedSkull = 10
dailyFragsToBlackSkull = dailyFragsToRedSkull
weeklyFragsToBlackSkull = weeklyFragsToRedSkull
monthlyFragsToBlackSkull = monthlyFragsToRedSkull
dailyFragsToBanishment = dailyFragsToRedSkull
weeklyFragsToBanishment = weeklyFragsToRedSkull
monthlyFragsToBanishment = monthlyFragsToRedSkull
blackSkulledDeathHealth = 40
blackSkulledDeathMana = 0
useBlackSkull = true
advancedFragList = false
-- Banishments
-- violationNameReportActionType 1 = just a report, 2 = name lock, 3 = player banishment
-- killsBanLength works only if useBlackSkull option is disabled.
notationsToBan = 3
warningsToFinalBan = 4
warningsToDeletion = 5
banLength = 7 * 24 * 60 * 60
killsBanLength = 7 * 24 * 60 * 60
finalBanLength = 30 * 24 * 60 * 60
ipBanishmentLength = 1 * 24 * 60 * 60
broadcastBanishments = true
maxViolationCommentSize = 200
violationNameReportActionType = 2
autoBanishUnknownBytes = false
-- Battle
-- NOTE: showHealingDamageForMonsters inheritates from showHealingDamage.
-- loginProtectionPeriod is the famous Tibia anti-magebomb system.
-- deathLostPercent set to nil enables manual mode.
worldType = "open"
protectionLevel = 1
pvpTileIgnoreLevelAndVocationProtection = true
pzLocked = 60 * 1000
huntingDuration = 60 * 1000
criticalHitChance = 7
criticalHitMultiplier = 1
displayCriticalHitNotify = false
removeWeaponAmmunition = true
removeWeaponCharges = true
removeRuneCharges = true
whiteSkullTime = 15 * 60 * 1000
noDamageToSameLookfeet = false
showHealingDamage = false
showHealingDamageForMonsters = false
fieldOwnershipDuration = 5 * 1000
stopAttackingAtExit = false
loginProtectionPeriod = 10 * 1000
deathLostPercent = 10
stairhopDelay = 2 * 1000
pushCreatureDelay = 2 * 1000
deathContainerId = 1987
gainExperienceColor = 215
addManaSpentInPvPZone = true
squareColor = 0
allowFightback = true
optionalWarAttackableAlly = false
fistBaseAttack = 7
-- Connection config
worldId = 0
ip = "127.0.0.1"
bindOnlyGlobalAddress = false
loginPort = 7171
gamePort = 7172
loginTries = 10
retryTimeout = 5 * 1000
loginTimeout = 60 * 1000
maxPlayers = 1000
motd = "Welcome to the Forgotten Server!"
displayOnOrOffAtCharlist = false
onePlayerOnlinePerAccount = true
allowClones = 0
serverName = "Forgotten"
loginMessage = "Welcome to the Forgotten Server!"
statusTimeout = 5 * 60 * 1000
replaceKickOnLogin = true
forceSlowConnectionsToDisconnect = false
loginOnlyWithLoginServer = false
premiumPlayerSkipWaitList = false
-- RSA
-- NOTE: These should not be changed unless you know what your doing!
-- Prime1 - known as p; Prime2 - known as q; Public - known as e;
-- Modulus - known as n; Private - known as d.
rsaPrime1 = "14299623962416399520070177382898895550795403345466153217470516082934737582776038882967213386204600674145392845853859217990626450972452084065728686565928113"
rsaPrime2 = "7630979195970404721891201847792002125535401292779123937207447574596692788513647179235335529307251350570728407373705564708871762033017096809910315212884101"
rsaPublic = "65537"
rsaModulus = "109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110603907230888610072655818825358503429057592827629436413108566029093628212635953836686562675849720620786279431090218017681061521755056710823876476444260558147179707119674283982419152118103759076030616683978566631413"
rsaPrivate = "46730330223584118622160180015036832148732986808519344675210555262940258739805766860224610646919605860206328024326703361630109888417839241959507572247284807035235569619173792292786907845791904955103601652822519121908367187885509270025388641700821735345222087940578381210879116823013776808975766851829020659073"
-- Database
-- NOTE: sqlFile is used only by sqlite database, and sqlKeepAlive by mysql database.
-- To disable sqlKeepAlive such as mysqlReadTimeout use 0 value.
-- encryptionType can be plain, md5, sha1, sha256, sha512 or vahash.
sqlType = "sqlite"
sqlHost = "localhost"
sqlPort = 3306
sqlUser = "root"
sqlPass = ""
sqlDatabase = "theforgottenserver"
sqlFile = "theforgottenserver.s3db"
sqlKeepAlive = 0
mysqlReadTimeout = 10
mysqlWriteTimeout = 10
encryptionType = "plain"
-- Deathlist
deathListEnabled = true
deathListRequiredTime = 1 * 60 * 1000
deathAssistCount = 19
maxDeathRecords = 5
-- Guilds
ingameGuildManagement = true
levelToFormGuild = 8
premiumDaysToFormGuild = 0
guildNameMinLength = 4
guildNameMaxLength = 20
-- Highscores
highscoreDisplayPlayers = 15
updateHighscoresAfterMinutes = 60
-- Houses
buyableAndSellableHouses = true
houseNeedPremium = true
bedsRequirePremium = true
levelToBuyHouse = 1
housesPerAccount = 0
houseRentAsPrice = false
housePriceAsRent = false
housePriceEachSquare = 1000
houseRentPeriod = "never"
houseCleanOld = 0
guildHalls = false
-- Item usage
timeBetweenActions = 200
timeBetweenExActions = 1000
hotkeyAimbotEnabled = true
-- Map
-- NOTE: storeTrash costs more memory, but will perform alot faster cleaning.
mapName = "nowo.otbm"
mapAuthor = "Komic"
randomizeTiles = true
storeTrash = true
cleanProtectedZones = true
mailboxDisabledTowns = ""
-- Process
-- NOTE: defaultPriority works only on Windows and niceLevel on *nix
-- niceLevel works only on *nix systems
-- coresUsed are seperated by comma cores ids used by server process,
-- default is -1, so it stays untouched (automaticaly assigned by OS).
defaultPriority = "high"
niceLevel = 5
coresUsed = "-1"
-- Startup
startupDatabaseOptimization = true
updatePremiumStateAtStartup = true
confirmOutdatedVersion = false
skipItemsVersionCheck = true
-- Spells
formulaLevel = 5.0
formulaMagic = 1.0
bufferMutedOnSpellFailure = false
spellNameInsteadOfWords = false
emoteSpells = false
unifiedSpells = true
-- Outfits
allowChangeOutfit = true
allowChangeColors = true
allowChangeAddons = true
disableOutfitsForPrivilegedPlayers = false
addonsOnlyPremium = true
-- Miscellaneous
-- NOTE: promptExceptionTracerErrorBox works only with precompiled support feature,
-- called "exception tracer" (__EXCEPTION_TRACER__ flag).
dataDirectory = "data/"
logsDirectory = "data/logs/"
bankSystem = true
displaySkillLevelOnAdvance = false
promptExceptionTracerErrorBox = true
maximumDoorLevel = 500
maxMessageBuffer = 4
tradeLimit = 100
-- VIP list
separateVipListPerCharacter = false
vipListDefaultLimit = 20
vipListDefaultPremiumLimit = 100
-- Saving-related
-- useHouseDataStorage usage may be found at README.
saveGlobalStorage = true
useHouseDataStorage = true
storePlayerDirection = false
-- Loot
-- monsterLootMessage 0 to disable, 1 - only party, 2 - only player, 3 - party or player (like Tibia's)
checkCorpseOwner = true
monsterLootMessage = 3
monsterLootMessageType = 25
-- Ghost mode
ghostModeInvisibleEffect = false
ghostModeSpellEffects = true
-- Limits
idleWarningTime = 14 * 60 * 1000
idleKickTime = 15 * 60 * 1000
reportsExpirationAfterReads = 1
playerQueryDeepness = 2
tileLimit = 0
protectionTileLimit = 0
houseTileLimit = 0
-- Premium-related
freePremium = false
premiumForPromotion = true
-- Blessings
-- NOTE: blessingReduction* regards items/containers loss.
-- eachBlessReduction is how much each bless reduces the experience/magic/skills loss.
blessings = true
blessingOnlyPremium = true
blessingReductionBase = 30
blessingReductionDecrement = 5
eachBlessReduction = 8
-- Rates
-- NOTE: experienceStages configuration is located in data/XML/stages.xml.
-- rateExperienceFromPlayers 0 to disable.
experienceStages = false
rateExperience = 5.0
rateExperienceFromPlayers = 0
rateSkill = 3.0
rateMagic = 3.0
rateLoot = 2.0
rateSpawn = 1
-- Monster rates
rateMonsterHealth = 1.0
rateMonsterMana = 1.0
rateMonsterAttack = 1.0
rateMonsterDefense = 1.0
-- Experience from players
-- NOTE: min~Threshold* set to 0 will disable the minimum threshold:
-- player will gain experience from every lower leveled player.
-- max~Threshold* set to 0 will disable the maximum threshold:
-- player will gain experience from every higher leveled player.
minLevelThresholdForKilledPlayer = 0.9
maxLevelThresholdForKilledPlayer = 1.1
-- Stamina
-- NOTE: Stamina is stored in miliseconds, so seconds are multiplied by 1000.
-- rateStaminaHits multiplies every hit done a creature, which are later
-- multiplied by player attack speed.
-- rateStaminaGain is multiplying every second of logged out time, eg:
-- 60 * 1000 / 3 = 20 seconds, what gives 1 stamina minute for 3 being logged off.
-- rateStaminaThresholdGain is dividing in case the normal gain (that is
-- multiplied by rateStaminaGain, btw.) passed above threshold, eg:
-- 60 * 1000 / 3 = 20 / 4 = 5 seconds (3 * 4 = 12 minutes for 1 stamina minute).
-- staminaRatingLimit* is in minutes.
rateStaminaLoss = 1
rateStaminaGain = 3
rateStaminaThresholdGain = 12
staminaRatingLimitTop = 40 * 60
staminaRatingLimitBottom = 14 * 60
staminaLootLimit = 14 * 60
rateStaminaAboveNormal = 1.5
rateStaminaUnderNormal = 0.5
staminaThresholdOnlyPremium = true
-- Party
-- NOTE: experienceShareLevelDifference is float number.
-- experienceShareLevelDifference is highestLevel * value
experienceShareRadiusX = 30
experienceShareRadiusY = 30
experienceShareRadiusZ = 1
experienceShareLevelDifference = 2 / 3
extraPartyExperienceLimit = 20
extraPartyExperiencePercent = 5
experienceShareActivity = 2 * 60 * 1000
-- Global save
-- NOTE: globalSaveHour means like 03:00, not that it will save every 3 hours,
-- if you want such a system please check out data/globalevents/globalevents.xml.
globalSaveEnabled = false
globalSaveHour = 8
globalSaveMinute = 0
shutdownAtGlobalSave = true
cleanMapAtGlobalSave = false
-- Spawns
deSpawnRange = 2
deSpawnRadius = 50
-- Summons
maxPlayerSummons = 2
teleportAllSummons = false
teleportPlayerSummons = false
-- Status
statusPort = 7171
ownerName = ""
ownerEmail = "@otland.net"
location = "Europe"
displayGamemastersWithOnlineCommand = false
-- Logs
-- NOTE: This kind of logging does not work in GUI version.
-- For such, please compile the software with __GUI_LOGS__ flag.
displayPlayersLogging = true
prefixChannelLogs = ""
runFile = ""
outputLog = ""
truncateLogOnStartup = false
-- Manager
-- NOTE: managerPassword left blank disables manager.
managerPort = 7171
managerLogs = true
managerPassword = ""
managerLocalhostOnly = true
managerConnectionsLimit = 1
-- Admin
-- NOTE: adminPassword left blank disables manager.
-- Set to anything if you set adminRequireLogin to false.
-- adminEncryption available options: rsa1024xtea;
-- remember to set correct data!
adminPort = 7171
adminLogs = true
adminPassword = ""
adminLocalhostOnly = true
adminConnectionsLimit = 1
adminRequireLogin = true
adminEncryption = ""
adminEncryptionData = ""

Link para o comentário
Compartilhar em outros sites

Amigo, provavelmente você esta usando um website de versão diferente da suportável pelo seu TFS ...

A criptografia feita pelo website era 'puxada' do config.lua pela expressão: encryptionType =

Aqui está (no gesior, exemplo) a parte que o website 'puxa' do config.lua (versão anterior a TFS 1.0)
• Website::setPasswordsEncryption(Website::getWebsiteConfig()->getValue('encryptionType'));

O problema é que agora no TFS 1.0 a expressão que 'puxa' é outro: passwordType =

Aqui o código que 'puxa' do config.lua
• Website::setPasswordsEncryption(Website::getWebsiteConfig()->getValue('passwordType'));

Conclusão: Ou você usa TFS 1.0 e esta tentando usar um site de versão que não suporta o 1.0, ou ao contrário.

Link para o comentário
Compartilhar em outros sites

sha1 é para sites cara, ele encripta a senha, nao quero isso

Apenas para corrigir, sha1 é sim uma encriptação, e não, não é somente para sites, o próprio tfs entende.

 

Isso que aparece não é um erro, é apenas um aviso que "plain" não é seguro usar.

 

Deixar senhas salvas sem encriptá-las é perigoso.

Link para o comentário
Compartilhar em outros sites

Sim amigo, queria saber se é possivel retirar este aviso.

Se quiser remover, abra otserv.cpp em suas sources e procure por:

g_config.setNumber(ConfigManager::ENCRYPTION, ENCRYPTION_PLAIN);
E deixe apenas assim:

	else
	{
		g_config.setNumber(ConfigManager::ENCRYPTION, ENCRYPTION_PLAIN);
		std::clog << "> Using plaintext encryption" << std::endl;
	}
Link para o comentário
Compartilhar em outros sites

Posta o seu otserv.cpp.

 

////////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
////////////////////////////////////////////////////////////////////////
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////
#include "otpch.h"
#include "otsystem.h"
 
#include <iostream>
#include <fstream>
#include <iomanip>
 
#ifndef WINDOWS
#include <unistd.h>
#include <termios.h>
#else
#include <conio.h>
#endif
#include <boost/config.hpp>
 
#include <openssl/rsa.h>
#include <openssl/bn.h>
#include <openssl/err.h>
 
#include "server.h"
#ifdef __LOGIN_SERVER__
#include "gameservers.h"
#endif
#include "networkmessage.h"
 
#include "game.h"
#include "chat.h"
#include "tools.h"
 
#include "protocollogin.h"
#include "protocolgame.h"
#include "protocolold.h"
#include "protocolhttp.h"
 
#include "status.h"
#include "manager.h"
#ifdef __OTADMIN__
#include "admin.h"
#endif
 
#include "configmanager.h"
#include "scriptmanager.h"
#include "databasemanager.h"
 
#include "iologindata.h"
#include "ioban.h"
 
#include "outfit.h"
#include "vocation.h"
#include "group.h"
 
#include "monsters.h"
#ifdef __OTSERV_ALLOCATOR__
#include "allocator.h"
#endif
#ifdef __EXCEPTION_TRACER__
#include "exception.h"
#endif
#ifndef __OTADMIN__
#include "textlogger.h"
#endif
 
#ifdef __NO_BOOST_EXCEPTIONS__
#include <exception>
 
inline void boost::throw_exception(std::exception const & e)
{
std::clog << "Boost exception: " << e.what() << std::endl;
}
#endif
 
RSA* g_RSA;
ConfigManager g_config;
Game g_game;
Chat g_chat;
Monsters g_monsters;
Npcs g_npcs;
 
boost::mutex g_loaderLock;
boost::condition_variable g_loaderSignal;
boost::unique_lock<boost::mutex> g_loaderUniqueLock(g_loaderLock);
std::list<std::pair<uint32_t, uint32_t> > serverIps;
 
bool argumentsHandler(StringVec args)
{
StringVec tmp;
for(StringVec::iterator it = args.begin(); it != args.end(); ++it)
{
if((*it) == "--help")
{
std::clog << "Usage:\n"
"\n"
"\t--config=$1\t\tAlternate configuration file path.\n"
"\t--data-directory=$1\tAlternate data directory path.\n"
"\t--ip=$1\t\t\tIP address of the server.\n"
"\t\t\t\tShould be equal to the global IP.\n"
"\t--login-port=$1\tPort for login server to listen on.\n"
"\t--game-port=$1\tPort for game server to listen on.\n"
"\t--admin-port=$1\tPort for admin server to listen on.\n"
"\t--manager-port=$1\tPort for manager server to listen on.\n"
"\t--status-port=$1\tPort for status server to listen on.\n";
#ifndef WINDOWS
std::clog << "\t--runfile=$1\t\tSpecifies run file. Will contain the pid\n"
"\t\t\t\tof the server process as long as run status.\n";
#endif
std::clog << "\t--log=$1\t\tWhole standard output will be logged to\n"
"\t\t\t\tthis file.\n"
"\t--closed\t\t\tStarts the server as closed.\n";
return false;
}
 
if((*it) == "--version" || (*it) == "-V")
{
std::clog << SOFTWARE_NAME << ", version " << SOFTWARE_VERSION << "\n"
"A server developed by Skydarkyes.\n";
return false;
}
 
tmp = explodeString((*it), "=");
if(tmp[0] == "--config")
g_config.setString(ConfigManager::CONFIG_FILE, tmp[1]);
else if(tmp[0] == "--data-directory")
g_config.setString(ConfigManager::DATA_DIRECTORY, tmp[1]);
else if(tmp[0] == "--ip")
g_config.setString(ConfigManager::IP, tmp[1]);
else if(tmp[0] == "--login-port")
g_config.setNumber(ConfigManager::LOGIN_PORT, atoi(tmp[1].c_str()));
else if(tmp[0] == "--game-port")
g_config.setNumber(ConfigManager::GAME_PORT, atoi(tmp[1].c_str()));
else if(tmp[0] == "--admin-port")
g_config.setNumber(ConfigManager::ADMIN_PORT, atoi(tmp[1].c_str()));
else if(tmp[0] == "--manager-port")
g_config.setNumber(ConfigManager::MANAGER_PORT, atoi(tmp[1].c_str()));
else if(tmp[0] == "--status-port")
g_config.setNumber(ConfigManager::STATUS_PORT, atoi(tmp[1].c_str()));
#ifndef WINDOWS
else if(tmp[0] == "--runfile")
g_config.setString(ConfigManager::RUNFILE, tmp[1]);
#endif
else if(tmp[0] == "--log")
g_config.setString(ConfigManager::OUTPUT_LOG, tmp[1]);
else if(tmp[0] == "--closed")
g_config.setBool(ConfigManager::START_CLOSED, true);
else if(tmp[0] == "--no-script")
g_config.setBool(ConfigManager::SCRIPT_SYSTEM, false);
}
 
return true;
}
 
#ifndef WINDOWS
int32_t getch()
{
struct termios oldt;
tcgetattr(STDIN_FILENO, &oldt);
 
struct termios newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
 
int32_t ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
 
void signalHandler(int32_t sig)
{
switch(sig)
{
case SIGHUP:
Dispatcher::getInstance().addTask(createTask(
boost::bind(&Game::saveGameState, &g_game, false)));
break;
 
case SIGTRAP:
g_game.cleanMap();
break;
 
case SIGCHLD:
g_game.proceduralRefresh();
break;
 
case SIGUSR1:
Dispatcher::getInstance().addTask(createTask(
boost::bind(&Game::setGameState, &g_game, GAMESTATE_CLOSED)));
break;
 
case SIGUSR2:
g_game.setGameState(GAMESTATE_NORMAL);
break;
 
case SIGCONT:
Dispatcher::getInstance().addTask(createTask(
boost::bind(&Game::reloadInfo, &g_game, RELOAD_ALL, 0)));
break;
 
case SIGQUIT:
Dispatcher::getInstance().addTask(createTask(
boost::bind(&Game::setGameState, &g_game, GAMESTATE_SHUTDOWN)));
break;
 
case SIGTERM:
Dispatcher::getInstance().addTask(createTask(
boost::bind(&Game::shutdown, &g_game)));
break;
 
default:
break;
}
}
 
void runfileHandler(void)
{
std::ofstream runfile(g_config.getString(ConfigManager::RUNFILE).c_str(), std::ios::trunc | std::ios::out);
runfile.close();
}
#else
int32_t getch()
{
return (int32_t)getchar();
}
#endif
 
void allocationHandler()
{
puts("Allocation failed, server out of memory!\nDecrease size of your map or compile in a 64-bit mode.");
char buffer[1024];
delete fgets(buffer, 1024, stdin);
exit(-1);
}
 
void startupErrorMessage(std::string error = "")
{
if(error.length() > 0)
std::clog << std::endl << "> ERROR: " << error << std::endl;
 
getch();
exit(-1);
}
 
void otserv(StringVec args, ServiceManager* services);
int main(int argc, char* argv[])
{
StringVec args = StringVec(argv, argv + argc);
if(argc > 1 && !argumentsHandler(args))
return 0;
 
std::set_new_handler(allocationHandler);
ServiceManager servicer;
g_config.startup();
 
#ifdef __OTSERV_ALLOCATOR_STATS__
boost::thread(boost::bind(&allocatorStatsThread, (void*)NULL));
// TODO: shutdown this thread?
#endif
#ifdef __EXCEPTION_TRACER__
ExceptionHandler mainExceptionHandler;
mainExceptionHandler.InstallHandler();
#endif
#ifndef WINDOWS
 
// ignore sigpipe...
struct sigaction sigh;
sigh.sa_handler = SIG_IGN;
sigh.sa_flags = 0;
 
sigemptyset(&sigh.sa_mask);
sigaction(SIGPIPE, &sigh, NULL);
 
// register signals
signal(SIGHUP, signalHandler); //save
signal(SIGTRAP, signalHandler); //clean
signal(SIGCHLD, signalHandler); //refresh
signal(SIGUSR1, signalHandler); //close server
signal(SIGUSR2, signalHandler); //open server
signal(SIGCONT, signalHandler); //reload all
signal(SIGQUIT, signalHandler); //save & shutdown
signal(SIGTERM, signalHandler); //shutdown
#endif
 
OutputHandler::getInstance();
Dispatcher::getInstance().addTask(createTask(boost::bind(otserv, args, &servicer)));
 
g_loaderSignal.wait(g_loaderUniqueLock);
if(servicer.isRunning())
{
std::clog << ">> " << g_config.getString(ConfigManager::SERVER_NAME) << " server Online!" << std::endl << std::endl;
servicer.run();
}
else
std::clog << ">> " << g_config.getString(ConfigManager::SERVER_NAME) << " server Offline! No services available..." << std::endl << std::endl;
 
#ifdef __EXCEPTION_TRACER__
mainExceptionHandler.RemoveHandler();
#endif
return 0;
}
 
void otserv(StringVec, ServiceManager* services)
{
srand((uint32_t)OTSYS_TIME());
#if defined(WINDOWS)
SetConsoleTitle(SOFTWARE_NAME);
 
#endif
g_game.setGameState(GAMESTATE_STARTUP);
#if !defined(WINDOWS) && !defined(__ROOT_PERMISSION__)
if(!getuid() || !geteuid())
{
std::clog << "> WARNING: " << SOFTWARE_NAME << " has been executed as super user! It is "
<< "recommended to run as a normal user." << std::endl << "Continue? (y/N)" << std::endl;
char buffer = getch();
if(buffer != 121 && buffer != 89)
startupErrorMessage("Aborted.");
}
#endif
 
std::clog << SOFTWARE_NAME << ", version " << SOFTWARE_VERSION << "\n"
"A server developed by Skydarkyes.\n";
 
std::stringstream ss;
#ifdef __DEBUG__
ss << " GLOBAL";
#endif
#ifdef __DEBUG_MOVESYS__
ss << " MOVESYS";
#endif
#ifdef __DEBUG_CHAT__
ss << " CHAT";
#endif
#ifdef __DEBUG_EXCEPTION_REPORT__
ss << " EXCEPTION-REPORT";
#endif
#ifdef __DEBUG_HOUSES__
ss << " HOUSES";
#endif
#ifdef __DEBUG_LUASCRIPTS__
ss << " LUA-SCRIPTS";
#endif
#ifdef __DEBUG_MAILBOX__
ss << " MAILBOX";
#endif
#ifdef __DEBUG_NET__
ss << " NET";
#endif
#ifdef __DEBUG_NET_DETAIL__
ss << " NET-DETAIL";
#endif
#ifdef __DEBUG_RAID__
ss << " RAIDS";
#endif
#ifdef __DEBUG_SCHEDULER__
ss << " SCHEDULER";
#endif
#ifdef __DEBUG_SPAWN__
ss << " SPAWNS";
#endif
#ifdef __SQL_QUERY_DEBUG__
ss << " SQL-QUERIES";
#endif
 
std::string debug = ss.str();
if(!debug.empty())
std::clog << ">> Debugging:" << debug << "." << std::endl;
 
std::clog << ">> Loading config (" << g_config.getString(ConfigManager::CONFIG_FILE) << ")" << std::endl;
if(!g_config.load())
startupErrorMessage("Unable to load " + g_config.getString(ConfigManager::CONFIG_FILE) + "!");
 
// silently append trailing slash
std::string path = g_config.getString(ConfigManager::DATA_DIRECTORY);
g_config.setString(ConfigManager::DATA_DIRECTORY, path.erase(path.find_last_not_of("/") + 1) + "/");
 
path = g_config.getString(ConfigManager::LOGS_DIRECTORY);
g_config.setString(ConfigManager::LOGS_DIRECTORY, path.erase(path.find_last_not_of("/") + 1) + "/");
 
std::clog << "> Opening logs" << std::endl;
Logger::getInstance()->open();
 
IntegerVec cores = vectorAtoi(explodeString(g_config.getString(ConfigManager::CORES_USED), ","));
if(cores[0] != -1)
{
#ifdef WINDOWS
int32_t mask = 0;
for(IntegerVec::iterator it = cores.begin(); it != cores.end(); ++it)
mask += 1 << (*it);
 
SetProcessAffinityMask(GetCurrentProcess(), mask);
}
 
std::stringstream mutexName;
mutexName << "forgottenserver_" << g_config.getNumber(ConfigManager::WORLD_ID);
 
CreateMutex(NULL, FALSE, mutexName.str().c_str());
if(GetLastError() == ERROR_ALREADY_EXISTS)
startupErrorMessage("Another instance of The Forgotten Server is already running with the same worldId.\nIf you want to run multiple servers, please change the worldId in configuration file.");
 
std::string defaultPriority = asLowerCaseString(g_config.getString(ConfigManager::DEFAULT_PRIORITY));
if(defaultPriority == "realtime")
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
else if(defaultPriority == "high")
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
else if(defaultPriority == "higher")
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
 
#else
#ifndef MACOS
cpu_set_t mask;
CPU_ZERO(&mask);
for(IntegerVec::iterator it = cores.begin(); it != cores.end(); ++it)
CPU_SET((*it), &mask);
 
sched_setaffinity(getpid(), (int32_t)sizeof(mask), &mask);
}
#endif
 
std::string runPath = g_config.getString(ConfigManager::RUNFILE);
if(runPath != "" && runPath.length() > 2)
{
std::ofstream runFile(runPath.c_str(), std::ios::trunc | std::ios::out);
runFile << getpid();
runFile.close();
atexit(runfileHandler);
}
 
if(!nice(g_config.getNumber(ConfigManager::NICE_LEVEL))) {}
#endif
std::string encryptionType = asLowerCaseString(g_config.getString(ConfigManager::ENCRYPTION_TYPE));
if(encryptionType == "md5")
{
g_config.setNumber(ConfigManager::ENCRYPTION, ENCRYPTION_MD5);
std::clog << "> Using MD5 encryption" << std::endl;
}
else if(encryptionType == "sha1")
{
g_config.setNumber(ConfigManager::ENCRYPTION, ENCRYPTION_SHA1);
std::clog << "> Using SHA1 encryption" << std::endl;
}
else if(encryptionType == "sha256")
{
g_config.setNumber(ConfigManager::ENCRYPTION, ENCRYPTION_SHA256);
std::clog << "> Using SHA256 encryption" << std::endl;
}
else if(encryptionType == "sha512")
{
g_config.setNumber(ConfigManager::ENCRYPTION, ENCRYPTION_SHA512);
std::clog << "> Using SHA512 encryption" << std::endl;
}
else
{
g_config.setNumber(ConfigManager::ENCRYPTION, ENCRYPTION_PLAIN);
std::clog << "> Using plaintext encryption" << std::endl;
}
 
std::clog << ">> Loading RSA key" << std::endl;
g_RSA = RSA_new();
 
BN_dec2bn(&g_RSA->p, g_config.getString(ConfigManager::RSA_PRIME1).c_str());
BN_dec2bn(&g_RSA->q, g_config.getString(ConfigManager::RSA_PRIME2).c_str());
BN_dec2bn(&g_RSA->d, g_config.getString(ConfigManager::RSA_PRIVATE).c_str());
BN_dec2bn(&g_RSA->n, g_config.getString(ConfigManager::RSA_MODULUS).c_str());
BN_dec2bn(&g_RSA->e, g_config.getString(ConfigManager::RSA_PUBLIC).c_str());
// TODO: dmp1, dmq1, iqmp?
 
// This check will verify keys set in config.lua
if(!RSA_check_key(g_RSA))
{
std::stringstream s;
s << "OpenSSL failed - ";
 
ERR_load_crypto_strings();
s << ERR_error_string(ERR_get_error(), NULL);
startupErrorMessage(s.str());
}
 
std::clog << ">> Starting SQL connection" << std::endl;
Database* db = Database::getInstance();
if(db && db->isConnected())
{
std::clog << ">> Running Database Manager" << std::endl;
if(DatabaseManager::getInstance()->isDatabaseSetup())
{
uint32_t version = 0;
do
{
version = DatabaseManager::getInstance()->updateDatabase();
if(!version)
break;
 
std::clog << "> Database has been updated to version: " << version << "." << std::endl;
}
while(version < VERSION_DATABASE);
}
else
startupErrorMessage("The database you have specified in config.lua is empty, please import schemas/<engine>.sql to the database.");
 
DatabaseManager::getInstance()->checkTriggers();
DatabaseManager::getInstance()->checkEncryption();
if(g_config.getBool(ConfigManager::OPTIMIZE_DATABASE) && !DatabaseManager::getInstance()->optimizeTables())
std::clog << "> No tables were optimized." << std::endl;
}
else
startupErrorMessage("Couldn't estabilish connection to SQL database!");
 
std::clog << ">> Loading items (OTB)" << std::endl;
if(Item::items.loadFromOtb(getFilePath(FILE_TYPE_OTHER, "items/items.otb")))
startupErrorMessage("Unable to load items (OTB)!");
 
std::clog << ">> Loading items (XML)" << std::endl;
if(!Item::items.loadFromXml())
{
std::clog << "Unable to load items (XML)! Continue? (y/N)" << std::endl;
char buffer = getch();
if(buffer != 121 && buffer != 89)
startupErrorMessage("Unable to load items (XML)!");
}
 
std::clog << ">> Loading groups" << std::endl;
if(!Groups::getInstance()->loadFromXml())
startupErrorMessage("Unable to load groups!");
 
std::clog << ">> Loading vocations" << std::endl;
if(!Vocations::getInstance()->loadFromXml())
startupErrorMessage("Unable to load vocations!");
 
std::clog << ">> Loading outfits" << std::endl;
if(!Outfits::getInstance()->loadFromXml())
startupErrorMessage("Unable to load outfits!");
 
std::clog << ">> Loading chat channels" << std::endl;
if(!g_chat.loadFromXml())
startupErrorMessage("Unable to load chat channels!");
 
if(g_config.getBool(ConfigManager::SCRIPT_SYSTEM))
{
std::clog << ">> Loading script systems" << std::endl;
if(!ScriptManager::getInstance()->loadSystem())
startupErrorMessage();
}
else
ScriptManager::getInstance();
 
std::clog << ">> Loading mods..." << std::endl;
if(!ScriptManager::getInstance()->loadMods())
startupErrorMessage();
 
#ifdef __LOGIN_SERVER__
std::clog << ">> Loading game servers" << std::endl;
if(!GameServers::getInstance()->loadFromXml(true))
startupErrorMessage("Unable to load game servers!");
 
#endif
std::clog << ">> Loading experience stages" << std::endl;
if(!g_game.loadExperienceStages())
startupErrorMessage("Unable to load experience stages!");
 
std::clog << ">> Loading monsters" << std::endl;
if(!g_monsters.loadFromXml())
{
std::clog << "Unable to load monsters! Continue? (y/N)" << std::endl;
char buffer = getch();
if(buffer != 121 && buffer != 89)
startupErrorMessage("Unable to load monsters!");
}
 
std::clog << ">> Loading map and spawns..." << std::endl;
if(!g_game.loadMap(g_config.getString(ConfigManager::MAP_NAME)))
startupErrorMessage();
 
std::clog << ">> Checking world type... ";
std::string worldType = asLowerCaseString(g_config.getString(ConfigManager::WORLD_TYPE));
if(worldType == "open" || worldType == "2" || worldType == "openpvp")
{
g_game.setWorldType(WORLDTYPE_OPEN);
std::clog << "Open PvP" << std::endl;
}
else if(worldType == "optional" || worldType == "1" || worldType == "optionalpvp")
{
g_game.setWorldType(WORLDTYPE_OPTIONAL);
std::clog << "Optional PvP" << std::endl;
}
else if(worldType == "hardcore" || worldType == "3" || worldType == "hardcorepvp")
{
g_game.setWorldType(WORLDTYPE_HARDCORE);
std::clog << "Hardcore PvP" << std::endl;
}
else
{
std::clog << std::endl;
startupErrorMessage("Unknown world type: " + g_config.getString(ConfigManager::WORLD_TYPE));
}
 
std::clog << ">> Initializing game state and binding services..." << std::endl;
g_game.setGameState(GAMESTATE_INIT);
IPAddressList ipList;
 
std::string ip = g_config.getString(ConfigManager::IP);
if(asLowerCaseString(ip) == "auto")
{
// TODO: automatic shit
}
 
IPAddress m_ip;
if(ip.size())
{
std::clog << "> Global IP address: ";
uint32_t resolvedIp = inet_addr(ip.c_str());
if(resolvedIp == INADDR_NONE)
{
struct hostent* host = gethostbyname(ip.c_str());
if(!host)
{
std::clog << "..." << std::endl;
startupErrorMessage("Cannot resolve " + ip + "!");
}
 
resolvedIp = *(uint32_t*)host->h_addr;
}
 
serverIps.push_front(std::make_pair(resolvedIp, 0));
m_ip = boost::asio::ip::address_v4(swap_uint32(resolvedIp));
 
ipList.push_back(m_ip);
std::clog << m_ip.to_string() << std::endl;
}
 
ipList.push_back(boost::asio::ip::address_v4(INADDR_LOOPBACK));
if(!g_config.getBool(ConfigManager::BIND_ONLY_GLOBAL_ADDRESS))
{
char hostName[128];
if(!gethostname(hostName, 128))
{
if(hostent* host = gethostbyname(hostName))
{
std::stringstream s;
for(uint8_t** addr = (uint8_t**)host->h_addr_list; addr[0] != NULL; addr++)
{
uint32_t resolved = swap_uint32(*(uint32_t*)(*addr));
if(m_ip.to_v4().to_ulong() == resolved)
continue;
 
ipList.push_back(boost::asio::ip::address_v4(resolved));
serverIps.push_front(std::make_pair(*(uint32_t*)(*addr), 0x0000FFFF));
 
s << (int32_t)(addr[0][0]) << "." << (int32_t)(addr[0][1]) << "."
<< (int32_t)(addr[0][2]) << "." << (int32_t)(addr[0][3]) << "\t";
}
 
if(s.str().size())
std::clog << "> Local IP address(es): " << s.str() << std::endl;
}
}
 
serverIps.push_front(std::make_pair(LOCALHOST, 0xFFFFFFFF));
if(m_ip.to_v4().to_ulong() != LOCALHOST)
ipList.push_back(boost::asio::ip::address_v4(LOCALHOST));
}
else if(ipList.size() < 2)
startupErrorMessage("Unable to bind any IP address! You may want to disable \"bindOnlyGlobalAddress\" setting in config.lua");
 
services->add<ProtocolStatus>(g_config.getNumber(ConfigManager::STATUS_PORT), ipList);
services->add<ProtocolManager>(g_config.getNumber(ConfigManager::MANAGER_PORT), ipList);
#ifdef __OTADMIN__
services->add<ProtocolAdmin>(g_config.getNumber(ConfigManager::ADMIN_PORT), ipList);
#endif
 
//services->add<ProtocolHTTP>(8080, ipList);
if(
#ifdef __LOGIN_SERVER__
true
#else
!g_config.getBool(ConfigManager::LOGIN_ONLY_LOGINSERVER)
#endif
)
{
services->add<ProtocolLogin>(g_config.getNumber(ConfigManager::LOGIN_PORT), ipList);
services->add<ProtocolOldLogin>(g_config.getNumber(ConfigManager::LOGIN_PORT), ipList);
}
 
services->add<ProtocolGame>(g_config.getNumber(ConfigManager::GAME_PORT), ipList);
services->add<ProtocolOldGame>(g_config.getNumber(ConfigManager::LOGIN_PORT), ipList);
std::clog << "> Bound ports: ";
 
std::list<uint16_t> ports = services->getPorts();
for(std::list<uint16_t>::iterator it = ports.begin(); it != ports.end(); ++it)
std::clog << (*it) << "\t";
 
std::clog << std::endl << ">> Everything smells good, server is starting up..." << std::endl;
g_game.start(services);
g_game.setGameState(g_config.getBool(ConfigManager::START_CLOSED) ? GAMESTATE_CLOSED : GAMESTATE_NORMAL);
g_loaderSignal.notify_all();
}

@up

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...