I'm working on allowing players to share their systems with a server. this will hopefully get integrated into PA Stats once it's ready, but for now it is standalone. The mod adds a "PA Stats Systems" button to the load_planet scene and a "Share System" button in the system editor. The nice thing about doing it this way is that I don't even need to touch the new_game scene at all. You can just go into new game, click load, and go get the system you want off the server. The mod as it stands now just treats the server the same as local storage, but I plan to add more features to it. If the saved systems list gets long, I need to be able to search, sort, and paginate. I also need to show the display name of the user that uploaded it. I haven't written any server code though. Right now I just have a couple php files running on a local webserver for testing. To get this integrated with PA Stats, the server will need an API I can talk to. I'll try to describe the server API here; The client side isn't close enough yet to justify working on the server, but I am putting this here just because I don't have a better place to put it. Once it gets to be time to work on the server and integrate this into PA Stats, would someone be able to help work on the server side? I'm not familiar enough with Scala to figure out how to do it without leaving a path for injection attacks or server-crashing bugs. *Edit* Better description of the server api.
As an added benefit to integrating this with PA Stats, I can imagine eventually being able to create a link on each PA Stats page to a page for the system it was played on. We could have some stats for the system itself over many games. This would mean automatically creating an entry for systems as they are played though, which could make the database a bit messy.
This will be a very nice improvement to the PA Stats system! I can't wait to see the finished product.
If I end up implementing a way to measure the popularity of systems, I bet we could tie that into automatching.
Why make the system unique? 2 People may create the same system randomly, how do you show them the resulting error?
Oh yeah, if the server sends back anything other than "true", I'll just display it as an error message. I guess there isn't really a need to make it unique though. The only time it will ever happen is if someone loads a PA Stats system and then tries to save it back without any changes.
Well you could define a method to ask the server if the system already exists or something like that.
I guess. What is the benefit to doing it that way and adding a new network request over just doing the same check on the server and returning an error? The way I have it set up right now, the duplicate check is done by the database. This is the fastest way to do it, but leaves a constraint on the amount of data we can store. It probably is better to do the check on the server by adding an extra SELECT call at the start of the database transaction. I'm going to check for duplicates every time I save anyway, so I don't see a need to double up on the network traffic.
I so don't care about a few kb of network traffic But yeah maybe the best way would be to have the store method return an error code so you can tell the user what is wrong.
I'll do it that way, then. I wasn't thinking as much about your bandwidth as just network latency. I usually try to avoid putting a SELECT and an INSERT into the same database transaction because I thought it locks the table, but it looks like that's not the case for InnoDB. Doesn't matter given the volume of traffic this mod will see, I guess. Habits are hard to break.
ok. The other question I have is about the way it is storing systems. I'm just throwing the whole json string right into that field, but I don't see any reason why it can't split that up and put planets in a separate table. If you think it will ever be useful to do more with these systems than just send them to the client, that might be useful.
Yes splitting that stuff up would be pretty cool. PA Stats already has a planets table that stores the data on the first planet as shown on the page. I've not gotten around to make it work with whole systems yet. Currently it just dumps a new record into the planet table for every game and that's it.
I would love it if PA Stats collected the same system information as my mod and stored it the same way. I think that opens up a lot of new possibilities, like being able to get the system id from PA Stats and go play on the exact same system or counting the number of times a system is used. That's really the main reason I wanted to hook this mod into PA Stats in the first place.
I'd love for you to dive into extending PA Stats My personal TO-DO list alone for PA related stuff is so big it could fill a few month at least.
I know that the server will need admin pages for banning IPs and deleting unwanted systems. The server could also set a rate limit if its an issue. No need to stress test though. It won't even download more than a page of systems at a time. Security isn't ever going to be perfect though. Sharing systems under someone else's name is easy.