Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sun Nov 19, 2017 5:37 pm

All times are UTC




Post new topic  Reply to topic  [ 30 posts ]  Go to page Previous 1 2
Author Message
 Post subject:
PostPosted: Wed Oct 26, 2005 6:43 am 
Offline
Engineer
Engineer

Joined: Tue Jul 12, 2005 8:14 am
Posts: 32
Location: Melbourne suburbs, Victoria, Australia (GMT+10)
uzurpator wrote:
Ok - I think we should really disregard this thread and build the tree on the fly.

For now it would constitute something like this:

Code:
God             Satan
 |               |
 |-Server        |-Client
 \-Network       \-Network


[snip]

BTW - I name classes by their level in the tree:

God
Seraph
Cherub
Angel
Saint
Blessed

Satan
Daemon
Devil
Imp
Sinner
Damned

Call me creative.


Creative, maybe, but WRONG. Should be the other way around (ie Satan as the server), as a server process is generally a DAEMON! :P

William.


Top
   
 Post subject:
PostPosted: Mon Mar 06, 2006 10:39 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
There's only a very small chance that our architecture will be right the first time. So, I propose to do things incrementally.

When looking at the (preliminary?) task list, I think that the small demo I've posted earlier today satisfies task 1 and a part of task 2.

Now, for the rest of task 2 and 3, I propose the following architecture:

Both the Server and the Client application will be constructed following the Model-View-Controller paradigm. Because I'd like to keep things simple for this step, the applications will be console based. Instead of transmitting the timestamp of the game, the applications will transmit the map.

The View and Controller part of both applications will be done properly at a later time. We will focus on the model, for now.

The model of the client will look like this:
Image
Omg... Visio 2000 gives really bad images

The Map interface is used by the View and the Controller to access the map. It is implemented by the MapCache class, which stores (caches) individual Tiles. The tiles are retrieved from the server through the ClientSocket class. Communication is done with Packets, which are created by the PacketFactory.

Everybody still reading? ;)

Now the server:
Image

The server has a ServerSocket which is comparable to the ClientSocket class in the client, but still quite different. Perhaps those two classes can share a super class. We'll see. We can always refactor in the future. The ServerSocket connects to the real Map, which happens to support all the same actions as the Map interface in the Client.

Notice that some classes are shared between Server and Client:
  • Packet
  • PacketFactory
Packets are only a medium to transmit information. Hence, it makes perfect sense to share these classes between the two applications.


Now... What is the purpose of all this. A prototype/demo/pre-alpha/whatever version of Transport Empire must satisfy these requirements:
  • The server must store a map of at least 16x16 tiles, with each tile having a height.
  • This map will be generated at random when the server is started.
  • The client will subsequently ask for two snapshots of 8x8 tiles and displays them on the console. After the second snapshot, the first is requested again. Here's where the cache should prevent excessive network communication.

The following items will be milestones for task 3:
  1. Creating the two Socket classes. Creating a Packet object, serializing it, transmitting and reconstructing it on the other side.
  2. Answering to an arrived packet
  3. Creating a random map at the server
  4. Requesting and receiving the map by the client
  5. Caching the map


Anyone willing to help is welcome. ;)

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)
Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+

[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...


Last edited by Hellfire on Mon Mar 06, 2006 11:02 pm, edited 2 times in total.

Top
   
 Post subject:
PostPosted: Mon Mar 06, 2006 10:39 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
This post is only for the images.


Attachments:
client.model.png
client.model.png [ 3.96 KiB | Viewed 5241 times ]
server.model.png
server.model.png [ 3.6 KiB | Viewed 5240 times ]

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...
Top
   
 Post subject:
PostPosted: Tue Mar 07, 2006 6:21 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Hellfire wrote:
The following items will be milestones for task 3:
  1. Creating the two Socket classes. Creating a Packet object, serializing it, transmitting and reconstructing it on the other side.
  2. Answering to an arrived packet
  3. Creating a random map at the server
  4. Requesting and receiving the map by the client
  5. Caching the map

Milestone 1 has been reached. :)

In the zipfile is a _very_ simple application that meets the requirements. It's basically the same as the demo I made earlier, except that this is Object Oriented and uses some form of abstraction over the data traffic.

The same condition holds nevertheless: compile it on linux or mingw on windows and run from a console. Start the Server first, then the Client.


Attachments:
task-3.1.zip [620.93 KiB]
Downloaded 163 times

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...
Top
   
 Post subject:
PostPosted: Wed Mar 08, 2006 4:59 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Hellfire wrote:
The following items will be milestones for task 3:
  1. Creating the two Socket classes. Creating a Packet object, serializing it, transmitting and reconstructing it on the other side.
  2. Answering to an arrived packet
  3. Creating a random map at the server
  4. Requesting and receiving the map by the client
  5. Caching the map

A little refactoring and a few new classes and voila! Milestone 2. :)

The same rules hold for this program: compile it on linux or mingw on windows and run from a console. Start the Server first, then the Client. Windows executables are included.

Talking into an empty room sucks... I hope at least someone will show up sooner or later and read these posts. ;)


Attachments:
task-3.2.zip [631.96 KiB]
Downloaded 170 times

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...
Top
   
 Post subject:
PostPosted: Fri Mar 10, 2006 6:43 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Hellfire wrote:
The following items will be milestones for task 3:
  1. Creating the two Socket classes. Creating a Packet object, serializing it, transmitting and reconstructing it on the other side.
  2. Answering to an arrived packet
  3. Creating a random map at the server
  4. Requesting and receiving the map by the client
  5. Caching the map

Milestone 3 should have been a part of milestone 4...


Attachments:
File comment: No binaries this time. From the user's point of view, there's no difference between 3.2 and 3.3
task-3.3.zip [15.21 KiB]
Downloaded 168 times

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...
Top
   
 Post subject:
PostPosted: Mon Mar 13, 2006 5:29 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Hellfire wrote:
The following items will be milestones for task 3:
  1. Creating the two Socket classes. Creating a Packet object, serializing it, transmitting and reconstructing it on the other side.
  2. Answering to an arrived packet
  3. Creating a random map at the server
  4. Requesting and receiving the map by the client
  5. Caching the map

Task 4 is done now. The included source code is based on RakNet. This wasn't really necessary, but I think we should go with RakNet anyway. I can still rip it out later if other people think otherwise.

One sidenote: both the server and the client application do not terminate anymore. I did this for two reasons:
1. I'm too lazy to write exit code.
2. The transition to milestone 5 is easier this way.

Another note: I have not tested the code on Linux yet.
Edit: The code werks perfectly on Linux, but it does not compile without libpthread, which should be present on almost all Linux installations. I've changed Makefile.var to add the library on non-windows systems. When I upload milestone 5, this glitch will be fixed.


Attachments:
File comment: Executables are available on request. :)
task-3.4.zip [20.72 KiB]
Downloaded 171 times

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...


Last edited by Hellfire on Tue Mar 14, 2006 10:59 am, edited 1 time in total.
Top
   
 Post subject:
PostPosted: Mon Mar 13, 2006 6:14 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 03, 2002 10:36 am
Posts: 13161
Location: The Netherlands
Can you send me an executable. I don't know if it will fit on a PM?!

_________________
Image
Dutch Trainset for OpenTTD | Dutch Trainset Topic | Combined Roadset v0.10


Top
   
 Post subject:
PostPosted: Tue Mar 14, 2006 11:16 am 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Just to show off, here's a screenshot of a terminal session to my Linux box and a command prompt on my Windows box. The server application is running on the Linux box, the client application is running on the Windows box. All communication is done over the network.


Attachments:
File comment: Just for fun, I added another client. It connects nicely, but because some small design decision, all packets from server to client are broadcasted. That's why the first client receives the map fragment twice.
two-clients.png [74.17 KiB]
Downloaded 56 times
File comment: Show off picture. :P

The server is a Linux machine
The client is a Windows machine

cross-platform.png [41.22 KiB]
Downloaded 60 times

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...
Top
   
 Post subject:
PostPosted: Tue Mar 14, 2006 3:51 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Hellfire wrote:
The following items will be milestones for task 3:
  1. Creating the two Socket classes. Creating a Packet object, serializing it, transmitting and reconstructing it on the other side.
  2. Answering to an arrived packet
  3. Creating a random map at the server
  4. Requesting and receiving the map by the client
  5. Caching the map

Tadah! Task 3 is now complete.

Conclusions from this exercise:
  • Managing makefiles by hand can get very annoying
  • Caching works.
  • Asynchronous communication works very well.
  • Time spent: 8 days, roughly 32 hours coding and debugging.
  • The loops in servermain.cpp and clientmain.cpp have an interesting feature: if (nothing to do) { sleep(a while); }. This keeps CPU usage down and gives us better overall system performance.
  • RakNet is an interesting library. We should look deeper into it.


Attachments:
File comment: Yet Another Useless Screen Shot
screenshot.png [44.39 KiB]
Downloaded 58 times
File comment: The Source (tm)
task-3.5.zip [23.02 KiB]
Downloaded 175 times

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 30 posts ]  Go to page Previous 1 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.