Jump to content

[SOLVED][C++] LPPARTY/CParty class and his ForEachOnlineMember() Method


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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 4

      Feeding game source to LLM

    2. 0

      Quest 6/7 Problem

    3. 5

      Effect weapons

    4. 0

      [C++] Fix Core Downer Using Negative Number in GM Codes

    5. 3

      Crystal Metinstone

    6. 4

      Feeding game source to LLM

    7. 113

      Ulthar SF V2 (TMP4 Base)

    8. 4

      Feeding game source to LLM

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.