The online racing simulator
Dizplay Base (C# InSim.NET based / proof of concept)

The GPL logos by Christian Candena are available under the CC-BY 3.0 license.

This is a proof of concept for a system, which I want to make a solid base, to use when you need to build an InSim application.

It is not a completed project, but I have not found any instabilities yet. If you encounter any, please let me know by posting a reply here.

Before anything, these are the people who must be noted.
DarkTimes - for the awesome library;
morpha - for helping me a lot with programming as a whole;
Dygear - mainly for always being so "that's why everything should be opensource";
You - if you feel like it, why not.

The idea of this application is very simple. It has the sole purpose to help you build InSim apps, without worrying about the core things. I like to think of it like the jQuery of InSim.NET. But that's far from the truth yet.

I don't really have the time yet, to strip only the base out, so you get a bit more than that. And that's the start of a cruise app. I think it's better too, in a way, since you will have examples on how to effectively use the systems in the base.

I don't know when I'll have time to update this project either. When I do though - I'm going to post here ... obviously.

If you have any negative feedback, I definitely want to hear that. Please don't hold it back. Be it about something not being as optimized as it can be, or about something that acts weirdly. Anything. And I definitely accept suggestions on ordering and naming of classes, methods, variables - I'm not very good at that yet.

I decided to publish Dizplay Base under the terms of the GPL v3 license. Though this may change in a future version.

The code is far from what it's supposed to be yet. There are a lot of stuff that have to be removed, moved and so on. Call it a creative mess.
But other than that - it's some of the code I'm most proud of.

I'm not going to go into detail yet, so I'm just going to tell you the first steps you need to take to make this run on your server, and start tweaking it. If you need help on anything else Base-related, please do post here, and I'll do my best to help. If the question is good, I guess I will include the answer in this (the main) post as well.

So, here's where changing of connection settings happens (this is around line 30 in Dizplay.cs):

<?php 
        
public static InSimSettings iSettings = new InSimSettings
        
{
            
Host "127.0.0.1",
            
Port 29009,
            
Admin "adminpass",

            
Flags InSimFlags.MultiCarInfo InSimFlags.Contact InSimFlags.ObjectHit InSimFlags.HotLapValidity InSimFlags.AutoXEdit,
            
Interval Globals.rootInterval,
            
Prefix '!',
            
Name "^1Dizplay"
        
};
?>

What comes next is email info changes. If you want error reports sent to your email, you have to insert your Gmail email and password in Vitals.cs.


That's all for now. If I find the motivation and some time, I will post a more detailed info on how to use Button Sequences, and Queue systems.

Thank you for trying the base.
Attached files
Dizplay Cruise v0.2.zip - 567.6 KB - 1305 views
Well, you did ask for feedback.

1. For some reason the solution won't open in VS2010. That's weird cause VS11 projects are supposed to be backwards compatible now. Anyway, I had to create a new VS10 project and copy all the files and references into it.

2. I'd suggest spending some time reading the .NET Framework Design Guidelines, which contains everything you would ever want to know about naming variables, methods, classes and more. They are just guidelines, so you don't need to follow them to the letter, but I'd recommend following them as much as you can. I find it really easy to tell from looking at code whether someone has read those guidelines or not. There's also this blog post about Microsoft Internal Coding Guidelines, but that's much more down to taste.

The main naming guidelines can be summed up as follows:
  • All private fields and local variables should be lower camelCase
  • Classes, properties and methods should be PascalCase
3. You have named a bunch of your classes with weird names, such as 'Globals', 'Processor', 'Vitals'. Aside from 'globals' (more on that in a minute) I've no idea what any of them mean. I'd highly suggest using more descriptive names for your classes.

4. Having a global settings class is a bad idea for a bunch of reasons. What I'd suggest is moving this 'data' out of your program into a configuration file. .NET has built-in support for creating Settings files for you automatically (you can create application wide settings, or per-user settings) and also lets you edit them using a pretty(ish) designer UI. Right-click on your project go to Properties > Settings and follow the instructions.

5. You're using a MySQL database which is fair enough I guess. I'd suggest using an embedded database such as SQL Compact or SQLite instead, as they require no setup or configuration and can be easily bundled with your program. MySQL requires you to download, install, configure and run the MySQL Windows Service, which is a total pain and way more hassle than it's worth. In terms of SQL Compact vs SQLite, I'd go with SQL Compact just because it has first class support inside Visual Studio (so you can use the database explorer and designer etc..) and can be easily installed and updated using NuGet.

6. You are executing raw SQL statements in your code, make sure you know about SQL Injection and always parametrise your SQL queries. Instead of executing raw SQL strings you should learn about LINQ, as it's probably the single best feature of the C# programming language.

7. A good tip is to turn on Warning as Errors, which will cause any code warnings to prevent compilation, therefore forcing you to fix them. Go to Properties > Build and set Treat Warnings as Errors to All.

8. Finally I'd advise running a static code analyser over your code. If you are using VS11 Ultimate beta then it has one built in. Right click on your project and select Run Code Analysis. You can configure it by going to Properties > Code Analysis and selecting a rule set. I'd suggest starting off with a basic rule set and gradually enabling more and more rules. Eventually you'll get to a point where either all the problems are fixed, or the things it's suggesting are completely pointless. If you are not using a retail version of Visual Studio then you can download FxCop, which is pretty-much a standalone version of the same thing.
Quote from DarkTimes :Well, you did ask for feedback.

1. For some reason the solution won't open in VS2010. That's weird cause VS11 projects are supposed to be backwards compatible now. Anyway, I had to create a new VS10 project and copy all the files and references into it.

2. I'd suggest spending some time reading the .NET Framework Design Guidelines, which contains everything you would ever want to know about naming variables, methods, classes and more. They are just guidelines, so you don't need to follow them to the letter, but I'd recommend following them as much as you can. I find it really easy to tell from looking at code whether someone has read those guidelines or not. There's also this blog post about Microsoft Internal Coding Guidelines, but that's much more down to taste.

The main naming guidelines can be summed up as follows:
  • All private fields and local variables should be lower camelCase
  • Classes, properties and methods should be PascalCase
3. You have named a bunch of your classes with weird names, such as 'Globals', 'Processor', 'Vitals'. Aside from 'globals' (more on that in a minute) I've no idea what any of them mean. I'd highly suggest using more descriptive names for your classes.

4. Having a global settings class is a bad idea for a bunch of reasons. What I'd suggest is moving this 'data' out of your program into a configuration file. .NET has built-in support for creating Settings files for you automatically (you can create application wide settings, or per-user settings) and also lets you edit them using a pretty(ish) designer UI. Right-click on your project go to Properties > Settings and follow the instructions.

5. You're using a MySQL database which is fair enough I guess. I'd suggest using an embedded database such as SQL Compact or SQLite instead, as they require no setup or configuration and can be easily bundled with your program. MySQL requires you to download, install, configure and run the MySQL Windows Service, which is a total pain and way more hassle than it's worth. In terms of SQL Compact vs SQLite, I'd go with SQL Compact just because it has first class support inside Visual Studio (so you can use the database explorer and designer etc..) and can be easily installed and updated using NuGet.

6. You are executing raw SQL statements in your code, make sure you know about SQL Injection and always parametrise your SQL queries. Instead of executing raw SQL strings you should learn about LINQ, as it's probably the single best feature of the C# programming language.

7. A good tip is to turn on Warning as Errors, which will cause any code warnings to prevent compilation, therefore forcing you to fix them. Go to Properties > Build and set Treat Warnings as Errors to All.

8. Finally I'd advise running a static code analyser over your code. If you are using VS11 Ultimate beta then it has one built in. Right click on your project and select Run Code Analysis. You can configure it by going to Properties > Code Analysis and selecting a rule set. I'd suggest starting off with a basic rule set and gradually enabling more and more rules. Eventually you'll get to a point where either all the problems are fixed, or the things it's suggesting are completely pointless. If you are not using a retail version of Visual Studio then you can download FxCop, which is pretty-much a standalone version of the same thing.

I did ask for feedback! And I LOVE you for those! So, I'm going to answer in points.

1. I will have to look into that. Probably some beta-bug, or I don't know. I'll sort it out, it's just the smallest issue right now.

2. I did spend some time reading, AND implementing those already. And I like how it makes the code look more pro.
Definitely huge thanks for that. I've been wondering for a lot of time how to name my variables and classes, and everything as a whole.

3. Yes, again - huuuge thanks! I will move some methods from there to appropriately named classes, that speak more for themselves. That's going to be soon, and I'm going to post an update to this thread.

4. Yes, I've been thinking about moving the data out (not only thinking, but planning that as well in the near-future). Very nice to know that .NET has built-in functionality for that!

5. I'm using a MySQL database, because that's what most web-hosts provide, and I'm planning on hosting my database remotely for now. For the uses of the cruise app. However, for local settings and data-failover reasons, I may read on more into the types of databases you've mentioned.

6. SQL injections is something I'm well aware of. But since I want this to be more of a library, than an application, I've taken some time to look more into that. I'm currently looking on working with "Mindscape LightSpeed". So far, it looks like the easiest LINQ alternative to work with, to me.

7. That's a reasonable suggestion, but LightSpeed being in beta for VS11 brings some errors with itself too. However, I will definitely try that to see if it will bypass the Mindscape warnings.

8. I recently had PoVo recommend ReSharper to me. Definitely a good analyzer. I got the "EAP" version of it. But from my experience with it so far, if I get better at C#, or start making money from it, that's definitely something I'd consider buying.

Overall, thanks a lot! That's EXACTLY what I asked for. I really wanted to wait more before I reply, so I can upload an update to Dizplay Base too, along with my reply. But that might take a lot of time. I have already renamed some classes and variables, and overall - taken steps into organizing the code. I realize it may sound a bit silly, but I really like making my code more readable, and easier for developers after me to modify! It's one of my top priorities, after the users' (or in this case - players) convenience and code optimization.

And finally - sadly, I don't have enough time to keep a steady-pace of development, but I am trying to pay more attention to side-projects lately, and I'm hoping that can change.
-
Is_axm (sicotange) DELETED by sicotange
Figured it out
Is this the only InSim.NET based out there?
Quote from Beaver08 :Figured it out

Good to hear you've sorted it out - what was the problem with special characters though?

Quote from ADr3nAl1n :Is this the only InSim.NET based out there?

I am not sure, but if anybody wants to make improvements, you are more than welcome to do so. Because, unfortunately, I do not have enough time to keep up with it at the moment. Any recommendations are welcome as well.
Trying to understand this source...

What about those special chars errors?
It does not work for me

FGED GREDG RDFGDR GSFDG