Andrew Que Sites list Photos
Projects Contact
Main

A ton of progress made at implementing the basic TW2002 sector system. Universe sector creation (including bubbles) is done. Basic user created. Basic navigation complete. Sessions functional. Users tracked entering new sectors.  I even had some luck recreating the the terminal-style look of the game.

Sector : 1 in The Federation.
Beacon : FedSpace, FedLaw Enforced
Ports : Sol, Class 0 (Special)
Planets : (M) Terra
Warps to Sector(s) : (2) - (3) - (4) - (5) - (6) - (7)
 
Command [TL=00:53:19]:[1] (?=Help) :

The above is copied from the game output.  You can traverse sectors, but just about everything else isn't functional.

There is much to think about in terms of how to track user motion. Simply having every client keep the system state is both costly and insecure. So we need to consider how to watch only the information we care about and keep that information from leaking. Not sure it is possible.

   Xiphos broke out the welder the other day.  Using 240 VAC from the old dryer outlet he melted down some metal powder in a crucible in an attempt to create ruby.  The results are very rough but the it looks like we have the tools necessary.

June 12, 2020

Game Server Data Management

Decided to use a concept I've been working with to send and receive data from a server for the game.  Games can create data objects the server holds onto.  They are simply named and the server doesn't really care what is in them.  Every client connected to the server can watch for changes to these objects.  At work I developed a system I called CRUDNAF (Create/Read/Update/Delete/Notify/readAll/Flush) to interface to database objects.  It is based on CRUD, a standard database technique with the addition of notifications.  A similar design allows access to memory objects.  The notifications are key.  Clients can asked to be notified to changes to a table.  Then changes made to the server by another client are shared with listening clients.  WebSockets allow this to take place easily without any need to poll the server.

In the future I hope to create this system using NodeJS.  For now I will use the Python system to see how it works for the project.  And what is the project?  I've decided to attempt a basic implementation of the old doors game Trade Wars 2002.  I'm not going to try and finish the game, but implement enough of the system to traverse a universe and do some interactions such as trading.  This will allow me to test the infrastructure of my game server.

Back in 2016 I had designed a stateless game server using jQuery and XML. Since my discovery of WebSockets the stateless requirement is no longer needed, and JSON is much easier to work with than XML. One aspect of the game server design I do like is using asymmetric cryptography to sign-off on changes to the game state. The idea is that no one trusts anyone else. Thus the games are driven by signed-off states. If a game has two players A and B and it is A’s turn, it continues to be A’s turn until B excepts the move A made as legitimate. Likewise, if a three player game with A, B and C has player A taking a turn, C cannot make A’s move because A must sign it’s move. Then B and C must accept that move.

I was thinking about using the WebSocket interface I created for driving a similar game state. This time, the server is more aware and probably playing the game.  I developed a Python-served WebSocket interface for my snapshot project sometime last year.  At work I imported this system for a project and have had good success with it.  I decided to see about applying this system for serving the game system I come up with in 2016 and set out today to try that.

June 10, 2020

Compile PHP 5 on Raspberry Pi

Yesterday I wrote about needing to compile PHP 5 on a Raspberry Pi as part of the LAMP stack. This is actually what is needed to do that.

First, a mess of libraries:

apt install libfcgi-dev libfcgi0ldbl libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev libzip-dev libsqlite3-dev libonig-dev libgmp-dev apache2-dev

Once all that is installed, there are a couple of tweaks that need to be made so libraries are found:

cd /usr/include
ln -s arm-linux-gnueabihf/curl
ln -s arm-linux-gnueabihf/gmp.h

What we are doing is adding include links for CURL and GMP to the platform-specific paths they exist. It was simply a matter of searching the error, and then changing the path from a 386/amd64 directory to the ARM equivalent.

Now PHP can be configured and compiled. I downloaded the last release of PHP 5 which is 5.6.40.

wget https://www.php.net/distributions/php-5.6.40.tar.xz 
tar xfv php-5.6.40.tar.xz 
cd php-5.6.40
./configure --with-apxs2 --enable-sockets --with-mysql --with-mysqli --with-pdo-mysql --enable-ftp --enable-sysvsem --enable-sysvshm --enable-sockets --enable-wddx --with-mhash --with-gd --with-zlib --enable-exif --with-mcrypt --with-gmp --with-curl --enable-bcmath --enable-mbstring --with-bz2 --enable-shmop --with-mcrypt --enable-maintainer-zts
make -j 4
sudo make install

This should install PHP in the default location which is /usr/local/bin. I did try using the FastCGI Process Manager (FPM) but never got it to work. I don’t currently need PHP 7 at all, so I’m not bothering with it for now.

With PHP installed you still have to setup a configuration file.

sudo cp php.ini-production /usr/local/lib/php.ini

Modify timezone:

sudo nano /usr/local/lib/php.ini

Add:

date.timezone = "US/Central"

For whatever reason, there is no configuration for the module in Apache, so you need to create that too:

Add /etc/apache2/mods-available/php5.conf

<FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Order Deny,Allow
    Deny from all
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
    Order Deny,Allow
    Deny from all
</FilesMatch>

Seems that when PHP 5 install it does enable the Apache module—it just doesn’t configure it to parse PHP files. The above was copied from the Sun-Dragon and works fine.

June 09, 2020

Porting users to Pi

Porting users from the Sun-Dragon to the Web-Pi went pretty smooth. This article talks about how to do this in a complete way. I don’t have many users so I did something more basic.

There are three files that contain user information:

  • /etc/passwd

  • /etc/shadow

  • /etc/groups

I could simply copy the entries for the users/groups into the same file on the Web-Pi. This effectively creates the users and groups. Now I just need their home directories. For that two items need to be considered: mount points and file permissions.

Some users have a mount point in their home directory. These are not typical users but backup accounts, and the mount point is for archives. I don’t want to copy files from the mount point. For that we need the x option.

We do want to preserve file permissions when doing the copy as home directories need to be owned by their user. For this we need the p option. I don’t know what would happen if the users were not setup before doing the copy. Presumably the directories would be owned by unknown users/groups and the user and group id listed. That would probably work fine, but I already copied the users so didn’t find out.

On the Sun-Dragon I copied all the home directories into a holding area and removed one user—me—from the list. I already have a directory on the Web-Pi and I don’t want to overwrite it.

cp -rpx /mnt/sun-dragon/root/move/* /home/

That worked, and now the users are synchronized.