Pages

Thursday, February 20, 2020

dreamcast.local VI - ChuChu Rocket!

Just like my prior article about Phantasy Star Online Ver. 2, I will split this article into two parts. The first part will be focusing on the website again, while the second part will focus on the game and how to go online with it again. One note about online gaming with ChuChu Rocket!: this time I will show you how to setup your own ChuChu Rocket! game server with the software from Shuouma.

Part I - ChuChu Rocket! website

Insert your game disc and in the main menu select "Homepage". Then make the following changes in the Options menu and set the AT command to atx if necessarry:

[Pictures will come]

Before actually going online, have an eye on syslog:

# tail -f /var/log/syslog | grep named
...


Now go online and look out for queries in syslog:

# tail -f /var/log/syslog | grep named
...
Feb 19 17:42:20 localhost named[1881]: client @0xb0e07970 192.168.3.1#54831 (ppp0.dreamcast.local): query: ppp0.dreamcast.local IN A + (192.168.3.1)
Feb 19 17:42:20 localhost named[1881]: client @0xb0e07970 192.168.3.1#60191 (ppp0): query: ppp0 IN A + (192.168.3.1)
Feb 19 17:42:20 localhost named[1881]: resolver priming query complete
Feb 19 17:42:20 localhost named[1881]: client @0xb1642e48 192.168.3.1#34058 (ppp0.dreamcast.local): query: ppp0.dreamcast.local IN A + (192.168.3.1)
Feb 19 17:42:20 localhost named[1881]: client @0xb1642e48 192.168.3.1#46314 (ppp0): query: ppp0 IN A + (192.168.3.1)
Feb 19 17:42:21 localhost named[1881]: client @0xb167cd38 192.168.3.1#38792 (ppp0.dreamcast.local): query: ppp0.dreamcast.local IN A + (192.168.3.1)
Feb 19 17:42:21 localhost named[1881]: client @0xb1642e48 192.168.3.1#55772 (ppp0): query: ppp0 IN A + (192.168.3.1)
Feb 19 17:42:23 localhost named[1881]: client @0xb0d08e88 172.16.12.2#2001 (chuchu.web.dreamcast.com): query: chuchu.web.dreamcast.com IN A + (192.168.3.1)
...


And here we see it already, the game tries to connect to chuchu.web.dreamcast.com when visting the games website. Start by faking the IP for chuchu.web.dreamcast.com add the zone to your bind:

# vi /etc/bind/named.conf
...
zone "chuchu.web.dreamcast.com" {
        type master;
        notify no;
        file "/etc/bind/zones/chuchu.web.dreamcast.com";
};
...


Then create the zone:

# vi /etc/bind/zones/chuchu.web.dreamcast.com
$ORIGIN chuchu.web.dreamcast.com.
$TTL 604800
@       IN      SOA     dcs01.dreamcast.local.  root.dreamcast.local. (
                                85; serial
                                28800; refresh (8 hours)
                                7200; retry (2 hours)
                                604800; expire (1 week)
                                10800; minimum (3 hours)
                                );

chuchu.web.dreamcast.com.       IN      NS      dcs01.dreamcast.local.
chuchu.web.dreamcast.com.       IN      MX 10   dcs01.dreamcast.local.

@                       IN      A       192.168.3.1


And restart bind:

# systemctl restart bind9

Finally run a query for chuchu.web.dreamcast.com:

# dig +short chuchu.web.dreamcast.com
192.168.3.1


Next create a Nginx block server configuration:

# vi /etc/nginx/sites-available/chuchu.web.dreamcast.com
server {
  listen 80;
  listen [::]:80;

  server_name chuchu.web.dreamcast.com;

  root /var/www/chuchu.web.dreamcast.com;
  index index.html;
  autoindex on;

  location / {
    try_files $uri $uri/ =404;
  }
}


And link it to the sites-enabled folder:

# ln -s /etc/nginx/sites-available/chuchu.web.dreamcast.com /etc/nginx/sites-enabled/

Restart Nginx:

# systemctl restart nginx

Now it is time to create the website itself. I found a copy on https://www.dreamcastlive.net, which I will use here. First create a folder and change into it, to download a copy of the webiste:

# mkdir -p /usr/src/dc/ccr && cd /usr/src/dc/ccr
# wget -c "https://www.dreamcastlive.net/files/Website%20Backups/chuchu.web.dreamcast.com.zip"
...


Unzip the copy:

# unzip chuchu.web.dreamcast.com.zip

And move all files into your Nginx block server folder:

# mv CHUCHUROCKET/* /var/www/chuchu.web.dreamcast.com/

Clean up a little and remove the folder:

# rmdir /usr/src/dc/ccr/CHUCHUROCKET/

When you visit the website for ChuChu Rocket! out of the game, it will look like this:

[Pictures will come]

Part II - ChuChu Rocket! online gaming

Before trying to play online, you need to grep syslog again:

# tail -f /var/log/syslog | grep named
...


Next start the game and select "Network" to go online with the game. Again, look out for DNS queries when going online:

# tail -f /var/log/syslog | grep named
...
Feb 19 18:09:47 localhost named[17625]: client @0xb1685270 192.168.3.1#54871 (ppp0.dreamcast.local): query: ppp0.dreamcast.local IN A + (192.168.3.1)
Feb 19 18:09:47 localhost named[17625]: client @0xb167d4c8 192.168.3.1#45582 (ppp0): query: ppp0 IN A + (192.168.3.1)
Feb 19 18:09:47 localhost named[17625]: client @0xb1685270 192.168.3.1#38498 (ppp0.dreamcast.local): query: ppp0.dreamcast.local IN A + (192.168.3.1)
Feb 19 18:09:47 localhost named[17625]: client @0xb1685270 192.168.3.1#59659 (ppp0): query: ppp0 IN A + (192.168.3.1)
Feb 19 18:09:48 localhost named[17625]: client @0xb1685270 192.168.3.1#52688 (ppp0.dreamcast.local): query: ppp0.dreamcast.local IN A + (192.168.3.1)
Feb 19 18:09:48 localhost named[17625]: client @0xb1651690 192.168.3.1#46053 (ppp0): query: ppp0 IN A + (192.168.3.1)
Feb 19 18:09:50 localhost named[17625]: client @0xb1651690 172.16.12.2#1425 (chuchu.games.dream-key.com): query: chuchu.games.dream-key.com IN A + (192.168.3.1)
Feb 19 18:09:50 localhost named[17625]: client @0xb1651690 172.16.12.2#1426 (chuchu.games.dream-key.com): query: chuchu.games.dream-key.com IN A + (192.168.3.1)
Feb 19 18:09:51 localhost named[17625]: client @0xb1651690 192.168.3.1#59156 (ppp0.dreamcast.local): query: ppp0.dreamcast.local IN A + (192.168.3.1)
Feb 19 18:09:51 localhost named[17625]: client @0xb1651690 192.168.3.1#44939 (ppp0): query: ppp0 IN A + (192.168.3.1)
...


The game itself tries to connect to chuchu.games.dream-key.com. With this information we can now create a zone for bind:

# vi /etc/bind/named.conf
...
zone "chuchu.games.dreamcast.com" {
        type master;
        notify no;
        file "/etc/bind/zones/chuchu.games.dreamcast.com";
};
...


And the zone file itself:

# vi /etc/bind/zones/chuchu.games.dreamcast.com
$ORIGIN chuchu.games.dreamcast.com.
$TTL 604800
@       IN      SOA     dcs01.dreamcast.local.  root.dreamcast.local. (
                                85; serial
                                28800; refresh (8 hours)
                                7200; retry (2 hours)
                                604800; expire (1 week)
                                10800; minimum (3 hours)
                                );

chuchu.games.dreamcast.com.       IN      NS      dcs01.dreamcast.local.
chuchu.games.dreamcast.com.       IN      MX 10   dcs01.dreamcast.local.

@                       IN      A       192.168.3.1


Next restart bind and run a query on chuchu.games.dream-key.com:

# systemctl restart bind9
# dig +short chuchu.games.dreamcast.com
192.168.3.1


Now it is time to install the server software. Create a folder to download the source and change into it:

# mkdir -p /usr/src/dc/ccr && cd /usr/src/dc/ccr

Download the source package:

# wget -c "https://www.dreamcastlive.net/files/Downloads/chuchu_server.zip"

And it extract it to the folder src:

# unzip chuchu_server.zip -d src

Change into folder:

# cd src

Before you can compile the source, you need to install sqlite3 first:

# apt install sqlite3 libsqlite3-dev
...


Now run make to compile the source:

# make
...


Note: the source compiled on my ARM based Orange Pi R1!

Configure the server software and change the IP to the IP of your Dreamcast server:

# vi chuchu.cfg
...
CHUCHU_LOBBY_IP=192.168.3.1
...


To run the server software, you need two terminals. One for the login server and another one for the lobby server. On the terminal for the login server change into the directory where you compiled the software and start the login server:

# cd /usr/src/dc/ccr/src/
# ./chuchu_login_server
[2020/02/19 18:21:18][ChuChu - Server] [INFO] - Reading config...
[2020/02/19 18:21:18][ChuChu - Server] [INFO] - Loaded Config:
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_LOGIN_PORT_: 9000
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_IP: 192.168.3.1
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_PORT: 9001
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_DB_PATH: db/chuchu.db
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_INFO_PATH: info/chuchu_info.txt
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_MAX_PUZZLES: 96
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_MAX_CLIENTS: 100
[2020/02/19 18:21:18][ChuChu - Server] [INFO] -         CHUCHU_MAX_ROOMS: 20
[2020/02/19 18:21:18][ChuChu - LoginServer] [INFO] - Socket created
[2020/02/19 18:21:18][ChuChu - LoginServer] [INFO] - Bind done
[2020/02/19 18:21:18][ChuChu - LoginServer] [INFO] - Waiting for incoming connections...


On the terminal for the lobby server change into the directory where you compiled the software and start the lobby server:

# cd /usr/src/dc/ccr/src/
# ./chuchu_lobby_server
[2020/02/19 18:21:44][ChuChu - Server] [INFO] - Reading config...
[2020/02/19 18:21:44][ChuChu - Server] [INFO] - Loaded Config:
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_LOGIN_PORT_: 9000
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_IP: 192.168.3.1
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_PORT: 9001
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_DB_PATH: db/chuchu.db
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_LOBBY_INFO_PATH: info/chuchu_info.txt
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_MAX_PUZZLES: 96
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_MAX_CLIENTS: 100
[2020/02/19 18:21:44][ChuChu - Server] [INFO] -         CHUCHU_MAX_ROOMS: 20
[2020/02/19 18:21:44][ChuChu - Server] [INFO] - Added 0 puzzles
[2020/02/19 18:21:44][ChuChu - LobbyServer] [INFO] - Socket created
[2020/02/19 18:21:44][ChuChu - LobbyServer] [INFO] - Bind done
[2020/02/19 18:21:44][ChuChu - LobbyServer] [INFO] - Waiting for incoming connections...


When you go online with the game now, then you are required to login first. If you don't have an account, you have to create one. I created one with username "K" and password "K". Registration and login on the server looks like:

...
[2020/02/19 18:23:25][ChuChu - LoginServer] [INFO] - Connection accepted from 172.16.12.2 on socket 4
[2020/02/19 18:23:25][ChuChu - LoginServer] [INFO] - Handler assigned
[2020/02/19 18:23:26][ChuChu - LoginServer] [INFO] -  <- DC-ID: [d055254b8818]
[2020/02/19 18:23:26][ChuChu - Server] [INFO] - DC id is not in the DB
[2020/02/19 18:23:26][ChuChu - LoginServer] [INFO] -  <- New user joining...
[2020/02/19 18:23:43][ChuChu - LoginServer] [INFO] -  <- Username: K is trying to join...
[2020/02/19 18:23:43][ChuChu - Server] [INFO] - Records created successfully
[2020/02/19 18:23:43][ChuChu - LoginServer] [INFO] - Done, disconnecting socket 4
...


When you select a room to play online, then the log for the lobby looks like:

...
[2020/02/19 18:23:43][ChuChu - LobbyServer] [INFO] - Connection accepted from 172.16.12.2 on socket 4
[2020/02/19 18:23:43][ChuChu - LobbyServer] [INFO] - Added client: 0x104
[2020/02/19 18:23:43][ChuChu - LobbyServer] [INFO] - Handler assigned
[2020/02/19 18:23:43][ChuChu - LobbyServer] [INFO] -  <- Username: K is trying to join...
[2020/02/19 18:23:43][ChuChu - LobbyServer] [INFO] - Stats fetched for username: K
[2020/02/19 18:23:54][ChuChu - LobbyServer] [INFO] -  <- 0x01 players on this dreamcast wants to play
[2020/02/19 18:24:25][ChuChu - LobbyServer] [INFO] - User K joined room PSO Room
[2020/02/19 18:24:31][ChuChu - LobbyServer] [INFO] - User K left room PSO Room
...


Of course, since I am the only one on the server logged in, I can not play with others. One feature that really surprised me was, that server software can deal with self created puzzles. Which meeans you can create a puzzle and store it on your VMU. Then go online with the game and upload the puzzle. When you delete the self created puzzle on your VMU, you can download it again from the server.

If you want to, then you can take a look at the database. Change into the directory where you compiled the source:

# cd /usr/src/dc/ccr

Run sqlite3 and open the database:

# sqlite3 db/chuchu.db

Check that you are conneted to the right database:

sqlite> .databases
main: /usr/src/dc/ccr/src/db/chuchu.db


List the available tables:

sqlite> .tables
PLAYER_DATA  PUZZLE_DATA


Take a look at the PLAYER_DATA table:

sqlite> pragma table_info('PLAYER_DATA');
cid         name        type        notnull     dflt_value  pk
----------  ----------  ----------  ----------  ----------  ----------
0           ID          INTEGER     0                       1
1           DC_ID       CHAR(8)     1                       0
2           USERNAME    CHAR(16)    1                       0
3           PASSWORD    CHAR(16)    1                       0
4           WON_RNDS    INTEGER     0                       0
5           LOST_RNDS   INTEGER     0                       0
6           TOTAL_RNDS  INTEGER     0                       0

sqlite> select * from PLAYER_DATA;
1|D055254B8818|K|K|0|0|0


And the PUZZLE_DATA table:

sqlite> pragma table_info('PUZZLE_DATA');
cid         name        type        notnull     dflt_value  pk
----------  ----------  ----------  ----------  ----------  ----------
0           ID          INTEGER     0                       1
1           PUZZLE_NAM  CHAR(16)    1                       0
2           CREATOR     CHAR(16)    1                       0
3           PUZZLE_FIL  BLOB        0                       0
4           DOWNLOADED  INTEGER     1                       0

sqlite> select * from PUZZLE_DATA;
1|KAR01|K||1


And this is it: the recovered website and your own ChuChu Rocket! game server.

Links:
https://www.dreamcastlive.net

No comments:

Post a Comment