Code Monkey home page Code Monkey logo

sc4mp-server's Introduction

SC4MP Server

A multiplayer gameserver for the PC videogame SimCity 4. Uses python 3.8.10 and py2exe. Built to work with the SC4MP Client.

Installation and Usage

Download the latest release and follow the instructions included in the Readme.html file.

Alternatively, use the SC4MP Server Dockerizer by andreRBarata and deploy your server as a Docker container.

Compiling

To compile the source code, run the setup.py script.

API

This section is meant for developers using the server API. Here you can find examples of requests and responses from the server API, useful for creating a server scanner or client appplication for the SC4MP network.

Add server

Adds the requesting server to the requested server's server list queue.

Request

add_server <port>

Response

none

Check password

Returns "y" if the password provided is correct, otherwise "n".

Request

check_password <password>

Response

y

or

n

Info

Returns server info in a JSON dictionary.

Request

info

Response

{  
    "server_id": <server_id>,  
    "server_name": <server_name>,  
    "server_description": <server_description>,  
    "server_url": <server_url>,  
    "server_version": <server_version>,  
    "private": <private>,  
    "password_enabled": <password_enabled>,  
    "user_plugins_enabled": <user_plugins_enabled>  
}

Password enabled

Returns "y" if the server requires a password, otherwise "n".

Request

password_enabled

Response

y

or

n

Ping

Returns "pong".

Request

ping

Response

pong

Plugins

Requests plugins from the server.

Request

plugins

or

plugins <version> <user_id> <password>

Response

[
	[<file_1_md5>, <file_1_size>, <file_1_relpath>],
	[<file_2_md5>, <file_2_size>, <file_2_relpath>],
	...
	[<file_n_md5>, <file_n_size>, <file_n_relpath>]
]

Request

[
    [<file_1_md5>, <file_1_size>, <file_1_relpath>],
    [<file_2_md5>, <file_2_size>, <file_2_relpath>],
    ...
    [<file_n_md5>, <file_n_size>, <file_n_relpath>]
]

Response

<file_1_data>
<file_2_data>
...
<file_n_data>

Private

Returns "y" if the server's plugins and regions require a request header, otherwise "n".

Request

private

Response

y

or

n

Regions

Requests regions from the server.

Request

regions

or

regions <version> <user_id> <password>

Response

[
	[<file_1_md5>, <file_1_size>, <file_1_relpath>],
	[<file_2_md5>, <file_2_size>, <file_2_relpath>],
	...
	[<file_n_md5>, <file_n_size>, <file_n_relpath>]
]

Request

[
    [<file_1_md5>, <file_1_size>, <file_1_relpath>],
    [<file_2_md5>, <file_2_size>, <file_2_relpath>],
    ...
    [<file_n_md5>, <file_n_size>, <file_n_relpath>]
]

Response

<file_1_data>
<file_2_data>
...
<file_n_data>

Save

Pushes a save to the server.

Request

save <version> <user_id> <password>

Response

ok

Request

[
	<region_name>,
	[
		<file_1_size>,
		<file_2_size>,
		...
		<file_n_size>
	]
]

Response

ok

Request

<data>

Response

<message>

Server description

Returns the server description.

Request

server_description

Response

<server_description>

Server ID

Returns the server ID.

Request

server_id

Response

<server_id>

Server list

Returns the server list in a 2d JSON array.

Request

server_list

Response

[  
    [<server_1_host>, <server_1_port>],  
    [<server_2_host>, <server_2_port>],  
    ...  
    [<server_n_host>, <server_n_port>]  
]  

Server name

Returns the server name.

Request

server_name

Response

<server_name>

Server URL

Returns the server URL.

Request

server_url

Response

<server_url>

Server version

Returns the version of the SC4MP Server that the server is running on.

Request

server_version

Response

<server_version as major.minor.patch>

Time

Returns the time in the server's timezone.

Request

time

Response

<time as Y-m-d H:M:S>

Token

Returns a radomized token that is used for server verification.

Request

token <version> <user_id> <password>

Response

<token>

User ID

Returns a user_id from an SHA-256 hash of a concatenation of the user_id and client-side token. Used to verify that the server has the user ID on record.

Request

user_id <hash>

Response

<user_id>

User plugins enabled

Returns "y" if user plugins are permitted, otherwise "n".

Request

user_plugins_enabled

Response

y

or

n

sc4mp-server's People

Contributors

jflann avatar kegsmr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jflann iqionly

sc4mp-server's Issues

Server host/port doesn't update if the old host/port are being used to host a server with a different `server_id`

�[90m [01:11:05] [SC4MP/Thread-6] (ServerList) [INFO] - "flann_02_namteam" already found in our server list
�[93m [01:11:05] [SC4MP/Thread-6] (ServerList) [WARNING] Resolving server_id conflict...
�[93m [01:11:05] [SC4MP/Thread-6] (ServerList) [WARNING] - keeping the old server!
�[90m [01:11:05] [SC4MP/Thread-6] (ServerList) [INFO] - requesting to be added to their server list...
�[90m [01:11:05] [SC4MP/Thread-6] (ServerList) [INFO] - receiving their server list...
�[90m [01:11:06] [SC4MP/Thread-6] (ServerList) [INFO] - done.```

Ensure server always exits safely

At the moment there's no safe way to shutdown the server. So far it hasn't caused any problems, but there is a chance that the server could be in the middle of an important operation when the process is killed.

The best way to ensure the server always exits safely might be to handle the keyboard interrupt and have it trigger the server to cleanup and shutdown.

Note: pretty sure the keyboard interrupt wouldn't work on Windows distributions, but that seems like a Windows problem...

API docs

Finish the API docs, so that people can make server browsers or even their own custom clients.

Add claims timeout

Default 1 hour or None

Would restrict new claims on a server until this duration elapsed from the last new claim.

ServerList server_queue fills with repeated server entries

ServerList.server_list() should check if a server is in the queue before adding. This behavior is likely responsible for slow synchronization of servers as the requests to add to the queue either end up at the end of a long queue and may be purged from that queue when it's randomly pruned, or they may not be added to the queue at all if its full when the request is handled.

Include city name in server-side savegame filenames

Right now, savegame filenames on the server use the format <x_coordinate>_<y_coordinate>.sc4

It would be easier to identify savegames if they used a format such as (<x_coordinate>, <y_coordinate>) <city_name>.sc4.

This however would require the DBPF class to read the city name string from incoming saves.

Reserved tiles

Add the ability for server owners to reserve tiles and reject all claims on them. Would be useful for blocking claims on all-water tiles.

Automatic creation of firewall rules

Create inbound firewall rules automatically when starting the server. This would most likely only be needed on Windows, as the Windows firewall is rather annoying. Other Windows applications create firewall rules automatically, so this is something good to look into.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.