Jump to content

Recommended Posts

Hello guys!

To start I'd like to apologize for my bad english; sooner or later I'll improve it :D

I'm not new to C++ but I never played much with metin2 server sources.
Yesterday I was developing a little script in game/party.cpp, in the end of the function "void CParty::P2PJoin(DWORD)", where I need to store all party's Players ID.

I get an error on a CParty method: "no matching function for call to 'CParty::ForEachOnlineMember(CParty::P2PJoin(DWORD)::FPartyPIDCollector&, long int)'";

It's like I wouldn't initialized that function but I already included the header "party.h", where that (public) method is declared in the CParty class as "template <class Func> void ForEachOnlineMember(Func & f);" and where it is also defined as follow:

template <class Func> void CParty::ForEachOnlineMember(Func & f)

	{

	   TMemberMap::iterator it;
   for (it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
     if (it->second.pCharacter)
       f(it->second.pCharacter);
}


The critical section of my code is...

[...]
	LPCHARACTER leader = CHARACTER_MANAGER::instance().FindByPID(pid);

	if (leader && leader->GetDesc())

	 {

	   LPPARTY pParty = leader->GetParty();

	   if (pParty) {

	        struct FPartyPIDCollector // <- thanks to "Dash" @metin2dev.org for this struct

	         {

	         std::vector <DWORD> vecPIDs;

	         FPartyPIDCollector() {}

	         void operator () (LPCHARACTER ch)

	         {

	             vecPIDs.push_back(ch->GetPlayerID());

	         }

	         };

	        FPartyPIDCollector f;

	        pParty->ForEachOnlineMember(f);
    [...]
   }
  [...]
}


I'm almost sure that it's just a noobs thing, but I really can't understand what's the reason of this error u.u
Maybe are there differences between CParty and LPPARTY?



Best regards,
Erich

Wow @.Devil., you're right! That's the error! Thank you!
But I always wrote nested functions, why does not this works?
(just for my knowledge, it works fine declaring the struct in the global scope)


[Post scriptum: anyway thanks to @arves100 for his help too!]

Because not all compiler works with them nested. You can't, anyway, make a function inside another function (I've write this in the previous post but I was referring to local classes/structs).. For example with C++98 you can call/declare struct/classes only from the function where they are declared (but not as argument for another function, like you did). 

  • Love 1

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.