Compiling tfs 0.4

Okke

Voidcore 7.4
Joined
Jul 19, 2015
Messages
938
Best answers
20
Reaction score
454
Location
germany
Hello Sir Sezago,

throw us the code here so we can check it out and maybe fix it for you, I'd rather make you think a little and solve your problem yourself.

There are different ways to solve this, it depends on the way you want to store information, if you want to go byte by byte, let's put it this way:
C++:
int32_t x=sirSezagoRandomValue;
char *ptr = (char*)&x;
char *msg = new char[5];
for(int i=0;i<4;++i, ++ptr)
    msg[i] = *ptr;
If you want to store it digit by digit instead:

C++:
int32_t x=sirSezagoRandomValue;
int digs[5], count=0;
char *msg = new char[5];
while(x>0)
{
     digs[count++]=x%10;
     x/=10;
}
int i=0;
while(count--)
{
     msg[i++] = digs[count] +'0';
}
I hope you can fix it yourself, anyways if you don't think you can, provide us the code :)

Best Wishes,
Okke
 
OP
Sir Sezago

Sir Sezago

Scripter/Developer
Joined
Aug 28, 2017
Messages
274
Best answers
0
Reaction score
16
Hello Sir Sezago,

throw us the code here so we can check it out and maybe fix it for you, I'd rather make you think a little and solve your problem yourself.

There are different ways to solve this, it depends on the way you want to store information, if you want to go byte by byte, let's put it this way:
C++:
int32_t x=sirSezagoRandomValue;
char *ptr = (char*)&x;
char *msg = new char[5];
for(int i=0;i<4;++i, ++ptr)
    msg[i] = *ptr;
If you want to store it digit by digit instead:

C++:
int32_t x=sirSezagoRandomValue;
int digs[5], count=0;
char *msg = new char[5];
while(x>0)
{
     digs[count++]=x%10;
     x/=10;
}
int i=0;
while(count--)
{
     msg[i++] = digs[count] +'0';
}
I hope you can fix it yourself, anyways if you don't think you can, provide us the code :)

Best Wishes,
Okke
//////////////////////////////////////////////////////////////////////// // Ope - Pastebin.com the code i don't under stand what u already said but the error in setstorage in the mount system
 

Gesior.pl

Mega Noob&LOL 2012
Joined
Sep 18, 2007
Messages
2,031
Best answers
19
Reaction score
1,087
Location
PLand
This error is probably, because you copied code from some server that use 'int' storage keys (all servers except 0.4) and TFS 0.4 has 'string' storage keys.
These functions should work:
PHP:
bool Player::tameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(getStorage(keyString, tmp))
    {
        value = atoi(tmp.c_str());
        value |= (int32_t)pow(2., mountId % 31);
    }
    else
        value = (int32_t)pow(2., mountId % 31);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}

bool Player::untameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(!getStorage(keyString, tmp))
        return true;

    value = atoi(tmp.c_str());
    value ^= (int32_t)std::pow(2., mountId % 31);

    Mount* mount = Mounts::getInstance()->getMountByCid(defaultOutfit.lookMount);
    if(mount->getId() == (mountId + 1))
        dismount(true);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}
 
OP
Sir Sezago

Sir Sezago

Scripter/Developer
Joined
Aug 28, 2017
Messages
274
Best answers
0
Reaction score
16
This error is probably, because you copied code from some server that use 'int' storage keys (all servers except 0.4) and TFS 0.4 has 'string' storage keys.
These functions should work:
PHP:
bool Player::tameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(getStorage(keyString, tmp))
    {
        value = atoi(tmp.c_str());
        value |= (int32_t)pow(2., mountId % 31);
    }
    else
        value = (int32_t)pow(2., mountId % 31);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}

bool Player::untameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(!getStorage(keyString, tmp))
        return true;

    value = atoi(tmp.c_str());
    value ^= (int32_t)std::pow(2., mountId % 31);

    Mount* mount = Mounts::getInstance()->getMountByCid(defaultOutfit.lookMount);
    if(mount->getId() == (mountId + 1))
        dismount(true);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}
i got other error bro .. bug exxx.PNG
 
OP
Sir Sezago

Sir Sezago

Scripter/Developer
Joined
Aug 28, 2017
Messages
274
Best answers
0
Reaction score
16
In DevCpp (screen looks like DevCpp) it was 'Rebuild all' or something like that. To compile all files again. You must do it everytime you change something in any .h file.
already done it and still get same error ..
 
OP
Sir Sezago

Sir Sezago

Scripter/Developer
Joined
Aug 28, 2017
Messages
274
Best answers
0
Reaction score
16
In DevCpp (screen looks like DevCpp) it was 'Rebuild all' or something like that. To compile all files again. You must do it everytime you change something in any .h file.
Remember this error bro i Found what is the cause of this error
when i add this Code in TheforgottenServer.Dev it doesn't Import Mounts.h/ mounts.cpp
Code:
[Unit158]
FileName=..\mounts.cpp
CompileCpp=1
Folder=TheForgottenServer
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit159]
FileName=..\mounts.h
CompileCpp=1
Folder=TheForgottenServer
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
after adding it it should add active mounts .h / cpp but it compiling normal...
 
Top