• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X Shows how many tiles have in the house

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
16
How to make house shows how many tiles have onlook the door like this img?

dEl0Soz.png


my house.cpp: Fir3element/3777 (https://github.com/Fir3element/3777/blob/master/src/house.cpp)

I think it's here:
Code:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str());
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins.", tmp.c_str(), name.c_str(), tmp.c_str(), price);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}

But i have no idea how to make it done, is anyone can help?
 
C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    std::string tmp = "house";
    /*
    no isGuild method (atm)
    if(isGuild())
        tmp = "hall";
    */
    char houseDescription[200];
    const int32_t housePrice = g_config.getNumber(ConfigManager::HOUSE_PRICE);
    if(owner)
    {
        /*
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        */
        if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);
 
        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s.", tmp.c_str(), houseName.c_str(), _name.c_str(), tmp.c_str());
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %lu gold coins.", tmp.c_str(), houseName.c_str(), tmp.c_str(), ( housePrice != -1 ? (houseTiles.size() * housePrice) : 0 ) );
 
    for (const auto& it : doorSet) {
        it->setSpecialDescription(houseDescription);
    }
Try replace with this, I am not sure if it gonna work I have found on a brazil forum.
 
C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    std::string tmp = "house";
    /*
    no isGuild method (atm)
    if(isGuild())
        tmp = "hall";
    */
    char houseDescription[200];
    const int32_t housePrice = g_config.getNumber(ConfigManager::HOUSE_PRICE);
    if(owner)
    {
        /*
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        */
        if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s.", tmp.c_str(), houseName.c_str(), _name.c_str(), tmp.c_str());
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %lu gold coins.", tmp.c_str(), houseName.c_str(), tmp.c_str(), ( housePrice != -1 ? (houseTiles.size() * housePrice) : 0 ) );

    for (const auto& it : doorSet) {
        it->setSpecialDescription(houseDescription);
    }
Try replace with this, I am not sure if it gonna work I have found on a brazil forum.


TY BRO

but its showing some errors when compile:
Code:
house.cpp: In member function ‘void House::updateDoorDescription(std::__cxx11::string)’:
house.cpp:169:91: error: ‘houseName’ was not declared in this scope
         sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s.", tmp.c_str(), houseName.c_str(), _name.c_str(), tmp.c_str());
                                                                                           ^~~~~~~~~
house.cpp:172:120: error: ‘houseName’ was not declared in this scope
         sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %lu gold coins.", tmp.c_str(), houseName.c_str(), tmp.c_str(), ( housePrice != -1 ? (houseTiles.size() * housePrice) : 0 ) );
                                                                                                                        ^~~~~~~~~
house.cpp:174:16: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++11-compat]
     for (const auto& it : doorSet) {
                ^~~~
house.cpp:174:22: error: ISO C++ forbids declaration of ‘it’ with no type [-fpermissive]
     for (const auto& it : doorSet) {
                      ^~
house.cpp:174:27: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
     for (const auto& it : doorSet) {
                           ^~~~~~~
house.cpp:174:27: error: ‘doorSet’ was not declared in this scope
house.cpp:175:11: error: base operand of ‘->’ is not a pointer
         it->setSpecialDescription(houseDescription);
           ^~
Makefile:33: recipe for target 'house.o' failed
make: *** [house.o] Error 1
make: *** Waiting for unfinished jobs....

line 169:
Code:
sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s.", tmp.c_str(), houseName.c_str(), _name.c_str(), tmp.c_str());
 
It has house->getTilesCount() tiles.

I think house->getTilesCount() should be a global variable if not, set it as one and you will have the tiles count.
Alternatively you can take the price and divide it through config house price, should work aswell.

int32_t house_tiles = price / g_config.getBool(ConfigManager::HOUSE_RENTASPRICE);

C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getBool(ConfigManager::HOUSE_RENTASPRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %s tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %s tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}
 
It has house->getTilesCount() tiles.

I think house->getTilesCount() should be a global variable if not, set it as one and you will have the tiles count.
Alternatively you can take the price and divide it through config house price, should work aswell.

int32_t house_tiles = price / g_config.getBool(ConfigManager::HOUSE_RENTASPRICE);

C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getBool(ConfigManager::HOUSE_RENTASPRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %s tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %s tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}

My server isn't open, when start to load map, shows:
Code:
[16:0:47.049] >> Loading map and spawns...
[16:0:47.649] > Map size: 2548x2548.
[16:0:47.649] > Map descriptions: 
[16:0:47.649] "Saved with Remere's Map Editor 3.4"
[16:0:47.649] "No map description available."
Floating point exception

When compile shows this warnings:
Code:
house.cpp: In member function ‘void House::updateDoorDescription(std::__cxx11::string)’:
house.cpp:165:161: warning: format ‘%s’ expects argument of type ‘char*’, but argument 7 has type ‘int32_t {aka int}’ [-Wformat=]
         sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %s tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
                                                                                                                                                                 ^
house.cpp:168:181: warning: format ‘%s’ expects argument of type ‘char*’, but argument 7 has type ‘int32_t {aka int}’ [-Wformat=]
         sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %s tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);
                                                                                                                                                                                     ^
CC -o tfs

The only changes i have in my source pack is this
And this: TFS 0.X - Who cast the field/wall (https://otland.net/threads/who-cast-the-field-wall.263051/page-2)

It's not a map error, i tried the last compiled version and it opens well
 
Replace:
int32_t house_tiles = (price / g_config.getBool(ConfigManager::HOUSE_RENTASPRICE));
with:
int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));

Corrected code:
C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %s tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %s tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}
I was on mobile when I wrote that reply above. Not sure if its going to work tho it's expecting char, you can probably convert int32_t to char aswell.
 
Replace:
int32_t house_tiles = (price / g_config.getBool(ConfigManager::HOUSE_RENTASPRICE));
with:
int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));

Corrected code:
C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %s tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %s tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}
I was on mobile when I wrote that reply above. Not sure if its going to work tho it's expecting char, you can probably convert int32_t to char aswell.

Same thing :(
Code:
tfs build options:
g++ house.cpp
CXXFLAGS = -std=c++03 -Os -fomit-frame-pointer -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pipe -I/usr/include/libxml2 -I/usr/include/lua5.1 -I.   -DHAVE_CONFIG_H -D__USE_MYSQL__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT
LDFLAGS  = -s -llua5.1 -lmariadbclient -lcrypto -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp -lxml2 -pthread
CC       = g++
house.cpp: In member function ‘void House::updateDoorDescription(std::__cxx11::string)’:
house.cpp:165:161: warning: format ‘%s’ expects argument of type ‘char*’, but argument 7 has type ‘int32_t {aka int}’ [-Wformat=]
         sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %s tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
                                                                                                                                                                 ^
house.cpp:168:181: warning: format ‘%s’ expects argument of type ‘char*’, but argument 7 has type ‘int32_t {aka int}’ [-Wformat=]
         sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %s tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);
                                                                                                                                                                                     ^
CC -o tfs

Line 165 is: sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %s tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
 
Nobody's answering you because there's nothing else to do. You either didn't recompile or you didn't edit the code correctly, that code given is the ONLY spot in TFS where the door description is defined, if you change it correctly it will change ingame as well.
C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}
 
Nobody's answering you because there's nothing else to do. You either didn't recompile or you didn't edit the code correctly, that code given is the ONLY spot in TFS where the door description is defined, if you change it correctly it will change ingame as well.
C++:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}

Now i even tried to make clean and recompile again, same thing
Code:
13:25 You see a closed door. It belongs to house 'Unnamed House #1'. Nobody owns this house. It costs 3900000 gold coins.

I'm using the updateDoorDescription like u said in my house.cpp
Code:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}

Using this source pack, clean
 
Now i even tried to make clean and recompile again, same thing
Code:
13:25 You see a closed door. It belongs to house 'Unnamed House #1'. Nobody owns this house. It costs 3900000 gold coins.

I'm using the updateDoorDescription like u said in my house.cpp
Code:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}

Using this source pack, clean
bump
 
Now i even tried to make clean and recompile again, same thing
Code:
13:25 You see a closed door. It belongs to house 'Unnamed House #1'. Nobody owns this house. It costs 3900000 gold coins.

I'm using the updateDoorDescription like u said in my house.cpp
Code:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}

Using this source pack, clean

Same here
 
Back
Top