• 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!

C++ Same problem at this guy on compile 0.4 with pingfunction

ezeriel

New Member
Joined
Feb 26, 2017
Messages
12
Reaction score
1
I'm trying to add the same ping function at this guy from this topic:
Compiling - Help to add ping functions on 0.4

On 0.4...
He fixed, but i'm not...

My folders:
luascript.cpp
hastebin

luascript.h
hastebin

protocolgame.h
hastebin

Errors at compile:
Code:
In file included from player.h:33:0,
                 from party.h:20,
                 from chat.h:24,
                 from chat.cpp:18:
protocolgame.h:209:8: error: ‘void ProtocolGame::sendPing()’ cannot be overloaded
   void sendPing();
        ^
In file included from player.h:33:0,
                 from party.h:20,
                 from chat.h:24,
                 from chat.cpp:18:
protocolgame.h:76:8: error: with ‘void ProtocolGame::sendPing()’
   void sendPing(); // Xeraphus
        ^
In file included from player.h:33:0,
                 from actions.cpp:23:
protocolgame.h:209:8: error: ‘void ProtocolGame::sendPing()’ cannot be overloaded
   void sendPing();
        ^
In file included from player.h:33:0,
                 from actions.cpp:23:
protocolgame.h:76:8: error: with ‘void ProtocolGame::sendPing()’
   void sendPing(); // Xeraphus
        ^
In file included from player.h:33:0,
                 from house.h:27,
                 from beds.cpp:20:
protocolgame.h:209:8: error: ‘void ProtocolGame::sendPing()’ cannot be overloaded
   void sendPing();
        ^
In file included from player.h:33:0,
                 from house.h:27,
                 from beds.cpp:20:
protocolgame.h:76:8: error: with ‘void ProtocolGame::sendPing()’
   void sendPing(); // Xeraphus
        ^
Makefile:547: recipe for target 'chat.o' failed
 
Solution
luascript.cpp:
hastebin

Code:
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10194:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   client->sendPing();
                     ^
mv -f .deps/map.Tpo .deps/map.Po

protocolgame.cpp:
hastebin

Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2972:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() &&...
Look at line 76 and line 209, remove one of them.
Overload = you try to load another function with the same name as another one, in this case you probbly added one while fixing it but forgot to remove the other one.
 
Look at line 76 and line 209, remove one of them.
Overload = you try to load another function with the same name as another one, in this case you probbly added one while fixing it but forgot to remove the other one.

Oh man thank you so much!
You was mean to remove:

void sendPing();

To line 209, of hastebin
Right?

Because i removed, but now there is a new error when compile:
Code:
player.cpp: In member function ‘virtual bool Player::onDeath()’:
player.cpp:2309:25: error: ‘lexical_cast’ is not a member of ‘boost’
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfai
                         ^
player.cpp:2309:56: error: expected primary-expression before ‘>’ token
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfai
                                                        ^
Makefile:547: recipe for target 'player.o' failed

player.cpp
hastebin
 
Oh man thank you so much!
You was mean to remove:

void sendPing();

To line 209, of hastebin
Right?

Because i removed, but now there is a new error when compile:
Code:
player.cpp: In member function ‘virtual bool Player::onDeath()’:
player.cpp:2309:25: error: ‘lexical_cast’ is not a member of ‘boost’
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfai
                         ^
player.cpp:2309:56: error: expected primary-expression before ‘>’ token
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfai
                                                        ^
Makefile:547: recipe for target 'player.o' failed

player.cpp
hastebin

Yes, most likely your compiler stopped at the first critical error, now it will continue till you don't have any more errors :p
Not sure if you even got boost, but try this: hastebin
Otherwise try to replace this;
C++:
setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)));

With this;
C++:
setStorage(665, std::stoi(static_cast<int>(unfairFightReduction)));
 
Yes, most likely your compiler stopped at the first critical error, now it will continue till you don't have any more errors :p
Not sure if you even got boost, but try this: hastebin
Otherwise try to replace this;
C++:
setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)));

With this;
C++:
setStorage(665, std::stoi(static_cast<int>(unfairFightReduction)));

Using your player.cpp show me this warning errors:
Code:
player.cpp: In member function ‘void Player::manageAccount(const string&)’:
player.cpp:4908:27: warning: iteration 11u invokes undefined behavior [-Waggressive-loop-optimizations]
       talkState[i] = false;
                           ^
player.cpp:4907:26: note: containing loop
      for(int8_t i = 2; i <= 14; i++)
                          ^

To fix it... is just change:
Code:
                   for(int8_t i = 2; i <= 14; i++)
                       talkState[i] = false;

To

Code:
                   for(int8_t i = 2; i <= 14; i++) { talkState[i] = false; }

???

If it is the way, how can i recompile it to check?
 
Using your player.cpp show me this warning errors:
Code:
player.cpp: In member function ‘void Player::manageAccount(const string&)’:
player.cpp:4908:27: warning: iteration 11u invokes undefined behavior [-Waggressive-loop-optimizations]
       talkState[i] = false;
                           ^
player.cpp:4907:26: note: containing loop
      for(int8_t i = 2; i <= 14; i++)
                          ^

To fix it... is just change:
Code:
                   for(int8_t i = 2; i <= 14; i++)
                       talkState[i] = false;

To

Code:
                   for(int8_t i = 2; i <= 14; i++) { talkState[i] = false; }

???

If it is the way, how can i recompile it to check?

No you didn't change anything except make it one line and added curlies.
Lua - Is possible check sharing exp
Try that

A tip is to serach for the errors you find, most likely someone else had it and can help with finding the bug, seeing as we all share pretty much the same source code.
 
No you didn't change anything except make it one line and added curlies.
Lua - Is possible check sharing exp
Try that

A tip is to serach for the errors you find, most likely someone else had it and can help with finding the bug, seeing as we all share pretty much the same source code.

luascript.cpp:
hastebin

Code:
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10194:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   client->sendPing();
                     ^
mv -f .deps/map.Tpo .deps/map.Po

protocolgame.cpp:
hastebin

Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2972:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
                                                                                                                                                              ^

Should i change:
Code:
if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
	msg->put<uint16_t>(speaker->getPlayerInfo(PLAYERINFO_LEVEL));

To:
Code:
if(((speaker && type) != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && (pg == NULL || pg != NULL && !pg->getIsCast()))
	msg->put<uint16_t>(speaker->getPlayerInfo(PLAYERINFO_LEVEL));

Or its stuppid? Sorry i do not know about C++, i just want my sourcecode working fine with ping functions to make save my players from kicks and DDOS

Sorry to disturb you with more one question and thanks a lot to help me since here
 
luascript.cpp:
hastebin

Code:
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10194:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   client->sendPing();
                     ^
mv -f .deps/map.Tpo .deps/map.Po

protocolgame.cpp:
hastebin

Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2972:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
                                                                                                                                                              ^

Should i change:
Code:
if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
    msg->put<uint16_t>(speaker->getPlayerInfo(PLAYERINFO_LEVEL));

To:
Code:
if(((speaker && type) != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && (pg == NULL || pg != NULL && !pg->getIsCast()))
    msg->put<uint16_t>(speaker->getPlayerInfo(PLAYERINFO_LEVEL));

Or its stuppid? Sorry i do not know about C++, i just want my sourcecode working fine with ping functions to make save my players from kicks and DDOS

Sorry to disturb you with more one question and thanks a lot to help me since here

Luascript.cpp -> hastebin

Protocolgame is just a warning, to make the code look cleaner, either add parentheses around that part of the if statment or ignore it.
 
Solution
Luascript.cpp -> hastebin

Protocolgame is just a warning, to make the code look cleaner, either add parentheses around that part of the if statment or ignore it.

Thank you to everything...
If anotherone guy check this post, now you can add ping functions to create scripts about ping on LUA in a 0.4 sourcepack
Thanks to you...

Did you know how to make that parentheses to stop that warnings?
 
Thank you to everything...
If anotherone guy check this post, now you can add ping functions to create scripts about ping on LUA in a 0.4 sourcepack
Thanks to you...

Did you know how to make that parentheses to stop that warnings?

I guess this could do it?
C++:
if(speaker && (type != SPEAK_RVR_ANSWER ) && (!speaker->isAccountManager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && (pg == NULL || pg != NULL && !pg->getIsCast()))
 
I guess this could do it?
C++:
if(speaker && (type != SPEAK_RVR_ANSWER ) && (!speaker->isAccountManager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && (pg == NULL || pg != NULL && !pg->getIsCast()))

Still warning
Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2972:165: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 ustomFlag(PlayerCustomFlag_HideLevel)) && (pg == NULL || pg != NULL && !pg->get
                                                                     ^
 
C++:
if(speaker && (type != SPEAK_RVR_ANSWER ) && (!speaker->isAccountManager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg == NULL) || (pg != NULL) && (!pg->getIsCast())))
 
C++:
if(speaker && (type != SPEAK_RVR_ANSWER ) && (!speaker->isAccountManager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg == NULL) || (pg != NULL) && (!pg->getIsCast())))

Still warning
Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2972:169: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 mFlag(PlayerCustomFlag_HideLevel)) && ((pg == NULL) || (pg != NULL) && (!pg->ge
                                                                     ^
 
C++:
if((speaker && (type != SPEAK_RVR_ANSWER ) && (!speaker->isAccountManager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg == NULL)) || ((pg != NULL) && (!pg->getIsCast()))))
 
C++:
if((speaker && (type != SPEAK_RVR_ANSWER ) && (!speaker->isAccountManager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg == NULL)) || ((pg != NULL) && (!pg->getIsCast()))))

Again
Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2972:137: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 Manager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg ==
                                                                     ^

I thought just me had problem to fix this warning but its not too easy... XD
A lot || && its hard to know the right sintaxy
 
Again
Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2972:137: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 Manager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg ==
                                                                     ^

I thought just me had problem to fix this warning but its not too easy... XD
A lot || && its hard to know the right sintaxy

I got no ide why it's throwing that error, try to clean the solution and see if it changes, otherwise just ignore it.
I can't see where we should add more parentheses unless we add 500 more around every character :p
 
I got no ide why it's throwing that error, try to clean the solution and see if it changes, otherwise just ignore it.
I can't see where we should add more parentheses unless we add 500 more around every character :p

How to clean the solution?
 
Back
Top