Register for your free account! | Forgot your password?

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

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

Advertisement



volatile directories and threading

Discussion on volatile directories and threading within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
volatile directories and threading

is it possible to run hunting loop at separate thread using volatile directories updating by main thread ?
forgive my ignorance i've never done this , is it the best way to get it done ? any information would be highly appreciated , have a great day
go for it is offline  
Old 05/25/2013, 20:13   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
I might be completely misunderstanding what your question is but what exactly are you trying to accomplish.

I see no reason to have multiple threads each handling one small portion of a hunting loop (targeting loop, attacking loop, looting loop etc should generally not be on their own threads but w/e)


Concurrent collections are incredibly useful for synchronizing data between multiple threads (EG: collection of monsters on screen which might be edited by a spawn packet while your bot code is iterating it for hunting)

Volatile objects as I understand them (haven't had a reason to use them much myself) force the compiler to get the most recently updated value every time which would make it very useful for variables accessed from multiple threads.


I think the real question is what are you doing for thread safety to start with? These are all very powerful tools but using them as an excuse to organize your threading poorly is just a crutch in my eyes.


PS: What is a 'volatile directory'? Volatile in C# is a keyword and does not relate to a directory in any way that I'm aware of.
pro4never is offline  
Thanks
1 User
Old 05/25/2013, 20:16   #3
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
What you might want to consider doing is locking parts that aren't thread safe (such as methods that rely on data structures or classes from .NET that aren't thread safe). Be very careful with locking though. That was a major problem in TrinityCO (and still is with the public version) - deadlocks (two or more actions are each waiting for the other to be executed). Use minimal locks (in a safe manor that won't cause deadlocks) and try relying on thread-safe data structures such as a Concurrent Dictionary from .NET's framework.
Spirited is offline  
Thanks
1 User
Old 05/25/2013, 20:49   #4
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
what i want to do is having a thread hunting while the main thread is updating my collections (monster coords , etc)
ill look up the Concurrent collections thanks pro4never
and thanks fang for the lock hint ill look it up too

edit : btw pro4never you was invoking delegates to update the gui packet textbox from the handlers class at proxyparadise , do you think this is the best way to do this or should i pass the gui instance throw ctor/custom method to the handlers class to update the gui on receiving packets ?
go for it is offline  
Old 05/25/2013, 22:04   #5
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
I'm always very bad with how I handle cross thread calls but I seem to remember that the 'correct' way to do it is delegates. Basically they let you pass a command to be executed on the target thread (in this case the GUI thread)


In your description you would have your packets being processed asynchronously which would update a concurrent collection (likely dictionary of uid/entity). You would then have a logic thread running through that collection to perform actions. Concurrent collections are perfect for this and nothing further is required from your side.



The alternative would be asynchronous packet receiving which places each packet into a ConcurrentQueue (incoming/outgoing queue of packets). You then have a single thread which manages everything related to that client and each loop it processes packets, updates objects and then performs bot actions. In this example there is no need for thread safe collections for the client's surroundings as ALL client logic is on one single thread. You still have to handle the original packet processing in a thread safe way but I think it might work best from a bot standpoint because you can easily control things like keeping the bot from flooding the server/client with packets.
pro4never is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
C++ Threading
03/01/2013 - C/C++ - 3 Replies
Ich habe da mal eine frage zu Threading in C++ Wie kann ich eine Thread Array starten? ich weiß das ich in C# es z.B. so machen kann:) Thread myThread; myThread= new myThread;
Threading
02/22/2013 - Nostale - 3 Replies
Hi!I have a question for what i need multithreading i developing game server.Soo i know that i need this for connection.
[WTS] Blutkessel - EU [H] Ore, Gems and Volatile!
05/14/2012 - World of Warcraft Trading - 0 Replies
Hi, I am selling a big amount of Ores, gems and volatile for good prices in the Blutkessel realm. If you are interested, add me on skype: brampower I can supply every day, as much as you want. I have several guild banks full - let me know! German: Hallo zusammen, Ich verkaufe eine große Menge an Erze, Edelsteine ​​und flüchtiges zu guten Preisen in Blutkessel. Wenn Sie interessiert sind, nehmen Sie mich über skype: brampower
Lock vs Volatile
08/16/2011 - CO2 Private Server - 10 Replies
What would be best to use in which situation? If you don't know what Volatile is: UnCommon C# keywords - A Look - CodeProject :D
Registry+different directories=WTF
12/19/2010 - Technical Support - 0 Replies
I made a program that uses the registry. It writes a string to the registry and reads it (and does a lot more, but that doesn't matter^^). If I start the program with debugging (from RAD Studio), everything is fine. If I start the program directly, problems start. The program writes the string to the registry (it's there!). When I delete the value in the registry via regedit and let the program try to read the string, my program tells me, that the value is still there. Another thing is: I put...



All times are GMT +1. The time now is 06:15.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.