GithubHelp home page GithubHelp logo

citiesskylinesmultiplayer / csm Goto Github PK

View Code? Open in Web Editor NEW
725.0 59.0 100.0 13.19 MB

Source code for the Cities: Skylines Multiplayer mod (CSM)

Home Page: https://citiesskylinesmultiplayer.com/

License: MIT License

C# 98.37% PowerShell 1.61% Dockerfile 0.03%
cities-skylines mod multiplayer c-sharp protobuf litenetlib cities-skylines-game steam-workshop hacktoberfest

csm's Introduction

CSM - Cities: Skylines Multiplayer

Discord Build status Steam File Size

Quick Links

Introduction

CSM is an in-development multiplayer mod for Cities: Skylines. This mod aims to provide a simple client-server experience where users can play and build together in a single game.

Instructions to download and install the latest build of the mod can be seen below. Frequently asked questions, developer information and other information can be found on the GitHub wiki for this mod.

Feel free to join the development Discord server here.

This mod and its source code is licensed under the MIT license.

Download & Install

The easiest way to install this mod is from the Steam Workshop. Remember to enable it in the content manager.

To install the mod for other platforms than Steam, follow the instructions below:

  1. Download the latest release from Github
  2. Extract the folder and either run the install script, or copy all the *.dll files to the mod directory:
  • Windows: %LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\CSM
  • Mac OSX: ~/Library/Application Support/Colossal Order/Cities_Skylines/Addons/Mods/CSM
  • Linux: ~/.local/share/Colossal Order/Cities_Skylines/Addons/Mods/CSM
  1. Open Cities: Skylines and enable the mod in the content manager

You can also download the latest development builds by following the instructions below:

  1. Navigate to the list of CI builds here
  2. Click on the latest build with a green checkmark
  3. Under the Artifacts heading, click on CSM [Version]

If you want to build the mod yourself, follow the developer instructions in the wiki located here.

Usage (Server)

  1. Create a new game or open an existing game (if using an existing game, make a backup!)
  2. Open the "Pause Menu" (using the ESC key)
  3. Click the Multiplayer button on the top of the menu.
  4. Update any of the fields to your liking, click Create Server.

Usage (Clients)

  1. Click Join Game on the main menu.
  2. Enter the server and your information.
  3. Click Connect to Server and wait up to 60 seconds.

Patreons

We would like to give a special thanks to the people backing us financialy through Patreon

  • Henrik Nielsen
  • Daimyo
  • Motey
  • Ewan Colyer
  • Kevin Prüßner
  • C Zhang

Contributors

A full list of contributors can be found here.

csm's People

Contributors

bluenix2 avatar botprizm avatar brettpenzer123 avatar cameronct avatar cwmlolzlz avatar dfrankes avatar dominicmaas avatar elitenudel avatar guusje2 avatar hebestreit avatar hibo98 avatar jaspervriends avatar joaogl avatar kaenganxt avatar lgoenner avatar mahgo avatar malaud avatar mightywizard avatar ollelogdahl avatar rvnovae avatar sander0542 avatar spnda avatar treholt3103 avatar woodybriggs avatar

Stargazers

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

Watchers

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

csm's Issues

Unable to connect to servers

With your new guide that fixed my "build" issues, (thanks btw). I have tried to play with my friend. However, there is no server cfg or properties. So i dont know where i put my own ip to host, Also i cannot port forward 4230 on my super hub. And i dont know any way to change the port either.

Please help!

Thankyou

Move command logic into commands.

At the moment command logic is stored within the Server or Client classes (depending on what it does). This works currently, but will be unsustainable as more and more commands are added.

I'm adding this here to remind my self later.

  • Add two virtual methods to the base command, one for server side logic and the other for client logic.
  • Move current logic into these virtual methods.
  • Change server and client classes to auto call these methods.

Installation question

Hey, in your installation, it asks for the "steam folder directory" in power shell. does this mean the steamapps folder or the Local Appdata location of the original install?

EDIT: I think i figured it out, i used the explorer directory of the overall steam folder. sorry for the stupid question. IF that wasn't correct, i ask for some guidance, thanks!

Add support for DLC

Describe the bug

The mod does not support buildings and other things added by DLCs.
Even if everyone connected has the DLC, the buildings do not display and are replaced by basic buildings.

How to Reproduce

Steps to reproduce the behavior:

  1. Start a game with DLCs enabled
  2. Join the host
  3. Place a building of a DLC and look at what is happening on the Client side and the Server side

Expected behavior

Normally, the DLC building should be placed correctly if all connected people have the DLC.
If this is not the case, then do not build anything and send a message to the users to warn that everyone does not have the DLC rather than building a random buggy building.

Screenshots

Here is an example with the DLC "Green Cities" :

View of the person building the building :
sortie d eau ecolo vue serveur - construction par client - dlc ok vue cote client

View of the person who does not build the building :
sortie d eau ecolo vue serveur - construction par client - dlc ok vue cote serveur

You can see that when someone builds a DLC building (here an Ecological Water Outlet), this person sees the right building but the other people see a random buggy building.

Additional context

To get this bug, we both had the DLC "Green Cities" loaded.

Another example

If the client connects to the server on a different map than the server, some bugs appear.

Note: We have not tested with two vanilla maps*. We have tested with a "Snowfall" DLC map on the server and a classic vanilla map* on the client.

*What I call "Vanilla Map" is the maps that everyone has access to with the basic game, without DLC.

Note: The Client did not have the DLC "Snowfall" unlike the server that had the DLC.

Here is the screen of the view of the person who had the DLC map "Snowfall" (Server) :
map dlc snowfall cote serveur - map classique et pas le dlc cote client

As you can see, when the client builds a road, this strange thing appears on the server side.

This concludes the summary of this problem.

A little message for developers

I know that for the moment you are focusing on the synchronization of all vanilla elements but I still wanted to mention this problem :)

Also, your mod is fantastic and many people were waiting for it with great impatience !
It's good to see this mod finally working ! :')
You're doing a great job ! Thank you very much for all ! :D

Roads not syncing up

A friend and I connected to each other.
We can't see any roads the other person built, but money and building sync up fine.

same key?

An element with the same key already exists in the dictionary. [System.ArgumentException]

Details:
No details

connecting roads to existing roads cause bugs

It seems that connecting a road to an already existing road sometimes create problems, it seems to happen when the road is trying to connect with a segment, and not when it is trying to connect it to an existing node.

Cant Host Server

Hi,

I would like you to thank you for your amazing work. There is a Issue. I intalled the mod manually and Cities Skylines actually read it perfectly, the mod was suscesfully installed but there is a litte issue. I cannot host a servere, when I click on Host game it dosent do anything, but when I click join its works.

I would like to Host a game for me and my friend but it dosent do anything, can you help us.

Thank you for advance,

Greetings,

PS:Sorry for my bad english

Serializing complex objects

I'm working on the code to sync Buildings between server and client. To do that i think i have to serialize the building object and send it. I can use Surrogates to allow serialization, but i will have to write like a bazillion of them becourse of the complexity of the Building object. are there any other way to handle this, or is Surrogates the only way?

Syncing Building id between server and client

When a building i created it generate a random ushort 'Building id' that identify the building in the Instance.m_buildings.m_buffer[id] Array. Syncing relocation or destruction of the building requires this id to be known. but since its a randomly generated number it does not sync between Server and Client.

We need to somehow sync the Building id, so the same building id refers to the same building in both server and client.

Connection Screen

Im not too sure if this mod is completely concept. But i cannot type anything in the multiplayer connect screen
Also im not sure if i built it right. I just right clicked and built it, as when i tried your way, i couldnt find a button to build it.

Thanks, Again...

Can't reconnect to savegame

When i'm trying to load an earlier safe game by sharing the save game file, the client won't connect to the server.

The following error are shown on the debug display
error reconnection

Clean up Git Folder

Is your feature request related to a problem? Please describe.
.vscode and DLL should not be in the src folder

Describe the solution you'd like
Use git ignore to remove it

Can't Pause

First of all thanks for an amazing work, this really has enormous potential.

I just did a test over LAN. The sync of speed works as it should (Really impressive) but it can't handle Pause.

Steam Workshop

Is it possible to upload the Alpha/Beta version of this mod to the Steam Workshop? I would be a nice way for users to download the mod and have automatic updates

Mod Timeline

hey, i have few friends and myself interested in the Mod. We were just wondering how far along you were with implementing connections to servers and such. We did the basic install. let us know if you need testers!

Connected, but not getting roads, money, etc

Hi,

I installed this mod on my 2 systems, but when I connect them. It gives a green text saying connected, but when I place roads they are not visible on the other game. Why does this happen?

I am using a local direct IP connection

Unlocked areas does not update the zones on the reciving end

When an area is unlocked the new zones created when roads are build does not show on the client reciving the unlock command. The zones work, and it's posible for the reciving client to paint the zones, but the client is "blind" for the zonechanges

Manage Server

The manage server button does not work, I can create a server yet the manage server button will not work.

Zone and Road Syncing Issues

Describe the bug
Areas zoned by either the host or the client do not always sync up. The chat box shows errors but these are cut off. The same problem also occurs with roads created by either host or client not showing on the other end, with the same error shown in the chat box. A large number of these error messages appear in the chatbox when this issue occurs.

To Reproduce
Steps to reproduce the behavior:

  1. Start new game with same settings on client and host
  2. Join game
  3. Create zoned areas

Screenshots
Host:
screenshot 6

Client:
paul screen

Errors shown on host:
errors

Other Info
We are not using any other mods or DLC, and are using stock C:S maps not from the DLCs. The connection is made over the internet rather than a local network.

Chat messages do not always appear.

Chat messages do not seem to always appear after being sent. If a host sends a chat message, the client will receive it, but if the client sends a chat message, the server will not receive it and instead report an error.

[15:39:18.2518] [version] [Info] Encountered an error while reading command from <IP>:
[15:39:18.2598] [version] [Info] System.NullReferenceException: Object reference not set to an instance of an object
  at CSM.Commands.Handler.ChatMessageHandler.HandleOnServer (CSM.Commands.ChatMessageCommand command, CSM.Networking.Player player) [0x00000] in <filename unknown>:0 
  at CSM.Commands.Handler.CommandHandler`1[C].ParseOnServer (System.Byte[] message, CSM.Networking.Player player) [0x00000] in <filename unknown>:0 
  at CSM.Commands.Command.ParseOnServer (System.Byte[] msg, CSM.Networking.Player player) [0x00000] in <filename unknown>:0 
  at CSM.Networking.Server.ListenerOnNetworkReceiveEvent (LiteNetLib.NetPeer peer, LiteNetLib.Utils.NetDataReader reader) [0x00000] in <filename unknown>:0 

Since the stack trace stops at ChatMessageHandler I assume it has to do with the following line of code:

ChatLogPanel.GetDefault().AddChatMessage(command.Username, command.Message);

I'm assuming that GetDefault() returns null, just gotta try figure out why.

Where to Download?

I clicked the "here" link in README.md, next I clicked on the latest build, but I can not find the ZIP download. Where do I need to click?

image

Joining a game

I will be hosting the game, and i see it says a port is required. Does it matter what port i use, could i just use the default steam port 34197 or do i need to do something else?

Double nodes resulting in rendering problems and slowdown

when building a waterpipe an extra node/nodesegment is sometimes created on either client or server.
It seems that when a node/nodesegment is created two times, it can result in the game slowing down, constantly throwing rendering errors.
i belive the problem has to do with the way waterpipes are both buildings and nodes.
Deleting the extra node/nodesegment seems to sometimes solve the problem.

Dedicated Server Support

Can initially act as a relay, passing commands to all connected clients. Will encounter problems with world loading and saving. Dedicated server will have to keep track of the world somehow.

Might not be possible, leaving this here to look into later.

Building road under powerlines can break the game if there is no space for zones

When building roads under powerlines, the game can sometimes break if there is not space to make four blocks of zone on either sides of the road,

It seems to be a problem with the way zone creation are handled, and when a road build under a powerline, the powerline can block the construction of zones. the problem should be solved by going away from using dictionaries in road creation.

Couldn't connect to server.

Hello,

I am currently having problems with connecting to friend's servers,

We have port forwarded everything as a precaution through UDP and TCP to be safe.
It's not allowing them to connect to me and its not allowing me to connect to them.

We followed instructions accordingly, dlls are in the correct folders as far as I'm aware.

When we click "Manage Server" in game nothing pops up, and we cannot connect to each other's servers.

Just wondering if you have a fix for this or if this is an issue you know from experience!

Thank you,

~ D-amp

Syncing The Income displayed on the UI

The income displayed in the UI seems to be an average of the two private arrays m_totalIncome and m_totalExpenses found in the EconomyManager,
To get the Clients UI's to display the Current Income, these have to be copied from the server and send to the Client. The problem is that i don't know how to use the reflector to get and set arrays.

Also the money have been synced, and the income is now handled on the server side (which is why it has to be copied because the clients UI income as of now just show 0)

Only one person can connect at once.

Hey man. I'm super new to city skylines but I'm really interested in getting into it with 2 of my friends. Right now we can only get 1 person to connect to the host at a time. Is that working as intended or is something going wrong?

Also, you mentioned you wanted to make it easy to run. I highly recommend just sharing your mod on the steam workshop. You can literally just press the "share" button in the mod list in city skylines. That way people can just subscribe to it and it just works for them. I posted your mod already to share with my friend who was having trouble with installing through powershell, I can take it down if you want to make your own posting. It's super easy to update it and stuff and to install it people just have to press subscribe and it gets added to their mod files! I highly recommend looking into it!

Workshop link: https://steamcommunity.com/sharedfiles/filedetails/?id=1556336761

Send game save file on connect.

Introduction

When a player connects to the server, both server and client should be paused. Once paused, the server needs to grab a copy of the save game (this can be done with raw IO requests if there is no exposed method), and send it to the client (via TCP to ensure nothing is lost). Once the client receives the world, it needs to then load it (somehow) and unpause the game. To prevent the user from unpausing the game during this process, a giant loading screen will be displayed above all content.

Key Points

  • Loading screen that takes up entire window (above all content), replaces the current connection status info.
  • On client connect, pause the game for everyone, and show a loading window for everyone (client connecting).
  • Locate the game save on the server, either Cities: Skylines exposes a path to the game save, or we can locate it manually (set folder, and the gamename save which should be exposed in the API).
  • Send the game save over to the newly connected client, entire save must make it to the client (can be in multiple packets).
  • A client needs to be able to download a save game, put it in the save folder (named "multiplayer" or something) and then needs to load the game. I'm not sure if this can be done when your within a game already, or if we have to quit the game, join the new world and unpause (all while still connected).
  • Allow multiple players to join simultaneously (Requires some logic for showing/hiding the overlay for all players)
  • Maybe don't block the whole game while a player is joining (We could only pause the game and queue packets for player interactions on the joining client. I don't think it's possible to let the game run because we don't sync everything perfectly but rely on the simulation threads to be in sync)
  • Enable the host to reject join requests
  • Allow joining over the Steam friends menu
  • Implement multiplayer buttons into Escape menu
  • Add sync command that updates all clients with the world. Can be used when the game starts becoming unplayable.

The host can't have the name "host"

When you host a game and enter as the host name host, this error gets displayed:
An element with the same key already exists in the dictionary. [System.ArgumentException]

Making it possible to upgrade roads

Played a few hours and found that one of the biggest problems was the lacking ability to upgrade roads, with the upgrade road tool.

We should make the syncing of this a priority :)

Syncing creation and destruction of citizens

I Tried syncing the upgrading of buildings, but the process seems bound to the education level of the citizens.

Citizens are created with a random id, and we should be able to sync the creation of them like we are syncing buildings, roads ect. and since they don't constantly have to sync but only on creation, destruction (and building upgrade) it should not be a massive resource hog.

however since both server and clients are creating citizens, i think we have to remove the citizen creation on the client side, else they will be created in double rate, and possible we are gonna have a problem with the removal of citizens where they are removed faster than in the original game, but hopefully that wont be a problem.

Building Road Sync

The ICities.dll does not contain an extension for handling roads, as it does for buildings (where it can run an extension each time a building is created or destroyed) so we need a cleaver solution to overcome that problem.

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.