• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Compiling Trying to add updateInventoryWeight(); but says protected.

Arcadius

Banned User
Joined
Sep 11, 2014
Messages
60
Reaction score
1
Location
Developing
I have fixed the ammunition conjure bug not removing capacity from the player, it will be addressed to the public distribution on Monday.
But if you would like to fix it yourself:

Make public void updateInventoryWeight();
In spells.cpp, add player->updateInventoryWeight();

At true results / success conjures at:

bool ConjureSpell::ConjureItem(const ConjureSpell* spell, Creature* creature, const std::string& param)

And at

ReturnValue ConjureSpell::internalConjureItem(Player* player, uint32_t conjureId, uint32_t conjureCount)

And at

ReturnValue ConjureSpell::internalConjureItem(Player* player, uint32_t conjureId,
uint32_t conjureCount, uint32_t reagentId, slots_t slot, bool test /*= false*/)

As @Schmanky said, I had fixed most of the bugs reported here in the first test server that was ran months ago, but the server is so big it's literally hard for me to maintain the code and changes from my partner, so it can sometimes mess up / remove bug fixes.


Im currently editing "bool ConjureSpell::ConjureItem(const ConjureSpell* spell, Creature* creature, const std::string& param)"
So I have edited line 1887 to add: player->updateInventoryWeight();
I get this error:

Code:
make[1]: Warning: File `spells.cpp' has modification time 38 s in the future
g++ -DHAVE_CONFIG_H -I.    -I/usr/include/libxml2  -I/usr/include/lua5.1    -D__USE_MYSQL__      -DSYSCONFDIR=\"/usr/local/etc\" -DPKGDATADIR=\"/usr/local/share/otserv\" -D_THREAD_SAFE -D__OLD_GUILD_SYSTEM__ -D_REENTRANT -Wall -g -O2 -MT spells.o -MD -MP -MF .deps/spells.Tpo -c -o spells.o spells.cpp
spells.cpp: In static member function ‘static bool ConjureSpell::ConjureItem(const ConjureSpell*, Creature*, const std::string&)’:
spells.cpp:1887: error: no matching function for call to ‘Player::updateInventoryWeight(ReturnValue)’
player.h:651: note: candidates are: void Player::updateInventoryWeight()
make[1]: *** [spells.o] Error 1


If I change to player->updateInventoryWeight(RET_NOERROR);
I get this error:
Code:
make[1]: Warning: File `spells.cpp' has modification time 37 s in the future
g++ -DHAVE_CONFIG_H -I.    -I/usr/include/libxml2  -I/usr/include/lua5.1    -D__USE_MYSQL__      -DSYSCONFDIR=\"/usr/local/etc\" -DPKGDATADIR=\"/usr/local/share/otserv\" -D_THREAD_SAFE -D__OLD_GUILD_SYSTEM__ -D_REENTRANT -Wall -g -O2 -MT spells.o -MD -MP -MF .deps/spells.Tpo -c -o spells.o spells.cpp
player.h: In static member function ‘static bool ConjureSpell::ConjureItem(const ConjureSpell*, Creature*, const std::string&)’:
player.h:651: error: ‘void Player::updateInventoryWeight()’ is protected
spells.cpp:1887: error: within this context
make[1]: *** [spells.o] Error 1


Any ideas how to fix?
 
Also where is the public board and protected board,

I have found
Code:
void Player::updateInventoryWeight()
{
    inventoryWeight = 0.00;

    if(!hasFlag(PlayerFlag_HasInfiniteCapacity)){
        for(int i = SLOT_FIRST; i < SLOT_LAST; ++i){
            Item* item = getInventoryItem((slots_t)i);
            if(item){
                inventoryWeight += item->getWeight();
            }
        }
    }
}

In player.cpp but I dont see how I should change this to make it public.

@Damc
Oh really? Same error after I change it to public void instead of just void.

Code:
spells.cpp:41: error: expected unqualified-id before ‘public’
player.h: In static member function ‘static bool ConjureSpell::ConjureItem(const ConjureSpell*, Creature*, const std::string&)’:
player.h:651: error: ‘void Player::updateInventoryWeight()’ is protected
spells.cpp:1935: error: within this context
make[1]: *** [spells.o] Error 1
make[1]: Leaving directory `/home/OTHire/source'
make: *** [all] Error 2

Again, I could be looking at the wrong spot so a more detailed response would be better than.

"It's in the quote" lol, I have cleared read the quote.
 
Last edited by a moderator:
@Damc, You are a god. To be honest, I ended up finding it before I read your post but still. You would have been the savior to the day!

I have now fixed the bug, everything works as it should and spells update player weight. Thanks for the help!
 
Back
Top