Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


viper110110

Member Since 11 Nov 2008
Offline Last Active Apr 29 2015 04:31 PM

Topics I've Started

C# static interface or lack thereof

20 December 2014 - 12:04 PM

So I've found myself in a situation in which I either want to add a static member to an interface or create a static interface for my class to implement. Research has shown that this isn't a thing you can do in C# because it violates the concept of OOP. The problem I'm having is trying to find a replacement.

 

I have a generic data structure that I'm trying to turn into bytes to send/receive. The data structure is written and works with the generic type T, but now I am trying to add the construction/destruction from bytes. I looked into generic interfaces and came up with something like

public class HeirTree<T> where T : IEdible<T>
    { /*implementation*/ }


public interface IEdible<T>
    {
        byte[] GetBytes();
    }

public struct RobotPartPair : IEdible<RobotPartPair>
{ /*implements GetBytes*/}

This guarantees that whatever T is, I can call GetBytes on it. Now I want to create a FromBytes, but it only makes sense that it should be a constructor or a static method that returns the object. I see how this violates OOP because IEdible is not a concrete class and could be any inheriting class, but the fact that I'm using a generic T and that T will always be a concrete class should work around that. What would be the right solution here?

 

Ideally the entire HeirTree class has a method GetAsBytes() that returns the tree and all items inside it as an array of bytes, then has a static FromBytes or a constructor taking a byte array that can reverse an array of bytes into a tree.

 

Also every node in the tree is also a tree.


Choosing a port

07 October 2014 - 10:40 AM

I am trying to do a client/server setup and naturally I had to choose a port for each of them. The server one has been fine but the client one has given me trouble on several occasions. I get the exception:

 

SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted.

 
I understand that the port has been taken, but every time I end up googling the port I was using I end up finding some obscure thing that happened to be running while trying to run my game. Rather than trying new random ports every time this happens, is there a sure way to find myself a port that won't be used for anything? Any of the lists I can find of used ports always seem to show my ports as unassigned.
 
Alternatively, would it be a good idea to, in code, try a random port until I get one that works?

DXT Compressor Type performance

08 November 2013 - 02:19 PM

I am trying to shrink down a large texture which is currently saved as R8G8B8A8. If I shrink it by saving as R8G8B8 my loader won't load it. I am now trying to save as DXT1 and Paint.net gives me options for Compressor Type. It gives me 3 options rated fast to slowest. Obviously it will take longer to save the slowest one, but will it hurt performance in game?

 

The options from fast to slow, and low quality to high quality are:

Range fit

Cluster fit

Iterative fit


Heightmap steps

05 November 2013 - 10:42 AM

I have an issue with my heightmap where any gentle slopes aren't saved with enough detail to reproduce the same gentle slope. Since its only greyscalemy range is 0-255. When it goes across several pixels to drop down, it creates a staircase type effect where it is flat and then drops suddenly to the next level. I can't really decrease my vertical scale since I want the mountains to be high enough, and I don't know what tool I can use to create a 24 or 32 bit heightmap. I also don't have time to make my own. Is there a way in code to smooth it out? I was thinking about influencing each point by the ones near it.


Template content manager in c++

24 October 2013 - 06:32 PM

I am trying to write a content manager for my game. It will load files from the drive, or if the file has been requested before, it will return the same data without loading it from the drive again. When I think about the way the content manager works in XNA, you have to specify the type of content you want to load as a templated type. My question is what happens to the backing storage solution when I template different types of content? I just want to have to create one ContentManager instance, but have it Load<>() multiple types of data. I am confused as to how to do this.

 

My understanding of templates is that, if I just template the function, it will create multiple copies of the function for each type I use. I am just confused as to how this affects the storage as I will need to insert and get data of the type of the function.


PARTNERS