How can I prevent memory interferences in a computer game - unity3d

I am building an extension pack for a single player computer game, the extension pack will be purchased with steam's API and then I will have a representation of all the steamids of all the players with the items that they have purchased in my database.
Here's my concern: when a player logs in and sends a request to the server to get all the extension packs that they own and receives a response back, there needs to be some sort of a representation of the answer in the code, whether it is a boolean that represents access to a specific extension pack or a disabled button for items that they don't own. Can't players just edit that button/boolean using dll injection to gain access to that extension pack or even monitor the response from my server and change it? What would be the right way to do such a thing?

Related

Get token metadata inside the smart-contract for game functions

Context
I'm working on my first Game working with a Smart contract and I have some question.
On my game I have characters and cards, and both player will duel each other using one character and 10 card each.
For that, no issue: All players and cards metadata are stored into an IPFS buckets, and some extra metadata (like experiences) are stored into the smart-contract to be updated by the game.
The problem
Now I want to be able to create a duel function into my smart-contract. But I don't know how I can access to players and cards metadatas to be able to know you'll win.
"Solutions" I have in mind
#1: I never saw any IPFS fetcher to get the metadata, nor JSON parser.. So it's probably not the good way to do it.
#2: Do I have to implement a mapping(uint => Players) private playersMetadata; into my contract and load all metadata on it to be able to use it on the duel function ??
But #2.1: It'll enlarge the storage needed a lot !
And #2.2: How can I even load it ? By creating a function setPlayer(uint idx, Players playerMetadata) and mint 10k+ times this function ? It'll cost me so much !
#3: Do not implement this function on the smart-contract and do it on my web-server.. But I don't like that because I want the user to be able to read the smart-contract code and trust it (but don't trust me). So if I do it on my server side, they'll not be able to trust the function.
Thank you for helping me ! Have all a good day
There's no synchronous and straightforward way to access off-chain data (including IPFS, since it's on a different chain) from a smart contract.
You could use the oracle pattern to request the specified IPFS data from an offchain app that sends it back to the contract asynchronously (in a later block). But since one of your concerns is users' trust in the code, and this pattern introduces an element that the users can't control (the offchain app can theoretically pass to your contract a different value from what is actually stored on the IPFS), I won't go deeper into this approach.
Another option is to move the metadata required for the fight logic to the contract. You can shift the transaction fees to the users, so each time they want to perform an action (e.g. create a card, update a character, fight other player), their wallet will pop up asking them to pay the transaction fees.
Usually onchain games require a significant amount of data to be transferred. Some game authors make use of sidechains (e.g. Axie Infinity and their Ronin chain, which is a layer 2 chain connected to Ethereum), where the overall fees can be significantly lower (but a chain without fees would attract spam transactions flooding the network). This is also one of the approaches worth taking a look at.
Or possibly, smart contract just might not be a good tool for your use case. You could also create the game in a web technology, opensource the code, make getter endpoints publicly available, so that anyone can verify that the code that runs on your server really does what you claim it does.

How to Identify Sever and Client Seprately in Unity 3d

I am trying to understand data synchronization in Unity network development.
First Problem that I am facing is to understand unity3D server client model.
1
My basic understand is that one machine behaves as server + client and other simply client.
But in following graphics when hosted from PC build there is no server at all????
When I host it from Unity Editor now there are both server + Client.. why???
2
The other problem I am trying to solve that is to make such a behavior in which if I press space button at server it increments the server score.
Same goes to client when space is pressed at client it increment the client score.
No progress at all because I am unable to figure it out how to separate the server date from client data. Trying to get the reference of two different Text objects if it is server it gets the server text from hierarchy and if it is client make it to get the client text object from hierarchy.
I hope Graphics are self self explanatory.
When you host from standalone builds you can't see who's the host directly in inspector on client. You can create UI to display information about network identity and make sure everything is correct.
for the first question, remember:
When you Join game as a Host You are Server + Client
When you Join game as a Server you are only server.
When you join game as a Client you are only client
You check these thing in build and develop your OWN GUI to view the checks as you mentioned.
Yes you can differentiate client and server using these checks
if(isLocalPlayer){
//yes this is the local player
//The class must be derive from networkBehaviour to access this property
}
and You can also use Network class to check is Server.

networkView ViewID RPC in UNITY

I'm new to unity, I thought it was going to be a piece of cake, but now I'm thinking I bit off more than I can chew.
I'm trying to make an authoritative server game, where the client players send their desired movements to the server, then the server sends back to all clients, the actual movement position information.
When a client connects to the server, the server uses RPC calls to create the player objects on all of the clients. In the player script Awake() function, I create a NetworkView object, and attach it to the player object dynamically for synchronization. So all player clients are doing this as each new player connects to the game server, so everybody can see everybody else.
The problem I have is when the player client wants to move, the client tries to do RPC call to the server using the dynamically attached NetworkView, to send the desired movements, but the RPC call fails, giving an error on the SERVER (not the client), that the server cant find the NetworkViewID.
My code didn't print this error, so I guess it must be code deep inside unity that printed it when it received the RPC message from a client, and tried to match it up with a corresponding NetworkViewID on the server, when it could not, it printed the error?
I'm just wondering how unity works.... does object "A" on all clients and server have the same NetworkViewID, and object "B" on all clients and servers have the same ID (but different ID from "A")?
If so, how do NetworkView objects that are instantiated on clients and server know which ID to assign themselves so they all match up when this is being done on different computers over the network? Is this done automatically by unity, or do I have to send the ID myself to all NetworkView objects?? But I cant talk to the objects to tell them which ID to use, since I dont know the NetworkID in the first place, since that is apparently needed to talk to the NetworkView objects! Its like trying to ask someone their name, but you need their name in order to ask them. So that cant be how it works.
My problem is that at first, the player object has no NetworkView on it. After the object is created, the script on player object dynamically attaches a NetworkView. Since this is done on all clients, and on the server almost at the same time, how will they all know to assign the same ID to the same objects, so that they can RPC each other?
Also I read somewhere that the "owner ID" is always zero?
Sorry I'm new to unity, and trying to figure it all out. Can anyone give me the inside scoop on all this?

Efficient video game server data storage?

I'm currently developing a multiplayer iOS video game where I want the players data to be stored in the cloud. In the game the player creates an area by placing items, planting trees etc which other players can then visit and walk around in realtime.
From the game map side what needs to be stored is:
A 50x50 tile grid - The type of tile (grass etc) and the height of
the tile
All of the placed items and any associated item specific data (A tree for example would store when it was planted)
On the player side I need to store their:
Character customisation
Inventory
The information would need to be read fairly infrequently (every time a client connects to the area) but would need to be written back to fairly regularly (every time an item is placed etc) so that any future connecting client would be reading the correct data.
My question really is where to start with regards to storing this data in an efficient way for the server? I considered using several XML files to store different portions of the map and then storing each of the other parts (Inventory, Character etc) in their own XML file. But is this the most efficient way of doing it from the servers perspective? I want to minimise the amount of data it has to write back when the client updates :)
TL;DR: Use a database and the Unity plugin for said database.
Managing an XML file via server is just going to cause a bunch of file locking/synchronization problems that you shouldn't be dealing with manually (unless, this is the focus of your project/research).
There are plenty of database backends that you can use, and that work well with Unity. A few I can think of off-hand:
• Parse.com --- they have a Unity plugin
• Write your own HTTP-based web server (in PHP/MySQL, JavaScript, Ruby, whatever) and then use a REST interface library (a bunch on the Unity Asset Store) to talk to it and store your data.

Send server information to client

Last semester we had to develop the game Ludo in JavaScript and HTML/CSS. That was pretty easy. Now we have to develop a backend with GWT (Java) to create a multiplayer game. Sadly, we haven’t got much information on how to develop with GWT and the exercise is quite difficult at the beginning.
At the moment I am trying to create a kind of lobby where different players can join.
My idea was to use some input fields, where the player could enter his name and join the lobby. But I don’t know how to give the other clients the information that a new player has joined.
I created an asynchronous interfaces (RPC) where a player could submit his name to the server (Like this example). This works ok. But how should I share this information? Our docent said we should use JSON to share information’s, but I don’t know how this should help in this situation.
Is there a way to send information’s to the clients? I read a lot and just find to use additional libraries as gwt-comet.
I have really now clue how I could go on. I’m thankful for every help and information!
Greetz
You have two options: push and pull.
"Pull" option:
Other players get required information when they join the lobby and/or do something else. You can also schedule to pull this information periodically (like once every 10 minutes). You can use the same RPC mechanism to get data from server to a client. "Pull" means that a client initiates the request and server responds with the information.
"Push" option:
When a new player joins, the server pushes this new data to all other players. The best solution depends on your game implementation. Comet is a good option, as Jean-Michel mentioned, but it's more complicated and "expensive" from resources point of view. You should use this option if you need real-time status updates for your game.
I would suggest Errai and ErraiBus in particular. From Java perspective you are only sending some events via event bus (observer GoF pattern) and all the magic with Ajax Push is happening behind the scenes.