Keeping things simple

Posts Tagged ‘Game development

Add routes on VPN connect with Powershell and Task Scheduler

with 12 comments

At my company we use a Microsoft ISA server for our firewall/VPN server. To be able to access the servers at my company via VPN required me to do one of two things:

  1. Use default gateway of the remote network
  2. Add static routes each time I connect via VPN

Option number one has the drawback that in such a scenario all my traffic would be directed through the VPN connection. Since my company has a very restrictive security policy which allows me to access only a couple of servers (TFS, SQL server, …). That effectively means that when connected to the VPN I can not use the internet or any other network resource.

Option number two requires that you add each of the routes to the routing table every time you connect the VPN. This can not be done via a batch script since the IP of the gateway changes on each connect.

So I thought to my self that there should be a better way to do this. With some basic Googling I quickly came up with an elegant solution. The first step towards the solution was a piece found on this blog. The blog discribes the very same problem that I was facing and provides a simple Powershell script that handles the routes. This Powershell script although it does what is need efficiently didn’t completely satisfy me.

Why? Well simply because I lazy and don’t like having to click on a power shell script on the desktop every time I make a VPN connection.

Doing some more Googling brought me to a Technet page that described how to use the Windows Task Scheduler to trigger the Powershell script execution on each VPN connect. Modifying the snippet I created this command which is executed in the Powershell command prompt.

schtasks /create /F /TN "VPN Connection Update" /TR "Powershell.exe -NonInteractive -command C:\vpn.ps1" /SC ONEVENT /EC Application /MO " *[System[(Level=4 or Level=0) and (EventID=20225)]] and *[EventData[Data='VPN NAME']]"

In this command change the path to your script, and change the last part where it says VPN NAME to the name of your VPN connection. This will ensure that the Task scheduler executes your script only and only when you connect that specific VPN connection. The complete explanation of the settings in the command can be found on before mentioned Technet page.

So I was almost there with the solution but the script it self did not satisfy me because I had to add multiple route and ensure that the routes are not already existing. I modified the original script to this version.

# ---------------------------------------------------------------------------------------
# Initial version:
# by Chris @ 30.9.2008
# ---------------------------------------------------------------------------------------
# Modified version:
# by Luka Ferlež @ 6.10.2010
# ---------------------------------------------------------------------------------------
# Add IP routes across a VPN via a DHCP assigned IP address
# Configuration
# ---------------------------------------------------------------------------------------
# Route IP address
$ips = @("", "", "")
# VPN connection IP
$vpnIP = "192.168.90."
# ---------------------------------------------------------------------------------------
# Get the IP address of the VPN connection
$vpnip = ipconfig | findstr $vpnIP
# ---------------------------------------------------------------------------------------
# If we don't have an IP address on the VPN, error and quit
if (!$vpnip) {
"You do not have an IP address on the VPN"
# Trim any leading/trailing whitespace
$vpnip = $vpnip.Trim()
# ---------------------------------------------------------------------------------------
# Split the contents of $vpnip in to an array
$vpnip = $vpnip.Split(" ")
# ---------------------------------------------------------------------------------------
# Find out the depth of our IP address in the array
$bit = $vpnip.Length - 1
# ---------------------------------------------------------------------------------------
# Get out just our IP address on the VPN
$vpnip = $vpnip[$bit]
# ---------------------------------------------------------------------------------------
# Delete routes if existing
foreach($ip in $ips) {
$hasRoute = route print | findstr $ip
if($hasRoute) {
"Deleting route " + $ip
route delete $ip
# ---------------------------------------------------------------------------------------
# Add whatever routes we need
foreach($ip in $ips) {
"Adding route " + $ip
route add $ip MASK $vpnip

This script allows you to simply add the necessary routes at the top of the script, and the script will process them, enjoy.

Written by Luka Ferlež

October 6, 2010 at 22:21

The storyboard

leave a comment »

The storyboard for what I’m trying to do here is quite simple.

Now game publisher have released several series of management games so called tycoon games. What I have always found lacking, was that the games where not deep enough in terms of company management. The games always focus on building a certain industry, selling or transporting the goods to the end customer. That’s where most tycoon games stop, not giving you the depth of full company management. Like human resources, setting salary’s, unions, advertising, organizing company departments to function like at optimal levels. Not to mention setting the goals for your R&D department, picking your CEO’s, CTO’s., CAO’s etc. for your company.

I would also like with the full depth of the managment part of the game, have access to several industries. Like production, retailing, transportation, construction, real estate, media, hotels etc., at your desposal to work with.

If you combine all of this aspects of the game, you get a quite a range of possibilities and long term playability. That is just the basic story board.

Written by Luka Ferlež

March 18, 2008 at 21:23

Game layers

leave a comment »

Ok lets start with the game design, first off all to outline the available layers of the game. Once I complete all the layers, hopefully they will stack up nicely, and provide me with a playable game.

Basic game layers:

1. Map layer
2. Resources layer
3. Objects layer ( buildings, roads, etc.)
4. Construction layer
5. Economic layer
6. AI behavior layer
7. Random events layer
8. Game development layer ( general developments as the game progresses – population rise, economic states etc.)
9. Object behavior layer
10. Data layer ( file system)

Now I might add some or drop some layers from the picture as the development process goes on, but this should be the basic layers that the game should consist of.

Written by Luka Ferlež

March 18, 2008 at 21:21

Start of a slow begining

leave a comment »

I am quite of a casual gamer, you know that type that always complains and always wants more and more of features etc. I understand game developers have a hard time of developing games and adjusting them to please as much gamers as possible. Since I am a software developer my self, and I always have to bend over for my clients, whose count fortunately is not in the millions rather just a dozen of those super smart “managers”, you could say that i have it easier then the game developers.

I have often thought about writing my own game, to correct all that stuff that i found lacking in the games i played. I found often that the games had a good start, but at a certain point it seams like the development stopped, and the features that could have been implemented have not been.

Until now I did not think that one man, without no previous knowledge about game development, directx, graphics and etc. could do, I am a back end, enterprise solution developer, so drawing is not something that I am good at. But now after a saw a few demonstrations by Microsoft, on WinDays, TechEd and community conferences XNA Studio could solve a lot of my problems.

So off to install XNA. First to download the installer, some 80 MB download free from microsoft, and lets try it. But then i find out, I dont have a habit of reading those readmes and so on, that you need Visual Studio Express C# SP1 installed. So I figure this has to be an install bug, since I have Visual Studio Team System SP1 installed on my laptop. But <span style=”font-weight: bold;”>no </span>Microsoft decided that for now it would only support the Express version of Visual Studio for use with XNA Studio. So i download the C# Express version, and install it the same with SP1. Next i find out that the Express version does not support my favorite add in ReShaper, which i find as an essential tool for any serious development. But luckily Microsoft is considering running XNA Studio on other version of VS in the future.

So to recap, to start with XNA you need:
1. Visual Studio Express C# (no exception, there is no hack to run XNA on other versions of VS)
2. Visual Studio Express SP1
3. XNA Studio 1.0 refresh

The OS on my laptop is Vista, and XNA Game Studio does not by its spec support Vista, but fearless as I am, I did it anyway, so far I did not have any problems.

Loaded the SpaceWar example and started to try to figure it out 🙂 keep you posted

Written by Luka Ferlež

July 22, 2007 at 21:18

Posted in Uncategorized

Tagged with , , ,