Sunday, June 2, 2013

back to work to prediction

Last time I left off where I just need to make prediction. I didn't touch this multiplayer until I finished my game engine animation system. Now just need to make prediction and all assignment is over.

Monday, May 20, 2013

pretty much done

Now I am pretty much done with the multiplayer final project. I can focus on the game engine then.

Friday, May 17, 2013

serialization with BinaryFormatter

This is very crazy. I thought BinaryFormatter.serialize will do the magic and makes my life easier. Apparently, it is the opposite. The binary formatter does something crazy and I can't predict when it goes crazy. The result is the transfer data is veryy incredibly slowww.. From my experience, you can do serialize object using binaryformatter only for general type like int, byte, float, String, etc (Im not sure about enum)

Now here is the example:
// [Serializable]   // I could put here too the result still the same
struct DataPos
{
   float posX;
   float posY;
   float rot;
};

[Serializable]
struct ShipData
{
   // this is just enumeration for type
   eType type;

   // here I was trying only data position
   DataPos datapos;
}

The binaryformatter DOES NOT WORK WELL on this structure. I tried to put padding too in the enumeration and same thing. It doesn't say it is illegal. It just slows the transfer data. It takes 3 days to debug this shit.

Here after I change the data into this structure

[Serializable]
struct ShipData
{
   // this is just enumeration for type
   eType type;
   
   // not using the struct
   float posX;
   float posY;
   float rot;
}

everything goes well. This is really stupidd.. The BinaryFormatter should tell he can't serialize that if he can't. Not just by keep silent and let the programmer debug himself.

Determine which one is client or server

This is the hardest part: determining which one should run in the client or in the server. In theory, the server should do everything in the update section. But in practice, I think that updating the particle can be just done in the client because I don't want the server calculating the large particle and slow him self. This makes my code getting messier because I put every update in the server first and realized it was very slow. I need to refactor a lot of code. However whenever there is something special in that particular particle, server just need to tell to the client. But in this assignment, there is problem about that.

Sunday, May 12, 2013

C# is very easy

I thought it would take a while to learn C#. Apparently, it was very easy migrate from C++ to C#.

bad code from previous programmer

I don't it is whether bad code from previous programmer or C# allows us to put "new" everywhere. There is a code in everyloop calls Player.PlayerInput myInput = new Player.PlayerInput(); without calling delete. I don't know how to call delete anywhere though. I don't like that code.

Saturday, May 4, 2013

messy code

I believe this time my code is really messy.. I just want the networking works. I modified something that doesn't work when I combine everything. But I think its okay because I just want to focus on the networking

network state management

I like this example. I guess I will start from here and put the omega race project into this example.

Friday, May 3, 2013

real network programming

I guess the real programming starts from now. Basically I need to learn the example code. There are 6 examples. I guess I have to understand the whole thing then I can move on to the space war.

Friday, April 26, 2013

Queue Data

This assignment is to practice C#. I am getting familiar with C# function such as Queue. What I had to do is create a simple calculator (calc) and simple finite state machine (fsm). I put the data and operation of calc and fsm into the queue, then finally I process everything inside the queue.

The hardest part of this assignment is design the queue class such that my data can goes smoothly without too many if statement.The suggestion from Ed is put a header into the queue before inserting data. So when I enqueue the data, I enqueue it twice (header and data) and dequeue it twice. But I couldn't come up with enqueue process that can just call
   myQueue.Enqueue(header);   -> header type is calc
   myQueue.Enqueue(data);       -> calc data

Then my solution is I wrapped the header and data together as the input queue. So I only enqueue and dequeue once. Here is I design the class.

interface Data {}

struct Calc_Data : Data;
struct FSM_Data : Data;

enum QueueType { QUEUE_CALC, QUEUE_FSM }

struct QueueData   // the queue will accept this data
{
    QueueType type;
    Data data;   // calc or fsm
    int seqNumber;
}

class CalcQueue
{
   void add( Calc_Data data )
   {
       inQueue.enqueue (new QueueData( QUEUE_CALC, data ));
   }
}

// the same thing with fsm.

Then, the process function can do the magic.

Friday, April 19, 2013

UDP

The UDP programming is different with TCP. While in TCP we send and wait until the recipient receive the data, in UDP we can just send send send the data. No matter the recipient has received or not. In this way, it runs very fast. But the data might be broken or lost. This is unreliable.

Thursday, April 18, 2013

TCP

The third assignment is about TCP and UDP. I wanna talk about TCP first because I just finish it. So it is basically about creating a connection between client and server through a socket. The server listen from a port (ex: 8888). Basically, the server open that port and let everyone coming from that port.

From the client side, if he wants to connect to the server, he has to go through the opening port, that is 8888. So when the client connect to the server, it creates the connection socket. So next time when client wants to communicate with server and vice versa, they communicate from the socket. The process of making connection is called 3 handshake because there are 3 messages transmitted to create the connection.

Generally, this TCP assignment is easy. First of all, we create the connection between client and server. After the connection is made, client send a list of data to server. The server sort the list and send them back to client.

The hardest part is understanding the code line by line and learned what the code is actually doing. Then finally, do some coding stuffs and the TCP is done.

Wednesday, April 10, 2013

serialization

Basically, serialization is bundling an object into something that can be moved to other machine. After moved to a machine, that thing is extracted into another object which is called deserialization. Overall, this assignment is easy. The hardest part is arranging the data structure so it is optimized. I use __m64 to try to optimize the data structure.

This class is the most challenging:

class Fish
{
   Apple pApple;
   Orange *pOrange;
 
   union
   {
      // this variable can share the memory address with the int and float. It has 8 bytes
      __m64 op1;
      struct
      {
         // these variables will be shared with op1
         int x;
         float y;
      };
   };


   union
   {
    // this integer variable also shared with chars variable
   int op2;
   
   struct
   {
      char a;
      char pad1,pad2,pad3;
   };
   };
};

I was thinking to make copying process in one stamp. But I can't figure out how to do it. This is the best I can do.

Wednesday, April 3, 2013

first assignment

This is like very very simple assignment. Making own upper case just play with pointer and minus it to 32 ('A' - 'a') each character and its done.

Installing the xna maybe is kinda annoying. I download xna 3 which requires visual studio 2008 but I could find visual studio 2008 anymore. So I just installed xna 4

Welcome

Hi, welcome to my gam 490 blog. This is multiplayer class I am taking at DePaul University.