Handling player travel
Posted: Sat Jan 02, 2010 7:05 pm
Looking for some input/recommendations on something - for those that are not aware, I'm working on a text-based browser RPG.
I have a table that contains 3 fields for each record: currentloc, direction, newloc. Let's say you are a location 1. There would be a record with these values in it: '1', 'North', '2', meaning your currentloc is 1, going north takes you to newloc 2.
When you are at location 1, I display a description of the area and then create/display a link that says "Go North" and the href is to a file called travel.php. In the case of the above example, in the link I'm passing parameters ol=1&nl=2.
In travel.php, I check the travel table again to make sure that you can actually go from ol (old loc) to nl (new loc) to prevent anyone trying to cheat by changing the URL and if it's allowable, I move the player there and send them back to the main page, which then updates to show descriptions of the new location.
This system is in place in my game and working fine.
Here's what's bothering me though: A smart player could keep track of what locations attach to each other and if they were careful, they could change the link to a valid link, but one that is halfway across the world from where they started.
Is there another way to handle this that could prevent such cheats?
I have a table that contains 3 fields for each record: currentloc, direction, newloc. Let's say you are a location 1. There would be a record with these values in it: '1', 'North', '2', meaning your currentloc is 1, going north takes you to newloc 2.
When you are at location 1, I display a description of the area and then create/display a link that says "Go North" and the href is to a file called travel.php. In the case of the above example, in the link I'm passing parameters ol=1&nl=2.
In travel.php, I check the travel table again to make sure that you can actually go from ol (old loc) to nl (new loc) to prevent anyone trying to cheat by changing the URL and if it's allowable, I move the player there and send them back to the main page, which then updates to show descriptions of the new location.
This system is in place in my game and working fine.
Here's what's bothering me though: A smart player could keep track of what locations attach to each other and if they were careful, they could change the link to a valid link, but one that is halfway across the world from where they started.
Is there another way to handle this that could prevent such cheats?