{"id":23636689,"url":"https://github.com/pwalig/mini-rts-server","last_synced_at":"2025-11-09T04:30:21.765Z","repository":{"id":269079331,"uuid":"897972533","full_name":"pwalig/mini-RTS-server","owner":"pwalig","description":"server for minimalistic RTS game","archived":false,"fork":false,"pushed_at":"2025-02-01T19:27:25.000Z","size":132,"stargazers_count":0,"open_issues_count":15,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T19:31:16.414Z","etag":null,"topics":["bsd-sockets","c-plus-plus","college-assignment","college-project","cpp","game","game-server","rts","rts-game","server","tcp","tcp-server"],"latest_commit_sha":null,"homepage":"https://p-walig.itch.io/mini-rts","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwalig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-03T15:06:14.000Z","updated_at":"2025-02-01T19:27:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"1c5ee77c-0fc3-4618-86f1-e7d28e912e0e","html_url":"https://github.com/pwalig/mini-RTS-server","commit_stats":null,"previous_names":["pwalig/mini-rts-server"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fmini-RTS-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fmini-RTS-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fmini-RTS-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fmini-RTS-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwalig","download_url":"https://codeload.github.com/pwalig/mini-RTS-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239565632,"owners_count":19660164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bsd-sockets","c-plus-plus","college-assignment","college-project","cpp","game","game-server","rts","rts-game","server","tcp","tcp-server"],"created_at":"2024-12-28T06:14:25.592Z","updated_at":"2025-11-09T04:30:21.532Z","avatar_url":"https://github.com/pwalig.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mini-RTS-server\n\nserver for minimalistic RTS game\n\n**server is linux only**, can only be compiled for linux and will only run on linux\n\n# Building with CMake\n\nConfigure project:\n\n```\nmkdir build\ncd build \ncmake ..\n\n```\n\nOnce configuration is successful build project with avaliable tool\nfor example\n```\nmake\n```\n\n# Building with Zig\n\nProject can also be built with [zig](https://ziglang.org/)\n\n```\nzig build\n```\n\n\u003e zig c++ compiler produces much smaller executable\n\nCommand above will target the native system. If you are on other system than linux, then you can cross compile mini-RTS-server to linux (since server is **linux only**).\n```\nzig build -Dtarget=x86_64-linux\n```\nYou can replace `x86_64` with your cpu architecture if you happen to have a different one.\n\nYou will find the executable in `zig-out/bin/` directory.\n\n# Running server\n\n`./mini-rts-server \u003cport\u003e [config file]`\n\n# Configuring server\n\n`[config file]` can adjust game rules. `[config file]` consists of name value pairs.\n\n### Available values:\n\n* `millis` - duration of one game step [default: 200]\n* `maxPlayers` - how many players can play at once [default: 16]\n* `boardX` - x dimention of the board [default: 256]\n* `boardY` - y dimention of the board[default: 256]\n* `unitsToWin` - how many units player has to aquire to win the game [default: 50]\n* `startResources` - how many resources to spawn at the start of the game [default: 25]\n* `resourceHp` - starting hit points of every new resource [default: 100]\n* `unitHp` - starting hit points of every new unit [default: 100]\n* `unitDamage` - how much damage do units deal on every attack [default: 10]\n* `allowedNameCharacters` - string of characters that can be used in player names  [default: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_]\n* `maxResourceSpawn` - amount of times server will try to spawn a resource in one game tick / maximum amount of resources that can spawn in one tick [default: 1]\n* `resourceChance` - chance of resource spawning in one attempt [default: 0.1]\n\n### Example:\n\n``` config.txt\nmillis 3000\nmaxPlayers 2\nunitsToWin 2\nstartResources 8\nboardX 5\nboardY 5\nresourceHp 20\nunitHp 20\nunitDamage 5\nmaxResourceSpawn 2\nresourceChance 0.2\n```\n\nPair can appear in any order. If pair not listed default value will be used.\n\n# Comunicating with server\n\nCommunication happens via TCP protocol. Messages are separated by `\\n` character. Each message must start with one byte that designates the type of the message.\nSome messages consist of only type character others contain more data.\n\n## Message types\n\n### From client\n\n- `n` `\u003cname\u003e` `\\n` - set name or rename self\n- `j` - request join (player will be sent to game room or queue)\n- `q` - request quit (player will be removed from game room or queue, can still rejoin with `j`)\n- `m` `\u003cid\u003e` ` ` `\u003cx\u003e` ` ` `\u003cy\u003e` `\\n` - request unit of id: `\u003cid\u003e` to move to field of coordinates: `\u003cx\u003e\u003cy\u003e`\n- `a` `\u003cid1\u003e` ` ` `\u003cid2\u003e` `\\n` - request unit of id: `\u003cid1\u003e` to attack another unit (of id: `\u003cid2\u003e`) (possible to attack own units)\n- `d` `\u003cid\u003e` `\\n` - request unit to mine the resource (`\u003cid\u003e` is an id of the controlled unit) (unit can only mine resource that it is standing on)\n\n### From server\n\n- `c` `\u003cmillis\u003e` ` ` `\u003cmaxPlayers\u003e` ` ` `\u003cboardX\u003e` ` ` `\u003cboardY\u003e` ` ` `\u003cunitsToWin\u003e` ` ` `\u003cstartResources\u003e` ` ` `\u003cresourceHp\u003e` ` ` `\u003cunitHp\u003e` ` ` `\u003cunitDamage\u003e` ` ` `\u003callowedNameCharacters\u003e` `\\n` - almost whole server configuration sent to newly joined clients\n- `j` `\u003cplayer name\u003e` `\\n` - new player has joined the game room\n- `l` `\u003cplayer name\u003e` `\\n` - player `\u003cplayer name\u003e` has either left or lost the game\n- `m` `\u003cid\u003e` ` ` `\u003cx\u003e` ` ` `\u003cy\u003e` `\\n` - unit of id `\u003cid\u003e` has moved to `\u003cx\u003e;\u003cy\u003e`\n- `a` `\u003cid1\u003e` ` ` `\u003cid2\u003e` ` ` `\u003chp\u003e` `\\n` - unit of id `\u003cid1\u003e` attacked unit of id `\u003cid2\u003e` and target unit has now `\u003chp\u003e` hp left\n- `d` `\u003cid\u003e` ` ` `\u003chp\u003e` `\\n` - unit of id `\u003cid\u003e` mined a resource and resource has now `\u003chp\u003e` hp left\n- `u` `\u003cplayer name\u003e` ` ` `\u003cid\u003e` ` ` `\u003cx\u003e` ` ` `\u003cy\u003e` - player `\u003cplayer name\u003e` has aquired unit of id `\u003cid\u003e` on field `\u003cx\u003e;\u003cy\u003e`\n- `f` `\u003cx\u003e` ` ` `\u003cy\u003e` ` ` `\u003chp\u003e` `\\n` - new resource spawned on field `\u003cx\u003e;\u003cy\u003e`\n- `t` `\\n` - sent to all players in game room in regular time intervals, marks the and of each tick and a start of the next one\n- `q` `\\n` - player was sent to queue (in response to: `j`)\n- `y` `\\n` - client request accepted (in response to: `n`)\n- `n` `\\n` - client request denied (in response to: `j` or `n`)\n- `L` `\u003cname\u003e` `\\n` - client lost the game (and was moved out of game room), `\u003cname\u003e` is the name of the player who won\n- `W` `\u003cname\u003e` `\\n` - client won the game (and was moved out of game room), `\u003cname\u003e` is the name of the player who won\n \n### Board state message\n\nBoard state update is sent to every player that joins the game room\n\nStructure as follows:\n\n`p` `\u003camount of players\u003e` `;`  \n`\u003cplayer 1 name\u003e` ` ` `\u003camount of units of player1\u003e` `,`  \n`\u003cid\u003e` ` ` `\u003cx posion\u003e` ` ` `\u003cy position\u003e` ` ` `\u003chp\u003e` `,`  \n...  \n`\u003cid\u003e` ` ` `\u003cx posion\u003e` ` ` `\u003cy position\u003e` ` ` `\u003chp\u003e` `,` `;`  \n...  \n`\u003cplayer N name\u003e` ` ` `\u003camount of units of playerN\u003e` `,`  \n`\u003cid\u003e` ` ` `\u003cx posion\u003e` ` ` `\u003cy position\u003e` ` ` `\u003chp\u003e` `,`  \n...  \n`\u003cid\u003e` ` ` `\u003cx posion\u003e` ` ` `\u003cy position\u003e` ` ` `\u003chp\u003e` `,` `;` `\\n`  \n...  \n...  \n`r` `\u003camount of fields with resource\u003e` `;`  \n`\u003cx posion\u003e` ` ` `\u003cy position\u003e` ` ` `\u003chp\u003e` `;`  \n`\u003cx posion\u003e` ` ` `\u003cy position\u003e` ` ` `\u003chp\u003e` `;` `\\n`  \n...\n\nNumbers are represented as strings of characters (97 ---\u003e \"97\" not 'a').\n\n### Communication order (client's perspective)\n\n**1:** server sends `c`  \n**2:** client sends `n`  \n**3:** if server responds `n` =\u003e go to step **2**  \n**3:** else server responds `y`  \n**4:** if client sends `n` =\u003e go to step **3**  \n**4:** else client sends `j`  \n**5:** if server responds `q` =\u003e wait until server sends `p`, then `r`  \n**5:** else server reponds `p`, then `r`  \n**6:** server can send multiple: `j` `l` `m` `a` `d` `u` `f` messages  \n**6:** client can send multiple: `m` `a` `d` messages   \n**6:** if client sends `q` =\u003e go to step **4**  \n**6:** if server sends `W` or `L` =\u003e go to step **4**  \n**6:** if server sends `l` with client's name =\u003e go to step **4**  \n**7:** server sends `t` =\u003e go to step **6**  \n\n# Available Clients:\n\n- [Godot client](https://github.com/pwalig/mini-RTS-godot-client)\n- [Zig Bot](https://github.com/pwalig/mini-RTS-zig-bot)\n\nfeel free to write your own clients\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwalig%2Fmini-rts-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwalig%2Fmini-rts-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwalig%2Fmini-rts-server/lists"}