Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 19:57

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Queue System with Remove functionality

Discussion on Queue System with Remove functionality within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
Queue System with Remove functionality

So I guess this is slightly more appropriate for the programming section vs the pserver section.. problem is that the only place where it would be considered anything but basic knowledge and like 5 minutes of work would be in that section >.< (yay for lazy nubs who can't code at ALL)

May as well post it here though so here goes.


I was introduced fairly recently to the Queue system that C# has built into it.

What annoyed me was the inability to remove something prematurely from this queue. Unlike a dictionary you have no simple way to just toss out data you decide you don't need anymore. You have to handle it in the order it is added (which is the entire point of queue's I admit but there are many situations where you may want both)

So I wrote up a VERY simple wrapper for this.

So far it's just a few methods and a little bit of logic but it works perfectly for my server. Basically I am using it for my ground floor. Every time I drop an item I queue it up (to handle item timeout). Then if it gets looted before that I can use the .Remove(object) method so that it is no longer being spawned to people and I don't need to wait for the item floor thread to run through disposing all the previous objects dropped.

Works rather nicely so thought I'd share incase anyone else wanted it.

It's not obfuscated so feel free to mess around with the code (what tiny bit there is!)




The methods and usage is rather simple.... Add the dll reference to your server and then do using Queueing;

Then to use it just do something like..

Queueing.Queue Items = new Queueing.Queue();

You can then use the following methods...

Count: returns number of objects in the queue currently
Peek(): returns but does NOT remove the first object in the queue (next to be processed). Use for checks
Dequeue(): returns and removes the first object in queue (next to be processed)
Queue(object): adds the specified object to the END of the queue (LAST to be processed)
Remove(object): Removes the specified object from the queue regardless of its position.


Feel free to criticize and offer suggestions/improvements.

Also keep in mind you will want to only be storing one type of value in your queue and verify it before running checks.

Eg:
if(!(Items.Peek() is GroundItem))
return;

And convert it!
GroundItem I = (GroundItem)Items.Dequeue();

or

GroundItem I = Items.Dequeue() as GroundItem;
pro4never is offline  
Reply


Similar Threads Similar Threads
Queue system bugged :S
09/14/2009 - Silkroad Online - 3 Replies
guys this is really starting to annoy me, 3 days ago my premuim finished and i have been trying to log on to activate the new one... i havent got anywhere near logging in ! i open 4 clients, 3 with my main 1 with my staller, my staller goes in but my ain doesnt ! and it still keeps writing (requestion user confirmation)... when i check my netstat -n in the command promt it says that my main connects to server .29/.28 ... my staller connects to .68, my staller got in less that 1 hour :S ?...
Topic Queue System
08/09/2007 - CO2 Exploits, Hacks & Tools - 0 Replies
New feature as been implemented!Topic Queue system for all CO2 release sections! CO2 Socket Theories CO2 Guides & Templates CO2 Weapon, Armor, Effects & Interface edits CO2 Exploits, Hacks & Tools CO2 Scams CO2 Bots & MacrosMods & Globals get to look over all new threads first before approval is given. Please do not submit more than once on making of a new thread. After We approve the thread, it will come up.
Topic Queue System
08/09/2007 - CO2 Exploits, Hacks & Tools - 0 Replies
New feature as been implemented!Topic Queue system for all CO2 release sections! CO2 Socket Theories CO2 Guides & Templates CO2 Weapon, Armor, Effects & Interface edits CO2 Exploits, Hacks & Tools CO2 Scams CO2 Bots & MacrosMods & Globals get to look over all new threads first before approval is given. Please do not submit more than once on making of a new thread. After We approve the thread, it will come up.
Topic Queue System
08/09/2007 - CO2 Bots & Macros - 0 Replies
New feature as been implemented!Topic Queue system for all CO2 release sections! CO2 Socket Theories CO2 Guides & Templates CO2 Weapon, Armor, Effects & Interface edits CO2 Exploits, Hacks & Tools CO2 Scams CO2 Bots & MacrosMods & Globals get to look over all new threads first before approval is given. Please do not submit more than once on making of a new thread. After We approve the thread, it will come up.



All times are GMT +2. The time now is 19:57.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.