Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 11 Nov 2008
Offline Last Active Yesterday, 04:54 PM

Topics I've Started

Lake flow

22 June 2015 - 05:34 PM

I have created some lakes, some of which have rivers. These rivers flow out into other lakes, or sometimes out to the ocean (which I have represented as a lake). For the purpose of the graphical world making sense, I now need to raise these lakes so that when they flow, they flow downhill. I'm now stuck on the algorithm for determining the heights.



I always have a reference to the ocean.

I can traverse this graph of lakes in either direction, despite the rivers having a direction assigned.

A lake can have more than one river flowing in and/or out.

There are no cycles in this graph of lakes.

I can ignore any lakes that don't have rivers, or separate graphs of lakes/rivers that don't flow out to the ocean.

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.