Click here to Skip to main content
14,977,821 members

Comments by Yvar Birx (Top 117 by date)

Yvar Birx 1-Nov-13 11:22am View
I'll send you a private messaging holding my Skype and Email. ;)
Yvar Birx 1-Nov-13 10:20am View
Thank you for your concern. This is actually helpful to know. (:
Yvar Birx 1-Nov-13 10:18am View
Hey Sergey,

I'd love to discuss these matters via a private messenger(If possible Skype, and or Email) as I'm not going to spew my ideas over Codeproject(with that also my code as I know some people over here copy my code and claim their rights).

So if you are still interested please let me know somehow. :)

- Yvar
Yvar Birx 26-Oct-13 20:48pm View
Cheers Sergey!

By using the Client stream instead of the new memory stream I am able to do this without errors. Once again, thank you for your help!

- Dimitri Nostalgia
Yvar Birx 26-Oct-13 20:37pm View
Yes, yes I have. Let me try your suggestion and use the clientstream. :)
Yvar Birx 3-May-13 20:40pm View
Once again, lovely solution. :)
Yvar Birx 3-May-13 20:37pm View
Also, I was wondering how I would host this "Website", as it needs a few bytes here and there for saving the shortened URLs.
Yvar Birx 3-May-13 18:51pm View
Much obliged!
Yvar Birx 3-May-13 18:34pm View
And then rounding 0.75 up would equal to one? Even if it's just more than 0.5?
Yvar Birx 3-May-13 18:32pm View
Sorry for the abs, I had a negative number inside it like a few seconds ago.
Yvar Birx 3-May-13 18:31pm View
15 / 20 = 0.75
Yvar Birx 3-May-13 18:31pm View
Okay, so let's suppose everything is positive.
Why does (15) return as 0?

int Value = (int)Math.Ceiling((double)(Math.Abs(15) / 20));
Yvar Birx 3-May-13 17:50pm View
Yvar Birx 3-May-13 17:23pm View
if (Number > 0)
Number = Math.Ceiling(Number );
Number = Math.Floor(Number );
Yvar Birx 3-May-13 17:18pm View
-16 returns to 0?

-16 / 20 = -0.8?
Yvar Birx 2-May-13 16:48pm View
Logic error? I just said I am suppose to get negative values. However when I hover over a negative value, the value returns positive. ::
Yvar Birx 1-May-13 10:03am View
I also have every block in the positive not in the negative, I convert the negative to positive with Math.Abs.
Yvar Birx 1-May-13 9:52am View

-- 5 / 1 = 5.
-- -5 / 1 = -5
Yvar Birx 1-May-13 4:52am View
Anyone else? :L
Yvar Birx 30-Apr-13 19:26pm View
Interesting answer though. I tried it, and I feel like it's something like that causing the bug. Because whenever I select it on the left side(- side) it puts it on the right side but in the exact opposite way.
Yvar Birx 30-Apr-13 19:07pm View
Well, I thought that as-well. But, the chunks have a cooardinate that be negative, however the blocks should be more than 0 and less then the size of the chunk.
Yvar Birx 30-Apr-13 18:31pm View
Indeed, I flagged it and hope a Moderator will take care of it.
Yvar Birx 30-Apr-13 18:13pm View
Yvar Birx 30-Apr-13 18:10pm View
Why don't you go ahead and loop through the items of the items you are looping through too? I mean, from this point of view, hiding a master item would make you unable to look at the subitems, right? Good work once again SA.
Yvar Birx 30-Apr-13 18:07pm View
Edit: The error I am having is that whenever I click on a location or a chunk that has a minus cooardinate, it simply won't place the block correctly, however when these values are not in the minus, it does everything I want it to.
Yvar Birx 27-Apr-13 15:18pm View
So I decided to check the Noise class, and there seems to be no problem there. It has to be the if statements, but there is absolutely nothing wrong with it.
Yvar Birx 27-Apr-13 15:16pm View
"The conditional-AND operator"? Now here comes the best part, before I modified the nose points, it used to work fine.
Yvar Birx 27-Apr-13 15:10pm View
It is an array with points, which should generate the level, however the value return from f / 10 is perfect, only it gets filled in like it's Chunk.ChunkHeight. Very odd.
Yvar Birx 27-Apr-13 15:09pm View
I'm sorry. Here, I'll print it out:
Yvar Birx 9-Apr-13 17:46pm View
Problem got resolved by a work around. Thanks everyone for the help!
Yvar Birx 9-Apr-13 17:39pm View
1. Resolved that, issue stil exists.
2. Yes, as I said in my topic, I did it to see if that was the problem.
Yvar Birx 9-Apr-13 17:36pm View
No thanks. Switches do not work.
Yvar Birx 9-Apr-13 17:17pm View
I did that on purpose, because when I do not do it the error is still there. Thanks for your contribution though. :)
Yvar Birx 9-Apr-13 16:54pm View
No luck, I'll post the full code though.
Yvar Birx 9-Apr-13 16:53pm View
Oh, well, if it's less than zero it would just be stone. This might be a good thing to check however. Maybe I can change some of this code to that, because that seems to work.
Yvar Birx 8-Apr-13 16:19pm View
I can not change "Chunks", as it can not be accessed from another thread it hasn't been created on.
Yvar Birx 8-Apr-13 14:44pm View
So, let's assume I will make a variable:
public Chunk[] Chunks;

I could set it via:

public void ReloadChunks()
Chunks = new Chunk[9];
Yvar Birx 8-Apr-13 10:39am View
"ReloadChunks". Access is related to being static. Let's suppose you make a public integer, you can NOT access it via another thread.
Yvar Birx 8-Apr-13 10:35am View
Thanks a lot for your answer. The thing is, they should not be static as it's actually a void I used to use without a thread, but now it's a thread I can not access the variables.
Yvar Birx 8-Apr-13 10:33am View
I did the exact same in the previous thread, however I did not start like this. These "professional" coders do not see that a thread error is not a variable error or question.
Yvar Birx 4-Apr-13 9:00am View
I got it fixed. :P
Yvar Birx 4-Apr-13 8:59am View
I got it fixed, I'm sorry. I was using Point[] instead of ReturnPoint.

Thanks :)
Yvar Birx 4-Apr-13 8:46am View
Double arrays do not really have to be initialized, when they are declared they will all have the state of 0. And this is confusing because it is saying it's null. O.o
Yvar Birx 4-Apr-13 8:41am View
" // -- Strangly, this is the error.
ReturnPoints[i] = rd.Next(0, (int)Points[i - 1]);

Well, I am stuck because I need these points to be generated.
Yvar Birx 3-Apr-13 16:10pm View
Very helpful, as always. Thanks! :)
Yvar Birx 3-Apr-13 16:02pm View
Perfect, I after a few days of Googling never saw this one. :(
Thanks a lot!
Yvar Birx 31-Mar-13 17:02pm View
Okay, whatever seems to be the problem it's not the random, I will do some research in my code, I thank you all for the help.
Yvar Birx 31-Mar-13 15:55pm View
How unfortunate that it didn't. :L
Yvar Birx 31-Mar-13 15:34pm View
Chunk.ChunkY is the cooardinate of the Chunk, this is a way for me to only generate below the walking level, it's a bit like Flatgrass in Minecraft really. Oh, yeh, I am, I always forget about the fact that everything starts at zero not at one, however, the fact that the chunks are being generated like this:

Has nothing to do with any of that. :L

Also, the colors are pretty much squares (32*32), which all show another chunk. So, you can see that the blocks are not random and I don't understand why.
Yvar Birx 31-Mar-13 15:10pm View
Oh yeah, also,

The different colors are the blocks in the chunks, as you can see there are three different chunks yet they all have the same block.
Yvar Birx 31-Mar-13 15:07pm View
Funnily enough I already tried that, anyways, here is a picture to give you an idea what messes up:
Yvar Birx 28-Mar-13 17:20pm View
Yeah, I kinda wrote the question wrong. Well, I am just hoping I can get as many numbers as possible. Zoltan just answered it for me. :P
Yvar Birx 28-Mar-13 16:56pm View
Yes, exactly, yeah it is, I'm not sure too. :P
Yvar Birx 28-Mar-13 16:55pm View
And with 'As far as possible' I mean, just to see the results.
Yvar Birx 28-Mar-13 16:54pm View
Yes, I understand, that's why I am interested into calculating it as far as possible. I have no clue where to start though.
Yvar Birx 16-Mar-13 16:00pm View
The line is:
return BitConverter.ToInt32(b, 0);
Yvar Birx 16-Mar-13 13:43pm View
Yes I will, I only currently have a small problem, I hope you can make something out of this:

Client sends this:
public void UpdateBufferSize(int Size)
/* Create a byte array for an integer. */
byte[] ByteInt = Helper.ConvertIntToByteArray(Size);

/* Create a one byte bigger array to send. */
byte[] ToSend = new byte[BufferSize];

/* Change the first byte. */

/* Copy the int in the ToSend. */
Array.Copy(ByteInt, 0, ToSend, 1, ByteInt.Length);

/* Sleep the thread to prevent bugs. */

/* Send the package. */
if (this._TcpClient.Connected)
this._TcpClient.GetStream().Write(ToSend, 0, ToSend.Length);


Then the server does this:
/* Handle change buffer size. */
if (_Package[0] == IDs.ID_CHANGEBUFFERSIZE)
/* Create the Integer array. */
byte[] IntegerArray = new byte[_Package.Length + 1];

/* Copy the array into it. */
Array.Copy(_Package, 1, IntegerArray, 0, _Package.Length - 1);

/* Clear the array so theres only the int left. */
IntegerArray = IntegerArray.Where(v => v > 0).ToArray();

/* Update the buffer size. */
_BufferSize = (int)Helper.ConvertByteArrayToInt32(IntegerArray);

/* Show message. */
System.Windows.Forms.MessageBox.Show("Buffer has been changed to: " + _BufferSize.ToString());

Then, I boot everything up like so:
static void Main(string[] args)
AFS_Network.Network.TCPServer Server = new AFS_Network.Network.TCPServer(1337);

AFS_Network.Network.TCPClient Client = new AFS_Network.Network.TCPClient("", 1337, 4096);


And the error I get is from my byte[] to int:
public static double ConvertByteArrayToInt32(byte[] b)

return BitConverter.ToInt32(b, 0);


The error is: Destination array is not long enough to copy all the items in the collection. Check array index and length.

I hope you can help me, I am sorry if it's a bit too much.
Yvar Birx 16-Mar-13 12:58pm View
Cheers, you're the best. ;3
Yvar Birx 13-Mar-13 15:23pm View
Assuming you had a TCP server and client.

You would have to create a buffer size like so:

// -- Convert the object client to a TCPClient.
TcpClient _TcpClient = (TcpClient)_Client;

// -- Create a stream.
NetworkStream _ClientStream = _TcpClient.GetStream();

// -- The message.
byte[] _Package = new byte[4096];

Now, problem is, let's say we want to send a bigger file to the client, perhaps, 12096? What we then have to do is tell the client that what we are about to send is bigger.

A -> B : I will send you a message of 12096 bytes
B -> A : Ok, I am ready
A -> B : [send those 12096 bytes]
B -> A : I got it

The way I am going to do it is by sending a byte array like so:

byte[] NewPackage = new byte[4096];
NewPackage[0] = ID_CHANGEBUFFER.

And then using the Array.Copy/ Methods to put the new Integer after the first byte. It's easy to get the Integer array out of it, but we will have the rest of the empty array standing there, and converting the byte array to an int again will be difficult because of the not used bytes in the array.

Yvar Birx 13-Mar-13 15:11pm View
Yes, I did. But I can only use the array, I am using this to tell a TCP Server or Client what to change their buffer size to, and I can't send a smaller array without making it the buffer size it already has.
Yvar Birx 9-Mar-13 16:50pm View
Many thanks to your informative answer, I will look at these links and I already have an idea on how to make it work.

Cheers! :)
Yvar Birx 9-Mar-13 12:56pm View
It is not working, so you ask us how to make one? So you have had a reference to something that did work, otherwise you wouldn't make one if you didn't know how? What have you tried yet?
Yvar Birx 3-Mar-13 13:38pm View
No not really. You are currently looking through my history finding something to complain about. This is probably the fourth time you have responded to an ancient old post of mine blaming me for not knowing, I was suggesting this person how to do something.

Seriously? Stop being immature.
Yvar Birx 3-Mar-13 9:38am View
Yeah, I actually don't mind. Sounds like a great thing to learn.
Yvar Birx 3-Mar-13 8:45am View
Thanks, I really appreciate the help, and I have finally gotten an idea on how to. ;)
Yvar Birx 3-Mar-13 5:29am View
It's funny how you are actually purposely insulting me now, I will report you now, I have asked you kindly. And no, he asked exactly what this is, and this will work for negative numbers. Cheerios.
Yvar Birx 28-Feb-13 16:57pm View
"Naive", I hope you know what the definition means, because this is probably the third time you have insulted me on my questions.
Yvar Birx 28-Feb-13 16:35pm View
Yvar Birx 28-Feb-13 16:31pm View
Cheers man. If no other solutions, I'll choose yours.
Yvar Birx 28-Feb-13 8:18am View
Thanks, clear and straight to the point.
Yvar Birx 28-Feb-13 8:16am View
So all it pretty much does is, it uses the Font, and then disposes it after the ending bracket?
Yvar Birx 28-Feb-13 8:08am View
Yvar Birx 28-Feb-13 8:08am View
That's really interesting, but this uses Google and Bing already, not that it's a bad thing.
Yvar Birx 28-Feb-13 8:08am View
Always handy!
Yvar Birx 28-Feb-13 8:07am View
Yvar Birx 28-Feb-13 8:07am View
Yvar Birx 28-Feb-13 7:28am View
Interesting, do they have any type of website where they explain how it works?
Yvar Birx 25-Feb-13 13:59pm View
Cheers for your kind reply. And this is not a re-post. This is a complete other question.
Yvar Birx 25-Feb-13 9:03am View
" System.Windows.Forms.MessageBox.Show(Angle(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), new Vector2(World.Player.GetPositionX(), World.Player.GetPositionY())).ToString());" Produces NaN.

PlayerX = 0;
PlayerY = 0;
MouseX = 130;
MouseY = 160;

I honestly don't understand how this is not a NaN for you, as NaN is an infinite loop, so something must be wrong with your code.

"In computing, NaN (Not a Number) is a value of the numeric data type representing an undefined or unrepresentable value, especially in floating-point calculations. Systematic use of NaNs was introduced by the IEEE 754 floating-point standard in 1985, along with the representation of other non-finite quantities like infinities."
Yvar Birx 25-Feb-13 7:02am View
Yvar Birx 25-Feb-13 1:47am View
public void DoMouse()
/* Mouse State */
MouseState State = Mouse.GetState();

/* Set the Angle. */
World.Player.SetAngle(World.Player.AngleBetweenCooardinates(new Vector2(State.X, State.Y), new Vector2(World.Player.PositionX, World.Player.PositionY)));
Yvar Birx 24-Feb-13 16:14pm View
This returns as NaN?
Yvar Birx 24-Feb-13 13:09pm View
Oh, I didn't notice that there was no cursor. Anyways, my cursor is in the down left corner, and it's looking at the other side.
Yvar Birx 20-Feb-13 15:33pm View
Cheers too!
Yvar Birx 20-Feb-13 15:32pm View
Yvar Birx 3-Feb-13 15:33pm View
Hello Matthew!
Thanks for your interesting reply. Well basically, I am trying to get it to dispose the TCP Client, because the Tcp Client is always there in the Ram even when I "disposes" or "closed" it. I'm trying it to handle the clients good enough for Windows not to complain that it still exists.
Yvar Birx 2-Feb-13 12:49pm View
Cheers mate, shame I didn't thought of that. ;3
Yvar Birx 7-Jan-13 15:54pm View
I also understand it's 75% slow because of the huge for loop, but I have no idea on how to fix that unless I want to go back to my griddy block view. :(
Yvar Birx 4-Jan-13 16:22pm View
Thanks for the helping reply. I'll ask another website. Really, if you can't be bothered explaining on how to use it then just let it be. This is a coding website not a insult everyone because they do not understand one thing website.
Yvar Birx 4-Jan-13 14:39pm View
Well, since I don't know how angles work. :/
Yvar Birx 30-Dec-12 16:11pm View
Edit: Fixed, thanks so much ! :)
Yvar Birx 30-Dec-12 16:10pm View
Thanks, any idea on how to get the numbers 0-8 then ?
Because I need to Write the arrays. >.>
Yvar Birx 27-Dec-12 8:54am View
Cheers mate ! Thanks finally works !
One question, how did you know to square the number ?
Yvar Birx 26-Dec-12 9:12am View
This does not do what I want it to, I have checked that link out already. ;s
Yvar Birx 26-Dec-12 8:56am View
I am not really sure how to explain it more briefly. I got an multi-dimensional array of a 'block' class, I need to be able to convert that into a single array so I can use the XML serializer to save it in a file. I just don't know how to convert a multi into a single array and back.
Yvar Birx 26-Dec-12 8:50am View
I got this as a propery because that is how XML Serializer works, and I need to save this in a file and load it out later.
Yvar Birx 26-Dec-12 8:40am View
What do you mean ?
Yvar Birx 25-Dec-12 14:44pm View
Also, Chunk class is similair but works.
Yvar Birx 25-Dec-12 14:43pm View
Alright, thanks. Last problem; It does not serialize the blocks, this is my result:

< chunk >
< x > 0 < /x >
< y > -1< / y >
< / chunk >

Where are my blocks at ?

Also I changed the code of the block class to:

" [Serializable]
public static class ID
public static int BlockSize = 32;

public const byte BLOCK_AIR = 30;
public const byte BLOCK_DIRT = 31;
public const byte BLOCK_GRASS = 32;

public class Block
public byte ID { get; set; }

public Block()

// -- Block
/// Initializes a new Block with the ID given.

/// <param name="_ID">The ID of the block.</param>
public void InitializeBlock(byte _ID)
// -- Set the ID.
ID = _ID;
Yvar Birx 25-Dec-12 13:02pm View
It's in:

public class Chunk
// -- Blocks.
private Block[,] _Blocks;

// -- Cooardinates.
public int X { get; set; }
public int Y { get; set; }

// -- Chunk.
/// Initializes a new Chunk based on the Width and Height given.

/// <param name="Width"></param>
/// <param name="Height"></param>
public Chunk(int X, int Y, int Width, int Height)
Yvar Birx 25-Dec-12 13:01pm View
Don't I have that ? If not, could you point it out to me ? :)
Yvar Birx 25-Dec-12 6:40am View
I already have placed that ?
Yvar Birx 24-Dec-12 20:08pm View
> Terrasylum.exe!Terrasylum.Program.Main(string[] args) Line 13 C#

Which is the main, that is why I said. There is no specific error.
Yvar Birx 24-Dec-12 15:52pm View
Nevermind, you were right, I found a way. Thanks so much !
Yvar Birx 24-Dec-12 15:36pm View
I also store those chunk strings in a file. ;l
Yvar Birx 24-Dec-12 15:35pm View
I could transform the string into an array though, the chunk the player is in, to draw. ?
Yvar Birx 24-Dec-12 15:34pm View
Well, that is the problem. I have 9 chunks loaded in, whenever the player goes into another chunk the chunks are reloaded. This is ThePlayer.LoadedChunks. It's an array of strings, and I can't make an array out of an array. :L
Yvar Birx 24-Dec-12 15:22pm View
This, made it a lot more compact and easy thanks, unfortunatly, reading it out still seems to be messed up, am I using the right calculation(I am using the right chunk don't worry about that).

Yvar Birx 24-Dec-12 15:13pm View
What do you exactly mean ? (Thanks for helping me out btw)

The first two for loops make sure the string has the length it needs to have, otherwise I can't change the character.

The next two loops Actually generate the landscape.
Yvar Birx 24-Dec-12 15:07pm View
No, the thing is, they are even sizes. The Chunk has to be 20 by 20. And I am not going to make two variables valueing 20. :P
Yvar Birx 24-Dec-12 12:51pm View
Yes, I am generating 'flat grass' and the blocks should be below half of the room, although they are spazzing all over the Room. So the problem is 'reading' out the blocks. THAT is the problem.
Yvar Birx 23-Dec-12 9:21am View
My problem is as I said this: "(ChunkY == 0 && j > World.ChunkSize / 2))". There is no algorithm as this is flat grass.
Yvar Birx 19-Dec-12 14:39pm View
Someone please help.
Yvar Birx 19-Dec-12 13:55pm View
You made my day. :)
Yvar Birx 19-Dec-12 13:49pm View
I have no clue on what you are asking ?
Yvar Birx 11-Dec-12 12:10pm View
@Vijay, your reply to OriginalGriff makes me think you're not serious. Please stop that behaviour.
Yvar Birx 11-Dec-12 12:01pm View
What is your problem ?