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

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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 09-23-2008, 05:18 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

I tried reorganising the code to work as you originally intended. This is totally untested.

Note that in the case where a connection is removed, I have put a continue; statement which will go back to the top of the while loop, as I don't believe you want to advance the iterator if you've just deleted an element.

Code:
void ClientList::GetCLEIP(int32 iIP) {

        ClientListEntry* countCLEIPs = 0;
        LinkedListIterator<ClientListEntry*> iterator(clientlist);

        int IPInstances = 0;
        iterator.Reset();

        while(iterator.MoreElements()) {

                countCLEIPs = iterator.GetData();

                // If the IP matches, and the connection admin status is below the exempt status,
                // or exempt status is less than 0 (no-one is exempt)

                if ((countCLEIPs->GetIP() == iIP) &&
                    ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) ||
                     (RuleI(World, ExemptMaxClientsStatus) < 0))) {

                        // Increment the occurences of this IP address

                        IPInstances++;

                        // If the number of connections exceeds the lower limit

                        if (IPInstances > (RuleI(World, MaxClientsPerIP))){

                                // If the Admin status of the connection is not eligible for the higher limit,
                                // or there is no higher limit (AddMaxClientStatus<0)

                                if ((countCLEIPs->Admin() < (RuleI(World, AddMaxClientsStatus)) ||
                                    (RuleI(World, AddMaxClientsStatus) < 0))) {

                                        // Remove the connection

                                        countCLEIPs->SetOnline(CLE_Status_Offline);
                                        iterator.RemoveCurrent();
                                        continue;

                                }
                                // else they are eligible for the higher limit, but if they exceed that

                                else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) {

                                        // Remove the connection

                                        countCLEIPs->SetOnline(CLE_Status_Offline);
                                        iterator.RemoveCurrent();
                                        continue;

                                }
                        }
                }
                iterator.Advance();
        }
}
Reply With Quote
 

Thread Tools
Display Modes

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 02:33 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