Ir para conteúdo
  • Cadastre-se

tfs 0.3 Dbo Rox V2 8.60 [Open Source][99% SEM BUGS]


Posts Recomendados

  • 2 weeks later...
  • Respostas 473
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Dragon Ball Rox Servidor 100% estável com mais de 200 horas online. 38 Vocações sendo 9 delas vip que são: Shenron,Vegetto,Zaiko,Kagome,Tapion,Kame Chilled,C8 e King Vegetta. Spells de fast attack (Usa uma vez sai 10 hits). Eventos automaticos como: Castle,Battlefield,Run event. Reborn level maximo 600. Vamos aos bugs que eu encontrei: * Zombie event quando o zombie pega algum player todos do evento e mandando pra fora e evento encerra. * Er

A base que o @WhiteBubble é a minha, e a do @Alexy Brocanello é outra diferente. Só comparar os arquivos "definitions.h", entre outras dezenas de coisas.   Agora SE o @WhiteBubble copiou alguma PARTE do code da source dele, já é outra história...  

100% ele n esta, tem esses pequenos bugs que nem são dificieis de arrumar, acredito que o unico "bug" que acho ser dificil e o das spells que não interfere em quase nada no server.

Posted Images

  Em 26/11/2016 em 21:36, WhiteBubble disse:

100% ele n esta, tem esses pequenos bugs que nem são dificieis de arrumar, acredito que o unico "bug" que acho ser dificil e o das spells que não interfere em quase nada no server.

Mostrar mais  

que bug das spells? poderia me falar

Link para o post
Compartilhar em outros sites

Mano Eu estou com um problema com essas sources que voce disponibilizou, Quando eu vou compilar, na etapa do tools.cpp da o seguinte erro:

 

 

23 C:\Users\Administrador\Desktop\source\tools.cpp openssl/sha.h: No such file or directory. 

24 C:\Users\Administrador\Desktop\source\tools.cpp openssl/md5.h: No such file or directory. 
 C:\Users\Administrador\Desktop\source\tools.cpp In function 'std::string transformToMD5(std::string, bool)': 
33 C:\Users\Administrador\Desktop\source\tools.cpp 'MD5_CTX' was not declared in this scope 
33 C:\Users\Administrador\Desktop\source\tools.cpp expected ';' before 'c' 
34 C:\Users\Administrador\Desktop\source\tools.cpp 'c' was not declared in this scope 
34 C:\Users\Administrador\Desktop\source\tools.cpp 'MD5_Init' was not declared in this scope 
35 C:\Users\Administrador\Desktop\source\tools.cpp 'MD5_Update' was not declared in this scope 
37 C:\Users\Administrador\Desktop\source\tools.cpp 'MD5_DIGEST_LENGTH' was not declared in this scope 

 

Tem varios e varios erros além desses, mais só copiei esses para facilitar Quem souber arrumar porfavor me ajuda, dou rep +, Aqui embaixo vai tar o tools.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 "tools.h"

#include <iostream>
#include <iomanip>

#include <openssl/sha.h>
#include <openssl/md5.h>

#include "vocation.h"
#include "configmanager.h"

extern ConfigManager g_config;

std::string transformToMD5(std::string plainText, bool upperCase)
{
    MD5_CTX c;
    MD5_Init(&c);
    MD5_Update(&c, plainText.c_str(), plainText.length());

    uint8_t md[MD5_DIGEST_LENGTH];
    MD5_Final(md, &c);

    char output[MD5_DIGEST_LENGTH * 2 + 1] = "";
    for(int32_t i = 0; i < static_cast<int32_t>(sizeof(md)); i++)
        sprintf(output, "%s%.2X", output, md);

    if(upperCase)
        return std::string(output);

    return asLowerCaseString(std::string(output));
}

std::string transformToSHA1(std::string plainText, bool upperCase)
{
    SHA_CTX c;
    SHA1_Init(&c);
    SHA1_Update(&c, plainText.c_str(), plainText.length());

    uint8_t md[SHA_DIGEST_LENGTH];
    SHA1_Final(md, &c);

    char output[SHA_DIGEST_LENGTH * 2 + 1] = "";
    for(int32_t i = 0; i < static_cast<int32_t>(sizeof(md)); i++)
        sprintf(output, "%s%.2X", output, md);

    if(upperCase)
        return std::string(output);

    return asLowerCaseString(std::string(output));
}

std::string transformToSHA256(std::string plainText, bool upperCase)
{
    SHA256_CTX c;
    SHA256_Init(&c);
    SHA256_Update(&c, plainText.c_str(), plainText.length());

    uint8_t md[SHA256_DIGEST_LENGTH];
    SHA256_Final(md, &c);

    char output[SHA256_DIGEST_LENGTH * 2 + 1] = "";
    for(int32_t i = 0; i < static_cast<int32_t>(sizeof(md)); i++)
        sprintf(output, "%s%.2X", output, md);

    if(upperCase)
        return std::string(output);

    return asLowerCaseString(std::string(output));
}

std::string transformToSHA512(std::string plainText, bool upperCase)
{
    SHA512_CTX c;
    SHA512_Init(&c);
    SHA512_Update(&c, plainText.c_str(), plainText.length());

    uint8_t md[SHA512_DIGEST_LENGTH];
    SHA512_Final(md, &c);

    char output[SHA512_DIGEST_LENGTH * 2 + 1] = "";
    for(int32_t i = 0; i < static_cast<int32_t>(sizeof(md)); i++)
        sprintf(output, "%s%.2X", output, md);

    if(upperCase)
        return std::string(output);

    return asLowerCaseString(std::string(output));
}

void _encrypt(std::string& str, bool upperCase)
{
    switch(g_config.getNumber(ConfigManager::ENCRYPTION))
    {
        case ENCRYPTION_MD5:
            str = transformToMD5(str, upperCase);
            break;
        case ENCRYPTION_SHA1:
            str = transformToSHA1(str, upperCase);
            break;
        case ENCRYPTION_SHA256:
            str = transformToSHA256(str, upperCase);
            break;
        case ENCRYPTION_SHA512:
            str = transformToSHA512(str, upperCase);
            break;
        default:
        {
            if(upperCase)
                std::transform(str.begin(), str.end(), str.begin(), upchar);

            break;
        }
    }
}

bool encryptTest(std::string plain, std::string& hash)
{
    std::transform(hash.begin(), hash.end(), hash.begin(), upchar);
    _encrypt(plain, true);
    return plain == hash;
}

bool replaceString(std::string& text, const std::string& key, const std::string& value)
{
    if(text.find(key) == std::string::npos)
        return false;

    std::string::size_type start = 0, pos = 0;
    while((start = text.find(key, pos)) != std::string::npos)
    {
        text.replace(start, key.size(), value);
        //text = text.substr(0, start) + value + text.substr(start + key.size());
        pos = start + value.size();
    }

    return true;
}

void trim_right(std::string& source, const std::string& t)
{
    source.erase(source.find_last_not_of(t) + 1);
}

void trim_left(std::string& source, const std::string& t)
{
    source.erase(0, source.find_first_not_of(t));
}

void toLowerCaseString(std::string& source)
{
    std::transform(source.begin(), source.end(), source.begin(), tolower);
}

void toUpperCaseString(std::string& source)
{
    std::transform(source.begin(), source.end(), source.begin(), upchar);
}

std::string asLowerCaseString(const std::string& source)
{
    std::string s = source;
    toLowerCaseString(s);
    return s;
}

std::string asUpperCaseString(const std::string& source)
{
    std::string s = source;
    toUpperCaseString(s);
    return s;
}

bool booleanString(std::string source)
{
    toLowerCaseString(source);
    return (source == "yes" || source == "true" || atoi(source.c_str()) > 0);
}

bool readXMLInteger(xmlNodePtr node, const char* tag, int32_t& value)
{
    char* nodeValue = (char*)xmlGetProp(node, (xmlChar*)tag);
    if(!nodeValue)
        return false;

    value = atoi(nodeValue);
    xmlFree(nodeValue);
    return true;
}

bool readXMLInteger64(xmlNodePtr node, const char* tag, int64_t& value)
{
    char* nodeValue = (char*)xmlGetProp(node, (xmlChar*)tag);
    if(!nodeValue)
        return false;

    value = atoll(nodeValue);
    xmlFree(nodeValue);
    return true;
}

bool readXMLFloat(xmlNodePtr node, const char* tag, float& value)
{
    char* nodeValue = (char*)xmlGetProp(node, (xmlChar*)tag);
    if(!nodeValue)
        return false;

    value = atof(nodeValue);
    xmlFree(nodeValue);
    return true;
}

bool readXMLString(xmlNodePtr node, const char* tag, std::string& value)
{
    char* nodeValue = (char*)xmlGetProp(node, (xmlChar*)tag);
    if(!nodeValue)
        return false;

    if(!utf8ToLatin1(nodeValue, value))
        value = nodeValue;

    xmlFree(nodeValue);
    return true;
}

bool readXMLContentString(xmlNodePtr node, std::string& value)
{
    char* nodeValue = (char*)xmlNodeGetContent(node);
    if(!nodeValue)
        return false;

    if(!utf8ToLatin1(nodeValue, value))
        value = nodeValue;

    xmlFree(nodeValue);
    return true;
}

bool parseXMLContentString(xmlNodePtr node, std::string& value)
{
    bool result = false;
    std::string compareValue;
    while(node)
    {
        if(xmlStrcmp(node->name, (const xmlChar*)"text") && node->type != XML_CDATA_SECTION_NODE)
        {
            node = node->next;
            continue;
        }

        if(!readXMLContentString(node, compareValue))
        {
            node = node->next;
            continue;
        }

        trim_left(compareValue, "\r");
        trim_left(compareValue, "\n");
        trim_left(compareValue, " ");
        if(compareValue.length() > value.length())
        {
            value = compareValue;
            if(!result)
                result = true;
        }

        node = node->next;
    }

    return result;
}

std::string getLastXMLError()
{
    std::stringstream ss;
    xmlErrorPtr lastError = xmlGetLastError();
    if(lastError->line)
        ss << "Line: " << lastError->line << ", ";

    ss << "Info: " << lastError->message << std::endl;
    return ss.str();
}

bool utf8ToLatin1(char* intext, std::string& outtext)
{
    outtext = "";
    if(!intext)
        return false;

    int32_t inlen = strlen(intext);
    if(!inlen)
        return false;

    int32_t outlen = inlen * 2;
    uint8_t* outbuf = new uint8_t[outlen];

    int32_t res = UTF8Toisolat1(outbuf, &outlen, (uint8_t*)intext, &inlen);
    if(res < 0)
    {
        delete[] outbuf;
        return false;
    }

    outbuf[outlen] = '\0';
    outtext = (char*)outbuf;

    delete[] outbuf;
    return true;
}

StringVec explodeString(const std::string& string, const std::string& separator)
{
    StringVec returnVector;
    size_t start = 0, end = 0;
    while((end = string.find(separator, start)) != std::string::npos)
    {
        returnVector.push_back(string.substr(start, end - start));
        start = end + separator.size();
    }

    returnVector.push_back(string.substr(start));
    return returnVector;
}

IntegerVec vectorAtoi(StringVec stringVector)
{
    IntegerVec returnVector;
    for(StringVec::iterator it = stringVector.begin(); it != stringVector.end(); ++it)
        returnVector.push_back(atoi((*it).c_str()));

    return returnVector;
}

bool hasBitSet(uint32_t flag, uint32_t flags)
{
    return ((flags & flag) == flag);
}

int32_t round(float v)
{
    int32_t t = (int32_t)std::floor(v);
    if((v - t) > 0.5)
        return t + 1;

    return t;
}

uint32_t rand24b()
{
    return ((rand() << 12) ^ (rand())) & (0xFFFFFF);
}

float box_muller(float m, float s)
{
    // normal random variate generator
    // mean m, standard deviation s
    float x1, x2, w, y1;
    static float y2;

    static bool useLast = false;
    if(useLast) // use value from previous call
    {
        y1 = y2;
        useLast = false;
        return (m + y1 * s);
    }

    do
    {
        double r1 = (((float)(rand()) / RAND_MAX));
        double r2 = (((float)(rand()) / RAND_MAX));

        x1 = 2.0 * r1 - 1.0;
        x2 = 2.0 * r2 - 1.0;
        w = x1 * x1 + x2 * x2;
    }
    while(w >= 1.0);
    w = sqrt((-2.0 * log(w)) / w);

    y1 = x1 * w;
    y2 = x2 * w;

    useLast = true;
    return (m + y1 * s);
}

int32_t random_range(int32_t lowestNumber, int32_t highestNumber, DistributionType_t type /*= DISTRO_UNIFORM*/)
{
    if(highestNumber == lowestNumber)
        return lowestNumber;

    if(lowestNumber > highestNumber)
        std::swap(lowestNumber, highestNumber);

    switch(type)
    {
        case DISTRO_UNIFORM:
            return (lowestNumber + ((int32_t)rand24b() % (highestNumber - lowestNumber + 1)));
        case DISTRO_NORMAL:
            return (lowestNumber + int32_t(float(highestNumber - lowestNumber) * (float)std::min((float)1, std::max((float)0, box_muller(0.5, 0.25)))));
        default:
            break;
    }

    const float randMax = 16777216;
    return (lowestNumber + int32_t(float(highestNumber - lowestNumber) * float(1.f - sqrt((1.f * rand24b()) / randMax))));
}

char upchar(char character)
{
    if((character >= 97 && character <= 122) || (character <= -1 && character >= -32))
        character -= 32;

    return character;
}

bool isNumber(char character)
{
    return (character >= 48 && character <= 57);
}

bool isLowercaseLetter(char character)
{
    return (character >= 97 && character <= 122);
}

bool isUppercaseLetter(char character)
{
    return (character >= 65 && character <= 90);
}

bool isPasswordCharacter(char character)
{
    return ((character >= 33 && character <= 47) || (character >= 58 && character <= 64) || (character >= 91 && character <= 96) || (character >= 123 && character <= 126));
}

bool isValidAccountName(std::string text)
{
    toLowerCaseString(text);

    uint32_t textLength = text.length();
    for(uint32_t size = 0; size < textLength; size++)
    {
        if(!isLowercaseLetter(text) && !isNumber(text))
            return false;
    }

    return true;
}

bool isValidPassword(std::string text)
{
    toLowerCaseString(text);

    uint32_t textLength = text.length();
    for(uint32_t size = 0; size < textLength; size++)
    {
        if(!isLowercaseLetter(text) && !isNumber(text) && !isPasswordCharacter(text))
            return false;
    }

    return true;
}

bool isValidName(std::string text, bool forceUppercaseOnFirstLetter/* = true*/)
{
    uint32_t textLength = text.length(), lenBeforeSpace = 1, lenBeforeQuote = 1, lenBeforeDash = 1, repeatedCharacter = 0;
    char lastChar = 32;
    if(forceUppercaseOnFirstLetter)
    {
        if(!isUppercaseLetter(text[0]))
            return false;
    }
    else if(!isLowercaseLetter(text[0]) && !isUppercaseLetter(text[0]))
        return false;

    for(uint32_t size = 1; size < textLength; size++)
    {
        if(text != 32)
        {
            lenBeforeSpace++;
            if(text != 39)
                lenBeforeQuote++;
            else
            {
                if(lenBeforeQuote <= 1 || size == textLength - 1 || text == 32)
                    return false;

                lenBeforeQuote = 0;
            }

            if(text != 45)
                lenBeforeDash++;
            else
            {
                if(lenBeforeDash <= 1 || size == textLength - 1 || text == 32)
                    return false;

                lenBeforeDash = 0;
            }

            if(text == lastChar)
            {
                repeatedCharacter++;
                if(repeatedCharacter > 2)
                    return false;
            }
            else
                repeatedCharacter = 0;

            lastChar = text;
        }
        else
        {
            if(lenBeforeSpace <= 1 || size == textLength - 1 || text == 32)
                return false;

            lenBeforeSpace = lenBeforeQuote = lenBeforeDash = 0;
        }

        if(!(isLowercaseLetter(text) || text == 32 || text == 39 || text == 45
            || (isUppercaseLetter(text) && text == 32)))
            return false;
    }

    return true;
}

bool isNumbers(std::string text)
{
    uint32_t textLength = text.length();
    for(uint32_t size = 0; size < textLength; size++)
    {
        if(!isNumber(text))
            return false;
    }

    return true;
}

bool checkText(std::string text, std::string str)
{
    trimString(text);
    return asLowerCaseString(text) == str;
}

std::string generateRecoveryKey(int32_t fieldCount, int32_t fieldLenght, bool mixCase/* = false*/)
{
    std::stringstream key;
    int32_t i = 0, j = 0, lastNumber = 99, number = 0;

    char character = 0, lastCharacter = 0;
    bool madeNumber = false, madeCharacter = false;
    do
    {
        do
        {
            madeNumber = madeCharacter = false;
            if((mixCase && !random_range(0, 2)) || (!mixCase && (bool)random_range(0, 1)))
            {
                number = random_range(2, 9);
                if(number != lastNumber)
                {
                    key << number;
                    lastNumber = number;
                    madeNumber = true;
                }
            }
            else
            {
                if(mixCase && (bool)random_range(0,1) )
                    character = (char)random_range(97, 122);
                else
                    character = (char)random_range(65, 90);

                if(character != lastCharacter)
                {
                    key << character;
                    lastCharacter = character;
                    madeCharacter = true;
                }
            }
        }
        while((!madeCharacter && !madeNumber) ? true : (++j && j < fieldLenght));
        lastCharacter = character = number = j = 0;

        lastNumber = 99;
        if(i < fieldCount - 1)
            key << "-";
    }
    while(++i && i < fieldCount);
    return key.str();
}

std::string trimString(std::string& str)
{
    str.erase(str.find_last_not_of(" ") + 1);
    return str.erase(0, str.find_first_not_of(" "));
}

std::string parseParams(tokenizer::iterator &it, tokenizer::iterator end)
{
    if(it == end)
        return "";

    std::string tmp = (*it);
    ++it;
    if(tmp[0] == '"')
    {
        tmp.erase(0, 1);
        while(it != end && tmp[tmp.length() - 1] != '"')
        {
            tmp += " " + (*it);
            ++it;
        }

        if(tmp.length() > 0 && tmp[tmp.length() - 1] == '"')
            tmp.erase(tmp.length() - 1);
    }

    return tmp;
}

std::string formatDate(time_t _time/* = 0*/)
{
    if(!_time)
        _time = time(NULL);

    const tm* tms = localtime(&_time);
    std::stringstream s;
    if(tms)
        s << tms->tm_mday << "/" << (tms->tm_mon + 1) << "/" << (tms->tm_year + 1900) << " " << tms->tm_hour << ":" << tms->tm_min << ":" << tms->tm_sec;
    else
        s << "UNIX Time: " << (int32_t)_time;

    return s.str();
}

std::string formatDateEx(time_t _time/* = 0*/, std::string format/* = "%d %b %Y, %H:%M:%S"*/)
{
    if(!_time)
        _time = time(NULL);

    const tm* tms = localtime(&_time);
    char buffer[100];
    if(tms)
        strftime(buffer, 25, format.c_str(), tms);
    else
        sprintf(buffer, "UNIX Time: %d", (int32_t)_time);

    return buffer;
}

std::string formatTime(time_t _time/* = 0*/, bool ms/* = false*/)
{
    if(!_time)
        _time = time(NULL);
    else if(ms)
        ms = false;

    const tm* tms = localtime(&_time);
    std::stringstream s;
    if(tms)
    {
        s << tms->tm_hour << ":" << tms->tm_min << ":";
        if(tms->tm_sec < 10)
            s << "0";

        s << tms->tm_sec;
        if(ms)
        {
            timeb t;
            ftime(&t);

            s << "."; // make it format zzz
            if(t.millitm < 10)
                s << "0";

            if(t.millitm < 100)
                s << "0";

            s << t.millitm;
        }
    }
    else
        s << "UNIX Time: " << (int32_t)_time;

    return s.str();
}

std::string convertIPAddress(uint32_t ip)
{
    char buffer[17];
    sprintf(buffer, "%d.%d.%d.%d", ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24));
    return buffer;
}

Skulls_t getSkulls(std::string strValue)
{
    std::string tmpStrValue = asLowerCaseString(strValue);
    if(tmpStrValue == "black" || tmpStrValue == "5")
        return SKULL_BLACK;

    if(tmpStrValue == "red" || tmpStrValue == "4")
        return SKULL_RED;

    if(tmpStrValue == "white" || tmpStrValue == "3")
        return SKULL_WHITE;

    if(tmpStrValue == "green" || tmpStrValue == "2")
        return SKULL_GREEN;

    if(tmpStrValue == "yellow" || tmpStrValue == "1")
        return SKULL_YELLOW;

    return SKULL_NONE;
}

PartyShields_t getShields(std::string strValue)
{
    std::string tmpStrValue = asLowerCaseString(strValue);
    if(tmpStrValue == "whitenoshareoff" || tmpStrValue == "10")
        return SHIELD_YELLOW_NOSHAREDEXP;

    if(tmpStrValue == "blueshareoff" || tmpStrValue == "9")
        return SHIELD_BLUE_NOSHAREDEXP;

    if(tmpStrValue == "yellowshareblink" || tmpStrValue == "8")
        return SHIELD_YELLOW_NOSHAREDEXP_BLINK;

    if(tmpStrValue == "blueshareblink" || tmpStrValue == "7")
        return SHIELD_BLUE_NOSHAREDEXP_BLINK;

    if(tmpStrValue == "yellowshareon" || tmpStrValue == "6")
        return SHIELD_YELLOW_SHAREDEXP;

    if(tmpStrValue == "blueshareon" || tmpStrValue == "5")
        return SHIELD_BLUE_SHAREDEXP;

    if(tmpStrValue == "yellow" || tmpStrValue == "4")
        return SHIELD_YELLOW;

    if(tmpStrValue == "blue" || tmpStrValue == "3")
        return SHIELD_BLUE;

    if(tmpStrValue == "whiteyellow" || tmpStrValue == "2")
        return SHIELD_WHITEYELLOW;

    if(tmpStrValue == "whiteblue" || tmpStrValue == "1")
        return SHIELD_WHITEBLUE;

    return SHIELD_NONE;
}

GuildEmblems_t getEmblems(std::string strValue)
{
    std::string tmpStrValue = asLowerCaseString(strValue);
    if(tmpStrValue == "blue" || tmpStrValue == "3")
        return EMBLEM_BLUE;

    if(tmpStrValue == "red" || tmpStrValue == "2")
        return EMBLEM_RED;

    if(tmpStrValue == "green" || tmpStrValue == "1")
        return EMBLEM_GREEN;

    return EMBLEM_NONE;
}

Direction getDirection(std::string string)
{
    if(string == "north" || string == "n" || string == "0")
        return NORTH;

    if(string == "east" || string == "e" || string == "1")
        return EAST;

    if(string == "south" || string == "s" || string == "2")
        return SOUTH;

    if(string == "west" || string == "w" || string == "3")
        return WEST;

    if(string == "southwest" || string == "south west" || string == "south-west" || string == "sw" || string == "4")
        return SOUTHWEST;

    if(string == "southeast" || string == "south east" || string == "south-east" || string == "se" || string == "5")
        return SOUTHEAST;

    if(string == "northwest" || string == "north west" || string == "north-west" || string == "nw" || string == "6")
        return NORTHWEST;

    if(string == "northeast" || string == "north east" || string == "north-east" || string == "ne" || string == "7")
        return NORTHEAST;

    return SOUTH;
}

Direction getDirectionTo(Position pos1, Position pos2, bool extended/* = true*/)
{
    Direction direction = NORTH;
    if(pos1.x > pos2.x)
    {
        direction = WEST;
        if(extended)
        {
            if(pos1.y > pos2.y)
                direction = NORTHWEST;
            else if(pos1.y < pos2.y)
                direction = SOUTHWEST;
        }
    }
    else if(pos1.x < pos2.x)
    {
        direction = EAST;
        if(extended)
        {
            if(pos1.y > pos2.y)
                direction = NORTHEAST;
            else if(pos1.y < pos2.y)
                direction = SOUTHEAST;
        }
    }
    else
    {
        if(pos1.y > pos2.y)
            direction = NORTH;
        else if(pos1.y < pos2.y)
            direction = SOUTH;
    }

    return direction;
}

Direction getReverseDirection(Direction dir)
{
    switch(dir)
    {
        case NORTH:
            return SOUTH;
        case SOUTH:
            return NORTH;
        case WEST:
            return EAST;
        case EAST:
            return WEST;
        case SOUTHWEST:
            return NORTHEAST;
        case NORTHWEST:
            return SOUTHEAST;
        case NORTHEAST:
            return SOUTHWEST;
        case SOUTHEAST:
            return NORTHWEST;
    }

    return SOUTH;
}

Position getNextPosition(Direction direction, Position pos)
{
    switch(direction)
    {
        case NORTH:
            pos.y--;
            break;
        case SOUTH:
            pos.y++;
            break;
        case WEST:
            pos.x--;
            break;
        case EAST:
            pos.x++;
            break;
        case SOUTHWEST:
            pos.x--;
            pos.y++;
            break;
        case NORTHWEST:
            pos.x--;
            pos.y--;
            break;
        case SOUTHEAST:
            pos.x++;
            pos.y++;
            break;
        case NORTHEAST:
            pos.x++;
            pos.y--;
            break;
    }

    return pos;
}

struct AmmoTypeNames
{
    const char* name;
    Ammo_t ammoType;
};

struct MagicEffectNames
{
    const char* name;
    MagicEffect_t magicEffect;
};

struct ShootTypeNames
{
    const char* name;
    ShootEffect_t shootType;
};

struct CombatTypeNames
{
    const char* name;
    CombatType_t combatType;
};

struct AmmoActionNames
{
    const char* name;
    AmmoAction_t ammoAction;
};

struct FluidTypeNames
{
    const char* name;
    FluidTypes_t fluidType;
};

struct SkillIdNames
{
    const char* name;
    skills_t skillId;
};

MagicEffectNames magicEffectNames[] =
{
    {"redspark",        MAGIC_EFFECT_DRAW_BLOOD},
    {"bluebubble",        MAGIC_EFFECT_LOSE_ENERGY},
    {"poff",        MAGIC_EFFECT_POFF},
    {"yellowspark",        MAGIC_EFFECT_BLOCKHIT},
    {"explosionarea",    MAGIC_EFFECT_EXPLOSION_AREA},
    {"explosion",        MAGIC_EFFECT_EXPLOSION_DAMAGE},
    {"firearea",        MAGIC_EFFECT_FIRE_AREA},
    {"yellowbubble",    MAGIC_EFFECT_YELLOW_RINGS},
    {"greenbubble",        MAGIC_EFFECT_POISON_RINGS},
    {"blackspark",        MAGIC_EFFECT_HIT_AREA},
    {"teleport",        MAGIC_EFFECT_TELEPORT},
    {"energy",        MAGIC_EFFECT_ENERGY_DAMAGE},
    {"blueshimmer",        MAGIC_EFFECT_WRAPS_BLUE},
    {"redshimmer",        MAGIC_EFFECT_WRAPS_RED},
    {"greenshimmer",    MAGIC_EFFECT_WRAPS_GREEN},
    {"fire",        MAGIC_EFFECT_HITBY_FIRE},
    {"greenspark",        MAGIC_EFFECT_POISON},
    {"mortarea",        MAGIC_EFFECT_MORT_AREA},
    {"greennote",        MAGIC_EFFECT_SOUND_GREEN},
    {"rednote",        MAGIC_EFFECT_SOUND_RED},
    {"poison",        MAGIC_EFFECT_POISON_AREA},
    {"yellownote",        MAGIC_EFFECT_SOUND_YELLOW},
    {"purplenote",        MAGIC_EFFECT_SOUND_PURPLE},
    {"bluenote",        MAGIC_EFFECT_SOUND_BLUE},
    {"whitenote",        MAGIC_EFFECT_SOUND_WHITE},
    {"bubbles",        MAGIC_EFFECT_BUBBLES},
    {"dice",        MAGIC_EFFECT_CRAPS},
    {"giftwraps",        MAGIC_EFFECT_GIFT_WRAPS},
    {"yellowfirework",    MAGIC_EFFECT_FIREWORK_YELLOW},
    {"redfirework",        MAGIC_EFFECT_FIREWORK_RED},
    {"bluefirework",    MAGIC_EFFECT_FIREWORK_BLUE},
    {"stun",        MAGIC_EFFECT_STUN},
    {"sleep",        MAGIC_EFFECT_SLEEP},
    {"watercreature",    MAGIC_EFFECT_WATERCREATURE},
    {"groundshaker",    MAGIC_EFFECT_GROUNDSHAKER},
    {"hearts",        MAGIC_EFFECT_HEARTS},
    {"fireattack",        MAGIC_EFFECT_FIREATTACK},
    {"energyarea",        MAGIC_EFFECT_ENERGY_AREA},
    {"smallclouds",        MAGIC_EFFECT_SMALLCLOUDS},
    {"holydamage",        MAGIC_EFFECT_HOLYDAMAGE},
    {"bigclouds",        MAGIC_EFFECT_BIGCLOUDS},
    {"icearea",        MAGIC_EFFECT_ICEAREA},
    {"icetornado",        MAGIC_EFFECT_ICETORNADO},
    {"iceattack",        MAGIC_EFFECT_ICEATTACK},
    {"stones",        MAGIC_EFFECT_STONES},
    {"smallplants",        MAGIC_EFFECT_SMALLPLANTS},
    {"carniphila",        MAGIC_EFFECT_CARNIPHILA},
    {"purpleenergy",    MAGIC_EFFECT_PURPLEENERGY},
    {"yellowenergy",    MAGIC_EFFECT_YELLOWENERGY},
    {"holyarea",        MAGIC_EFFECT_HOLYAREA},
    {"bigplants",        MAGIC_EFFECT_BIGPLANTS},
    {"cake",        MAGIC_EFFECT_CAKE},
    {"giantice",        MAGIC_EFFECT_GIANTICE},
    {"watersplash",        MAGIC_EFFECT_WATERSPLASH},
    {"plantattack",        MAGIC_EFFECT_PLANTATTACK},
    {"tutorialarrow",    MAGIC_EFFECT_TUTORIALARROW},
    {"tutorialsquare",    MAGIC_EFFECT_TUTORIALSQUARE},
    {"mirrorhorizontal",    MAGIC_EFFECT_MIRRORHORIZONTAL},
    {"mirrorvertical",    MAGIC_EFFECT_MIRRORVERTICAL},
    {"skullhorizontal",    MAGIC_EFFECT_SKULLHORIZONTAL},
    {"skullvertical",    MAGIC_EFFECT_SKULLVERTICAL},
    {"assassin",        MAGIC_EFFECT_ASSASSIN},
    {"stepshorizontal",    MAGIC_EFFECT_STEPSHORIZONTAL},
    {"bloodysteps",        MAGIC_EFFECT_BLOODYSTEPS},
    {"stepsvertical",    MAGIC_EFFECT_STEPSVERTICAL},
    {"yalaharighost",    MAGIC_EFFECT_YALAHARIGHOST},
    {"bats",        MAGIC_EFFECT_BATS},
    {"smoke",        MAGIC_EFFECT_SMOKE},
    {"insects",        MAGIC_EFFECT_INSECTS},
    {"dragonhead",    MAGIC_EFFECT_DRAGONHEAD}
};

ShootTypeNames shootTypeNames[] =
{
    {"spear",        SHOOT_EFFECT_SPEAR},
    {"bolt",        SHOOT_EFFECT_BOLT},
    {"arrow",        SHOOT_EFFECT_ARROW},
    {"fire",        SHOOT_EFFECT_FIRE},
    {"energy",        SHOOT_EFFECT_ENERGY},
    {"poisonarrow",        SHOOT_EFFECT_POISONARROW},
    {"burstarrow",        SHOOT_EFFECT_BURSTARROW},
    {"throwingstar",    SHOOT_EFFECT_THROWINGSTAR},
    {"throwingknife",    SHOOT_EFFECT_THROWINGKNIFE},
    {"smallstone",        SHOOT_EFFECT_SMALLSTONE},
    {"death",        SHOOT_EFFECT_DEATH},
    {"largerock",        SHOOT_EFFECT_LARGEROCK},
    {"snowball",        SHOOT_EFFECT_SNOWBALL},
    {"powerbolt",        SHOOT_EFFECT_POWERBOLT},
    {"poison",        SHOOT_EFFECT_POISONFIELD},
    {"infernalbolt",    SHOOT_EFFECT_INFERNALBOLT},
    {"huntingspear",    SHOOT_EFFECT_HUNTINGSPEAR},
    {"enchantedspear",    SHOOT_EFFECT_ENCHANTEDSPEAR},
    {"redstar",        SHOOT_EFFECT_REDSTAR},
    {"greenstar",        SHOOT_EFFECT_GREENSTAR},
    {"royalspear",        SHOOT_EFFECT_ROYALSPEAR},
    {"sniperarrow",        SHOOT_EFFECT_SNIPERARROW},
    {"onyxarrow",        SHOOT_EFFECT_ONYXARROW},
    {"piercingbolt",    SHOOT_EFFECT_PIERCINGBOLT},
    {"whirlwindsword",    SHOOT_EFFECT_WHIRLWINDSWORD},
    {"whirlwindaxe",    SHOOT_EFFECT_WHIRLWINDAXE},
    {"whirlwindclub",    SHOOT_EFFECT_WHIRLWINDCLUB},
    {"etherealspear",    SHOOT_EFFECT_ETHEREALSPEAR},
    {"ice",            SHOOT_EFFECT_ICE},
    {"earth",        SHOOT_EFFECT_EARTH},
    {"holy",        SHOOT_EFFECT_HOLY},
    {"suddendeath",        SHOOT_EFFECT_SUDDENDEATH},
    {"flasharrow",        SHOOT_EFFECT_FLASHARROW},
    {"flammingarrow",    SHOOT_EFFECT_FLAMMINGARROW},
    {"flamingarrow",    SHOOT_EFFECT_FLAMMINGARROW},
    {"shiverarrow",        SHOOT_EFFECT_SHIVERARROW},
    {"energyball",        SHOOT_EFFECT_ENERGYBALL},
    {"smallice",        SHOOT_EFFECT_SMALLICE},
    {"smallholy",        SHOOT_EFFECT_SMALLHOLY},
    {"smallearth",        SHOOT_EFFECT_SMALLEARTH},
    {"eartharrow",        SHOOT_EFFECT_EARTHARROW},
    {"explosion",        SHOOT_EFFECT_EXPLOSION},
    {"cake",        SHOOT_EFFECT_CAKE}
};

CombatTypeNames combatTypeNames[] =
{
    {"physical",        COMBAT_PHYSICALDAMAGE},
    {"energy",        COMBAT_ENERGYDAMAGE},
    {"earth",        COMBAT_EARTHDAMAGE},
    {"fire",        COMBAT_FIREDAMAGE},
    {"undefined",        COMBAT_UNDEFINEDDAMAGE},
    {"lifedrain",        COMBAT_LIFEDRAIN},
    {"life drain",        COMBAT_LIFEDRAIN},
    {"manadrain",        COMBAT_MANADRAIN},
    {"mana drain",        COMBAT_MANADRAIN},
    {"healing",        COMBAT_HEALING},
    {"drown",        COMBAT_DROWNDAMAGE},
    {"ice",            COMBAT_ICEDAMAGE},
    {"holy",        COMBAT_HOLYDAMAGE},
    {"death",        COMBAT_DEATHDAMAGE}
};

AmmoTypeNames ammoTypeNames[] =
{
    {"spear",        AMMO_SPEAR},
    {"arrow",        AMMO_ARROW},
    {"poisonarrow",        AMMO_ARROW},
    {"burstarrow",        AMMO_ARROW},
    {"bolt",        AMMO_BOLT},
    {"powerbolt",        AMMO_BOLT},
    {"smallstone",        AMMO_STONE},
    {"largerock",        AMMO_STONE},
    {"throwingstar",    AMMO_THROWINGSTAR},
    {"throwingknife",    AMMO_THROWINGKNIFE},
    {"snowball",        AMMO_SNOWBALL},
    {"huntingspear",    AMMO_SPEAR},
    {"royalspear",        AMMO_SPEAR},
    {"enchantedspear",    AMMO_SPEAR},
    {"sniperarrow",        AMMO_ARROW},
    {"onyxarrow",        AMMO_ARROW},
    {"piercingbolt",    AMMO_BOLT},
    {"infernalbolt",    AMMO_BOLT},
    {"flasharrow",        AMMO_ARROW},
    {"flammingarrow",    AMMO_ARROW},
    {"flamingarrow",    AMMO_ARROW},
    {"shiverarrow",        AMMO_ARROW},
    {"eartharrow",        AMMO_ARROW},
    {"etherealspear",    AMMO_SPEAR}
};

AmmoActionNames ammoActionNames[] =
{
    {"move",        AMMOACTION_MOVE},
    {"moveback",        AMMOACTION_MOVEBACK},
    {"move back",        AMMOACTION_MOVEBACK},
    {"removecharge",    AMMOACTION_REMOVECHARGE},
    {"remove charge",    AMMOACTION_REMOVECHARGE},
    {"removecount",        AMMOACTION_REMOVECOUNT},
    {"remove count",    AMMOACTION_REMOVECOUNT}
};

FluidTypeNames fluidTypeNames[] =
{
    {"none",        FLUID_NONE},
    {"water",        FLUID_WATER},
    {"blood",        FLUID_BLOOD},
    {"beer",        FLUID_BEER},
    {"slime",        FLUID_SLIME},
    {"lemonade",        FLUID_LEMONADE},
    {"milk",        FLUID_MILK},
    {"mana",        FLUID_MANA},
    {"life",        FLUID_LIFE},
    {"oil",            FLUID_OIL},
    {"urine",        FLUID_URINE},
    {"coconutmilk",        FLUID_COCONUTMILK},
    {"coconut milk",    FLUID_COCONUTMILK},
    {"wine",        FLUID_WINE},
    {"mud",            FLUID_MUD},
    {"fruitjuice",        FLUID_FRUITJUICE},
    {"fruit juice",        FLUID_FRUITJUICE},
    {"lava",        FLUID_LAVA},
    {"rum",            FLUID_RUM},
    {"swamp",        FLUID_SWAMP},
    {"tea",            FLUID_TEA},
    {"mead",        FLUID_MEAD}
};

SkillIdNames skillIdNames[] =
{
    {"fist",        SKILL_FIST},
    {"club",        SKILL_CLUB},
    {"sword",        SKILL_SWORD},
    {"axe",            SKILL_AXE},
    {"distance",        SKILL_DIST},
    {"dist",        SKILL_DIST},
    {"shielding",        SKILL_SHIELD},
    {"shield",        SKILL_SHIELD},
    {"fishing",        SKILL_FISH},
    {"fish",        SKILL_FISH},
    {"level",        SKILL__LEVEL},
    {"magiclevel",        SKILL__MAGLEVEL},
    {"magic level",        SKILL__MAGLEVEL}
};

MagicEffect_t getMagicEffect(const std::string& strValue)
{
    for(uint32_t i = 0; i < sizeof(magicEffectNames) / sizeof(MagicEffectNames); ++i)
    {
        if(!strcasecmp(strValue.c_str(), magicEffectNames.name))
            return magicEffectNames.magicEffect;
    }

    return MAGIC_EFFECT_UNKNOWN;
}

ShootEffect_t getShootType(const std::string& strValue)
{
    for(uint32_t i = 0; i < sizeof(shootTypeNames) / sizeof(ShootTypeNames); ++i)
    {
        if(!strcasecmp(strValue.c_str(), shootTypeNames.name))
            return shootTypeNames.shootType;
    }

    return SHOOT_EFFECT_UNKNOWN;
}

CombatType_t getCombatType(const std::string& strValue)
{
    for(uint32_t i = 0; i < sizeof(combatTypeNames) / sizeof(CombatTypeNames); ++i)
    {
        if(!strcasecmp(strValue.c_str(), combatTypeNames.name))
            return combatTypeNames.combatType;
    }

    return COMBAT_NONE;
}

Ammo_t getAmmoType(const std::string& strValue)
{
    for(uint32_t i = 0; i < sizeof(ammoTypeNames) / sizeof(AmmoTypeNames); ++i)
    {
        if(!strcasecmp(strValue.c_str(), ammoTypeNames.name))
            return ammoTypeNames.ammoType;
    }

    return AMMO_NONE;
}

AmmoAction_t getAmmoAction(const std::string& strValue)
{
    for(uint32_t i = 0; i < sizeof(ammoActionNames) / sizeof(AmmoActionNames); ++i)
    {
        if(!strcasecmp(strValue.c_str(), ammoActionNames.name))
            return ammoActionNames.ammoAction;
    }

    return AMMOACTION_NONE;
}

FluidTypes_t getFluidType(const std::string& strValue)
{
    for(uint32_t i = 0; i < sizeof(fluidTypeNames) / sizeof(FluidTypeNames); ++i)
    {
        if(!strcasecmp(strValue.c_str(), fluidTypeNames.name))
            return fluidTypeNames.fluidType;
    }

    return FLUID_NONE;
}

skills_t getSkillId(const std::string& strValue)
{
    for(uint32_t i = 0; i < sizeof(skillIdNames) / sizeof(SkillIdNames); ++i)
    {
        if(!strcasecmp(strValue.c_str(), skillIdNames.name))
            return skillIdNames.skillId;
    }

    return SKILL_FIST;
}

std::string getCombatName(CombatType_t combatType)
{
    switch(combatType)
    {
        case COMBAT_PHYSICALDAMAGE:
            return "physical";
        case COMBAT_ENERGYDAMAGE:
            return "energy";
        case COMBAT_EARTHDAMAGE:
            return "earth";
        case COMBAT_FIREDAMAGE:
            return "fire";
        case COMBAT_UNDEFINEDDAMAGE:
            return "undefined";
        case COMBAT_LIFEDRAIN:
            return "life drain";
        case COMBAT_MANADRAIN:
            return "mana drain";
        case COMBAT_HEALING:
            return "healing";
        case COMBAT_DROWNDAMAGE:
            return "drown";
        case COMBAT_ICEDAMAGE:
            return "ice";
        case COMBAT_HOLYDAMAGE:
            return "holy";
        case COMBAT_DEATHDAMAGE:
            return "death";
        default:
            break;
    }

    return "unknown";
}

std::string getSkillName(uint16_t skillId, bool suffix/* = true*/)
{
    switch(skillId)
    {
        case SKILL_FIST:
        {
            std::string tmp = "fist";
            if(suffix)
                tmp += " fighting";

            return tmp;
        }
        case SKILL_CLUB:
        {
            std::string tmp = "club";
            if(suffix)
                tmp += " fighting";

            return tmp;
        }
        case SKILL_SWORD:
        {
            std::string tmp = "sword";
            if(suffix)
                tmp += " fighting";

            return tmp;
        }
        case SKILL_AXE:
        {
            std::string tmp = "axe";
            if(suffix)
                tmp += " fighting";

            return tmp;
        }
        case SKILL_DIST:
        {
            std::string tmp = "distance";
            if(suffix)
                tmp += " fighting";

            return tmp;
        }
        case SKILL_SHIELD:
            return "shielding";
        case SKILL_FISH:
            return "fishing";
        case SKILL__MAGLEVEL:
            return "magic level";
        case SKILL__LEVEL:
            return "level";
        default:
            break;
    }

    return "unknown";
}

std::string getReason(int32_t reasonId)
{
    switch(reasonId)
    {
        case 0:
            return "Offensive Name";
        case 1:
            return "Invalid Name Format";
        case 2:
            return "Unsuitable Name";
        case 3:
            return "Name Inciting Rule Violation";
        case 4:
            return "Offensive Statement";
        case 5:
            return "Spamming";
        case 6:
            return "Illegal Advertising";
        case 7:
            return "Off-Topic Public Statement";
        case 8:
            return "Non-English Public Statement";
        case 9:
            return "Inciting Rule Violation";
        case 10:
            return "Bug Abuse";
        case 11:
            return "Game Weakness Abuse";
        case 12:
            return "Using Unofficial Software to Play";
        case 13:
            return "Hacking";
        case 14:
            return "Multi-Clienting";
        case 15:
            return "Account Trading or Sharing";
        case 16:
            return "Threatening Gamemaster";
        case 17:
            return "Pretending to Have Influence on Rule Enforcement";
        case 18:
            return "False Report to Gamemaster";
        case 19:
            return "Destructive Behaviour";
        case 20:
            return "Excessive Unjustified Player Killing";
        default:
            break;
    }

    return "Unknown Reason";
}

std::string getAction(ViolationAction_t actionId, bool ipBanishment)
{
    std::string action = "Unknown";
    switch(actionId)
    {
        case ACTION_NOTATION:
            action = "Notation";
            break;
        case ACTION_NAMEREPORT:
            action = "Name Report";
            break;
        case ACTION_BANISHMENT:
            action = "Banishment";
            break;
        case ACTION_BANREPORT:
            action = "Name Report + Banishment";
            break;
        case ACTION_BANFINAL:
            action = "Banishment + Final Warning";
            break;
        case ACTION_BANREPORTFINAL:
            action = "Name Report + Banishment + Final Warning";
            break;
        case ACTION_STATEMENT:
            action = "Statement Report";
            break;
        //internal use
        case ACTION_DELETION:
            action = "Deletion";
            break;
        case ACTION_NAMELOCK:
            action = "Name Lock";
            break;
        case ACTION_BANLOCK:
            action = "Name Lock + Banishment";
            break;
        case ACTION_BANLOCKFINAL:
            action = "Name Lock + Banishment + Final Warning";
            break;
        default:
            break;
    }

    if(ipBanishment)
        action += " + IP Banishment";

    return action;
}

std::string parseVocationString(StringVec vocStringVec)
{
    std::string str = "";
    if(!vocStringVec.empty())
    {
        for(StringVec::iterator it = vocStringVec.begin(); it != vocStringVec.end(); ++it)
        {
            if((*it) != vocStringVec.front())
            {
                if((*it) != vocStringVec.back())
                    str += ", ";
                else
                    str += " and ";
            }

            str += (*it);
            str += "s";
        }
    }

    return str;
}

bool parseVocationNode(xmlNodePtr vocationNode, VocationMap& vocationMap, StringVec& vocStringVec, std::string& errorStr)
{
    if(xmlStrcmp(vocationNode->name,(const xmlChar*)"vocation"))
        return true;

    int32_t vocationId = -1;
    std::string strValue, tmpStrValue;
    if(readXMLString(vocationNode, "name", strValue))
    {
        vocationId = Vocations::getInstance()->getVocationId(strValue);
        if(vocationId != -1)
        {
            vocationMap[vocationId] = true;
            int32_t promotedVocation = Vocations::getInstance()->getPromotedVocation(vocationId);
            if(promotedVocation != -1)
                vocationMap[promotedVocation] = true;
        }
        else
        {
            errorStr = "Wrong vocation name: " + strValue;
            return false;
        }
    }
    else if(readXMLString(vocationNode, "id", strValue))
    {
        IntegerVec intVector;
        if(!parseIntegerVec(strValue, intVector))
        {
            errorStr = "Invalid vocation id - '" + strValue + "'";
            return false;
        }

        size_t size = intVector.size();
        for(size_t i = 0; i < size; ++i)
        {
            Vocation* vocation = Vocations::getInstance()->getVocation(intVector);
            if(vocation && vocation->getName() != "")
            {
                vocationId = vocation->getId();
                strValue = vocation->getName();

                vocationMap[vocationId] = true;
                int32_t promotedVocation = Vocations::getInstance()->getPromotedVocation(vocationId);
                if(promotedVocation != -1)
                    vocationMap[promotedVocation] = true;
            }
            else
            {
                std::stringstream ss;
                ss << "Wrong vocation id: " << intVector;

                errorStr = ss.str();
                return false;
            }
        }
    }

    if(vocationId != -1 && (!readXMLString(vocationNode, "showInDescription", tmpStrValue) || booleanString(tmpStrValue)))
        vocStringVec.push_back(asLowerCaseString(strValue));

    return true;
}

bool parseIntegerVec(std::string str, IntegerVec& intVector)
{
    StringVec strVector = explodeString(str, ";");
    IntegerVec tmpIntVector;
    for(StringVec::iterator it = strVector.begin(); it != strVector.end(); ++it)
    {
        tmpIntVector = vectorAtoi(explodeString((*it), "-"));
        if(!tmpIntVector[0] && it->substr(0, 1) != "0")
            continue;

        intVector.push_back(tmpIntVector[0]);
        if(tmpIntVector.size() > 1)
        {
            while(tmpIntVector[0] < tmpIntVector[1])
                intVector.push_back(++tmpIntVector[0]);
        }
    }

    return true;
}

bool fileExists(const char* filename)
{
    FILE* f = fopen(filename, "rb");
    if(!f)
        return false;

    fclose(f);
    return true;
}

uint32_t adlerChecksum(uint8_t* data, size_t length)
{
    if(length > NETWORK_MAX_SIZE || !length)
        return 0;

    const uint16_t adler = 65521;
    uint32_t a = 1, b = 0;
    while(length > 0)
    {
        size_t tmp = length > 5552 ? 5552 : length;
        length -= tmp;
        do
        {
            a += *data++;
            b += a;
        }
        while(--tmp);
        a %= adler;
        b %= adler;
    }
    
    return (b << 16) | a;
}

std::string getFilePath(FileType_t type, std::string name/* = ""*/)
{
    #ifdef __FILESYSTEM_HIERARCHY_STANDARD__
    std::string path = "/var/lib/tfs/";
    #endif
    std::string path = g_config.getString(ConfigManager::DATA_DIRECTORY);
    switch(type)
    {
        case FILE_TYPE_OTHER:
            path += name;
            break;
        case FILE_TYPE_XML:
            path += "XML/" + name;
            break;
        case FILE_TYPE_LOG:
            #ifndef __FILESYSTEM_HIERARCHY_STANDARD__
            path = g_config.getString(ConfigManager::LOGS_DIRECTORY) + name;
            #else
            path = "/var/log/tfs/" + name;
            #endif
            break;
        case FILE_TYPE_MOD:
        {
            #ifndef __FILESYSTEM_HIERARCHY_STANDARD__
            path = "mods/" + name;
            #else
            path = "/usr/share/tfs/" + name;
            #endif
            break;
        }
        case FILE_TYPE_CONFIG:
        {
            #if defined(__HOMEDIR_CONF__)
            if(fileExists("~/.tfs/" + name))
                path = "~/.tfs/" + name;
            else
            #endif
            #if defined(__FILESYSTEM_HIERARCHY_STANDARD__)
                path = "/etc/tfs/" + name;
            #else
                path = name;
            #endif
            break;
        }
        default:
            std::clog << "> ERROR: Wrong file type!" << std::endl;
            break;
    }
    return path;
}

 

Link para o post
Compartilhar em outros sites
  • 3 weeks later...

Estou com um problema no site, quando eu vou entrar no site aparece o seguinte erro!

 

  Mostrar conteúdo oculto

 

Se alguém tiver ideá do que pode estar acontecendo é puder me ajudar

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por xWhiteWolf
      Fala galera do TK, vejo que tem bastante gente procurando esse sisteminha que é praticamente igual ao dodge system, então eu decidi fazer visto que na realidade era só mudar 3 linhas kkkk em todo caso ta aí pra quem quiser:

      creaturescripts.xml:
       <!-- CRITICAL SYSTEM -->    <event type="statschange" name="critical" event="script" value="critical.lua"/> creaturescripts\scripts\login.lua:
      --- CRITICAL SYSTEM ---- registerCreatureEvent(cid, "critical") if getPlayerStorageValue(cid, 48913) == -1 then         setPlayerStorageValue(cid, 48913, 0)      end creaturescritps\scripts\critical.lua:
      --[[Critical System -------------------------  By Night Wolf]] local lvlcrit = 48913 local multiplier = 1.5 function onStatsChange(cid, attacker, type, combat, value) if isPlayer(attacker) and (not (attacker == cid)) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS)  then if (getPlayerStorageValue(attacker, lvlcrit)*3) >= math.random (0,1000) then dano = math.ceil(value*(multiplier)) doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255) doSendAnimatedText(getCreaturePos(attacker), "CRITICAL!!", 144) return false end end return true end lvlcrit é o storage que fica salvo o seu level de critical e multiplier é o multiplicador do dano para ataques críticos.. nesse caso um ataque critico vai ser 1,5 vezes maior doque um ataque normal (50% maior)

      Agora em actions.xml adicione:
      <action itemid="1294" script="criticalrock.lua"/> e em actions\scripts\criticalrock.lua adicione:
      --- CRITICAL System by Night Wolf       local config = {    effectonuse = 14, -- efeito que sai    levelscrit = 100,  --- leveis que terão    storagecrit = 48913 -- storage que será verificado    }     function onUse(cid, item, frompos, item2, topos)     if getPlayerStorageValue(cid, config.storagecrit) < config.levelscrit then    doRemoveItem(item.uid, 1) doSendMagicEffect(topos,config.effectonuse) doPlayerSendTextMessage(cid,22,"You've Leveled your Critical Skill to ["..(getPlayerStorageValue(cid, config.storagecrit)+1).."/"..config.levelscrit.."].") setPlayerStorageValue(cid, config.storagecrit, getPlayerStorageValue(cid, config.storagecrit)+1) elseif getPlayerStorageValue(cid, config.storagecrit) >= config.levelscrit then doPlayerSendTextMessage(cid,22,"You've already reached the MAX level of Critical Skill.\nCongratulations!!!!")     return 0     end return 1 end Feito isso tá pronto, pra editar o item que dá a skill de critical vc edita no actions.xml mesmo:
      <action itemid="1294"   << ID do item que será usado pra dar a skill.
      A config tá bem simples:
      effectonuse = 14, -- efeito que sai
         levelscrit = 100,  --- leveis que terão 
         storagecrit = 48913 -- storage que será verificado.

      Lembrando que cada pedra utilizada dará 0,3% a mais de chance.. 10 pedras dão 3% de chance de dar critico a cada ataque e 100 pedras (NIVEL MÁXIMO PADRÃO) dará 30% de chance de dar crítico em cada ataque.
      Espero que vcs gostem, qualquer coisa deixem os comentários aqui.

      Obs: aqui tá uma foto


      Note que esse script só funciona em players, se vc quiser que funcione em monstros você vai ter que abrir um por um todos os monstros do server e colocar essa tag aqui: 
      <script> <event name="critical"/> </script> coloque antes de  </monster>
      Minha dica: coloquem apenas no Trainer pra que o player consiga ver que ele tem o critical e quanto ele tira e deixem avisado que o sistema só vai funcionar em players. 
    • Por KekezitoLHP
      Nome: Fist Fighting/Attackspeed
      Tipo: C++
      Autor: Oneshot
       
      Já vi alguns pedidos no fórum sobre a skill Fist Fighting, onde quanto mais você treinasse ela, mais rápido você atacaria no jogo, e parece que isto é um feature do Tibia. Como é uma modificação muito fácil nas sources, resolvi passar aí para a galera.
      Por padrão, o intervalo entre ataques do Tibia é 2000ms, ou seja, um ataque físico a cada dois segundos. Eu fiz uma pequena modificação nas sources onde o Fist Fighting seria inversamente proporcional ao tal intervalo, ou seja, quanto maior o valor da skill, menor seria o intervalo.

      Fiz de um modo que um jogador com Fist Fighting de nível 200, então, teria uma redução de 75% no intervalo de ataque, ou seja, um ataque a cada meio segundo ou dois ataques por segundo

      Leve em consideração que ele pega como base o attackspeed da vocação ou da arma usada, ou seja, se seu servidor já tem o tal chamado "fast attack", de nada adianta adicionar esse código C++.
       
       
      Abra seu player.cpp, procure por isso:
      Player::getAttackSpeed() Substitua toda a função, dependendo da versão de seu servidor:
       
      0.3.6
      uint32_t Player::getAttackSpeed() {     Item* weapon = getWeapon();     if(weapon && weapon->getAttackSpeed() != 0)         return std::ceil(weapon->getAttackSpeed() * (1 - (getSkill(SKILL_FIST, SKILL_LEVEL) * 0.00375)));     return std::ceil(vocation->getAttackSpeed() * (1 - (getSkill(SKILL_FIST, SKILL_LEVEL) * 0.00375))); } 0.4
      uint32_t Player::getAttackSpeed() const {     return std::ceil(((weapon && weapon->getAttackSpeed() != 0) ? weapon->getAttackSpeed() * (1 - (getSkill(SKILL_FIST, SKILL_LEVEL) * 0.00375)) : (vocation->getAttackSpeed() / std::max((size_t)1, getWeapons().size()) * (1 - (getSkill(SKILL_FIST, SKILL_LEVEL) * 0.00375))))); } Isso adiciona uma utilidade para a skill Fist Fighting que em muitos dos servidores é algo deixado de lado e inútil.
    • Por SlowK
      Pokémon Centurion
      (Tópico atualizado apenas para melhorar a aparência, servidor sem atualização desde 19/06/2014).
       
      Distro: Pokémon Dash Online Advanced 1.0 (PDA [Baseada na TFS 0.3.6])
      (Não tenho source).
       - Antigo cliente 8.54 -
       
      • Informações •
      - Ataques m1 ao m12
      - Sistema de bike
      - Sistema de boost
      - Trade Center
      - Mapa LunusOT
      - Sistema de profissões
      - Pokémons com níveis (com evolução)
      - Vários Shinies dentre eles da nova geração
      - Rocket (Giovani) e Police
      - Addons novos
      - Alguns Pokés com remakes
      - Várias quests escondidas
       
      • Algumas imagens •
      (Caso não estejam aparecendo, baixe aqui: IMAGENS)
       
      Senha do ADM: god/god
       
      • Links •
      Servidor
      Cliente
      (Mediafire já fornece scan semelhante ao vírustotal, basta descer a página um pouco).
       
      • Créditos •
      Cacaiu Alexandre
      Bruno Maciel
      Patrick Estrela
      SlowMCZ
       
       
      Obs: Servidor não será mais atualizado, nem darei ajuda, pois faz muito tempo que não mexo com tal server.
    • Por dodoby
      - Pokemon Imperium -
      ✺ INFORMAÇÕES
      ✺EDIÇÕES
      ✺PRINT's
      ✺ERROS - BUGS
      ✺CRÉDITOS
      ✺DOWNLOAD's

      Projeto tinha somente minha (LORDBAXX) dedicação, e tenho certeza que servirá para boas bases de projetos futuros.
      Eu trabalhava nele sempre um pouco, tanto na criação de sistemas quanto em codes para as sources (Ainda não muito modificada), o servidor é instituído somente pela primeira geração e todos os shinys (Primeira Versão), um detalhe sobre os shinys é que são de respawn com cores diferentes, pode nascer tanto de uma cor quanto de outra! (EXCRUSIVO)
      Continuo Trabalhando no servidor, então qualquer atualização estarei postando, e quem puder ajudar em melhorias, toda ajuda é bem vinda! 
      Vou listar alguns sistemas novos!
      ¤ Egg System (Único) - 100%
      ¤ TM System
      (Não único porém diferenciado)
      ¤ Age System
      (Sistema de idade nos pokemons, quando seu pokemons alcançar certas idades, vc pode ganhar items e até egg's, "IDADE MÁXIMA 30", Pode ser modificado)
      ¤ Evolution System
      (Modificado, seu pokemon pode ser evoluído pelo level usando um item de evolução que mostrarei logo mais nos prints, ou utilizando stone sem precisar de level)
      ¤ Pokeball's animadas
      ¤ Rare Candy para level e para idade
      ¤ Boost system
      (Temporariamente retirado para testes, talvez volte na v2)
      Bom estes são alguns dos sistemas, agora irei mostrar os sistemas tradicionais de todo servidor!
      ¤ Catch System - 100%
      ¤ Nurse - 100%
      ¤ 6 Balls diferentes - Normal ball, Super ball, Great ball, Ultra ball, Master ball e fresh ball
      ¤ Order system - 100% (Move, rock smash, dig, cut, fly, ride, surf ambos funcionando perfeitamente)
      ¤ Evoluções - 100%
      ¤ Pokemons Passivos e Agressivos - 100% (Demorou mais consegui rs')
      ¤ Mapa incompleto - somento uns 5 ou 10 % do mapa feito por mim ( Estava focado nas script's )
      ¤ Gender system - 100%
      ¤ Pokemons balanceados de acordo com o level e com seus determinados loot's e moves
      Acho que é isso se esqueci algo posto logo mais!
      Print's




      Erros-Bug's



      Créditos
      Lordbaxx - Sistemas, Scripts, codes, mapa - SERVER
      NextBr - Pelo sistema de idade no qual trabalhei
      Qualquer outro envolvido será creditado!
      DOWNLOAD's



      LEMBRANDO QUE AS SPRITES DOS POKEMONS SÃO DAS MAIS ANTIGAS ENTÃO SEM RECLAMAÇÕES POIS É UMA COISA SIMPLES DE SE FAZER!
      OBRIGADO VLW FLW
      att: LORDBAXX
    • Por Elitondeveloper
      Venho disponibilizar para vocês gratuitamente o servidor Alfa-Baiak, que atualmente está online com 250+ players.
      Algumas imagens em anexo!
      Totalmente Completo e de graça !!
      Façam bom proveito para seus projetos !!
       
      Informações
      Várias Quests
      4 sistemas de Vip
      1 donate
      hunts para level 620+
      Caves exclusivas
      novos itens!
      Muita jogabilidade
      Vocações balancedas
      Magias Balanceadas
      Sem Bugs
       
      Eventos
      Battle Field
      Capiture a Bandeira
      Defesa das torres
      Fire Storm
      Zombie Ataque
      SnowBall War
      War Anti-Entrosa
      Castle 24hrs
      Castle War

       Exp e Rates
      Exp inicial: 700x | (stages)
      Magic Rate: 10.0x |
      Skill Rate: 25.0x |
      Loot Rate: 8.0x
       
      Versão online para verificarem !
      Site: http://alfa-baiak.com/
      Ip: alfa-baiak.com
      Versão: 8.60
       
      Download: Download COMPLETO+SOURCE
      Scan: Virus total



       
      Créditos: Gabriel Correa
  • Estatísticas dos Fóruns

    96846
    Tópicos
    519603
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo