Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Windows Servers

Support::Windows Servers Support forum for Windows EQEMu users.

Reply
 
Thread Tools Display Modes
  #1  
Old 02-11-2010, 10:50 AM
lich2594
Sarnak
 
Join Date: Jun 2006
Location: Tennessee, USA
Posts: 77
Default Group server code

I am working with the source and I am having an issue with finding out if two players are grouped. If anyone could point me in the right direction, I would be thankful.

What I am trying to do is find out if client 1's group is the same as clients 2's group, or if client 1 (or 2) is not in a group.

Here is what I have atm, that does not work.

int c1_group = c1->GetGroup()->GetID(); // Client 1's group
int c2_group = c2->GetGroup()->GetID(); // Client 2's group

((c1_group != c2_group) || (c1_group == 0) || (c2_group == 0)) // clients grouped?

Can anyone point out to me what is wrong? Thanks!
Reply With Quote
  #2  
Old 02-11-2010, 11:10 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

If either client is not in a group, that code will cause a crash because GetGroup() will return a NULL pointer.

This should work:
Code:
Group *g1 = c1->GetGroup();
Group *g2 = c2->GetGroup();

if(!g1 || !g2 || (g1 != g2)
{
        // One or both clients not in a group, or not in the same group
}
Reply With Quote
  #3  
Old 02-11-2010, 11:24 AM
lich2594
Sarnak
 
Join Date: Jun 2006
Location: Tennessee, USA
Posts: 77
Default

Thank you! That worked.

I had actually been struggling with that for some time now, haha.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 08:58 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3