Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

161 Neutral

About Scythen

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Quote:Original post by Quasimojo My concern is that over time, with players killing monsters and using items - both of which would re-spawn periodically - the game would exceed the limits of the data type I use. At the same time, minimizing the size of data packets being transferred back and forth with the server is an important factor. Perhaps 16-bytes wouldn't be too much overhead. Quote:Wikipedia : The total number of unique keys (2^128 or 3.4*10^38 - in relation there are about 1.33*10^50 atoms on earth) is so large that the probability of the same number being generated twice is extremely small, and certain techniques have been developed to help ensure that numbers are not duplicated. Dont worry, you will never run out of new unique Ids. If you use a virtual ID system you will probably need to transmit a 1 or 2 byte ID most of the time. Quote:Original post by Quasimojo Is there a platform-independent way to generate GUID's? Yes, you can create GUIDs on any platform. See the Boost Uuid library.
  2. A few things to keep in mind. Managing unique Ids is a pain in the ass, particularly if they are persistent. If it has to be unique go with a Guid you will save yourself a whole lot of work. Some Ids are persistent and must never be duplicated while other Ids are temporary and can be reused. For example a player account Id would be persistent but an NPC instance Id can be reused. Ids have domains and only have to be unique within their domain. For example persistent player account Ids must never collide with each other but there can be an item with the same Id value. Your code should never try to take a player Id and use it as an item Id. Ids also have scope. For example an Id that is scoped to a client connection can be used to identify different things to different clients. The fact that ids have domains is very useful when you're dealing with things like resource Ids. I always use string hash ids for resource ids. This may seem dangerous since hash values can collide but because resource Ids are broken up into domains like texture, sound, script, model, shader, etc. the chance of collision is extremely low (I think I've seen one in 10+ years of using them). A virtual player Id is a good example of a scoped Id. If you use a Guid for your player Id and you don't want to send that Id back and forth between your client and server you can negotiate a virtual Id that is only valid when communicating with that particular client. The Id is scoped to that client. For example when the client connects they send you a 128 bit player Guid (in the real world you probably don't want to send account and player ids to the client, is a security risk). In response the server sends the client a virtual 1 byte player Id. From that point on when that client wants to communicate the player Id to the server is uses the 1 byte virtual Id.
  3. Scythen

    Select vs Polling

    rip-off was right about almost everything. The only thing he got a little wrong was the UDP vs. TCP issue. If you need any type of reliability do not use a reliable UDP system. There are many, many reasons why this type of system will not perform as well as TCP. For one nowadays the internet is tuned for TCP traffic, many ISPs will drop UPD traffic in favor of TCP traffic when under high load (they can't drop TCP because that would cause all sorts of pain). Also, think about resends. A reliable UDP system has to resend all the way from the server to the client. TCP does this in hardware from each node along the way so if the failure is at the last hop, that's the only resend. If you're streaming data like audio or video then UDP is fine. Anything reliable should be TCP. One other thing, if you're going to do an IOCP based network layer, its best to adopt that from the beginning due to the concurrency issues. Trying to add a highly concurrent network layer at any other time is asking for problems. Concurrency requires a lot of forethought and good design.
  4. Scythen

    effective keep-alive?

    Unless you’re streaming video, audio or something else just use TCP. It’s secure, reliable, performs better and connection based so you don’t have to deal with keep-alive. Not to mention most of the hardware out there today is optimized for TCP traffic (hence the better performance, although the fact that ISPs tend to deprioritize UDP traffic plays a big role as well).
  5. Ok, that was just my two cents. Copying all the data may not be what you want and that’s fine but implementing a copy constructor is not the same as reimplementing the same function in every class. Generally when you will be copying objects you want copy constructors.
  6. After thinking about it what you really want is to define copy constructors for all your classes and then implement clone like this: public Base Clone() { object[] param = new object[] { this }; return System.Activator.CreateInstance(this.GetType(), param) as Base; }
  7. Not sure if it’s important or not but I don’t see how you’re Clone/Copy functions actually "Clone" the object. How does the base class correctly copy the data members in the derived classes? Your implementation only initializes data members declared in the base class.
  8. Scythen

    C Socket question!

    A thread per socket is probably best if you have 10 or less connections. if high performance is not an issue you can probably get away with a hundred or so connections this way. However, if you want to do it the right way you need to use asynchronous sockets, IOCP and thread pools (assuming this is Windows). This will let you handle tens of thousands of connections efficiently. I will say you need to be an experienced programmer with a good understanding of concurrent systems to implement the IOCP based server. If you’re just starting out a thread per socket is going to be much easier to deal with. If you have no experience with threads and scalability is not an issue then go with blocking sockets and use select.
  9. Quote:Original post by bzroom What i meant by "bogus" was "completely obfuscated and unsuitable for a beginner." Hmmm, that’s not what bogus means. Bogus: not genuine; counterfeit; spurious; sham Personally I think it’s easier to see what’s going on with distilled version of the equation. Just my opinion but when I started learning this trying to see what was actually happening was often obfuscated by linear algebra when simpler equations were far easier to understand.
  10. Scythen

    Lockless FIFO Queue Implementation

    Concurrency is prety much where its at today. A few searches over at M$ or Dr.Dobbs should provide plenty of information. For a good Queue implementation take a look here: Measuring Parallel Performance: Optimizing a Concurrent Queue
  11. If you’re trying to implement a spinlock you don’t want a sleep or anything else that will relinquish the rest of the threads time quantum. The point of a spin lock is to reduce the number of context switches. You use a spin lock when you know that the operation you’re waiting for will likely complete in less time than a threads quantum. This way the thread spins for a short amount of time and then continues to execute rather than going to sleep and causing a context switch. Spinlocks are pretty useless on single core machines since the only way for the thread that’s blocking the spinning thread to execute is for the spinning thread to be switched out. On multicore machines spinlocks are pretty good for protecting small pieces of code that execute in a small number of cycles.
  12. Scythen

    Scene Graph

    Updating everything can be VERY costly if you have tens of thousands of objects in your graph. Generally you want to traverse the graph as little as possible, linked data structures are CPU cache killers. Touch as few objects per frame as possible. I’ve dealt with updates like this in a few ways, the most efficient seems to be keeping separate “dirty” lists of objects that must be updated each frame. Additionally you will probably want to differentiate between dirty visible objects and dirty non-visible objects. Some things only need to be updated when an they are visible while others have to be updated regardless(typically things that affect visibility).
  13. Scythen

    Looking for source control software

    Perforce is the way to go. I’ve used Source Save, CVS, SVN, ClearCase and some others that I don’t recall the name of at the moment and Perforce is hands down the best solution out there today. No idea where you got the idea that it’s buggy, particularly "extremely" buggy. That’s about as far from the truth as you can get. My experience with it over the past 8+ years is that it’s "extremely" stable. Probably more stable than the OS it’s running on. Not sure what the language has to do with the SCM but p4 should do the job.
  14. Scythen

    How to map a triangle to a circle?

    Ummm... Yea that helps!!! At least I was close. Thanks very much!
  15. Scythen

    How to map a triangle to a circle?

    Ok, while mapping the point from the triangle to the circle is fine going the other way is not. My test app is here test app if anyone cares to look. Maybe some sleep will help [dead]
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!