Sure kurifu, thanks for looking into this!
first the $map is initialized like this: $map = array();
and filled with new Tile()
this is how the map is saved:
saveGlobal('map',$map);
for($y = 0; $y < MAP_HEIGHT; $y += 1)
{
for($x = 0; $x < MAP_WIDTH; $x += 1)
{
$tile = $map[$y][$x];
if(!isset($tile))
exit("tile $x $y not set");
saveGlobal("m$x$y",serialize($tile));
}
}
this is how it's loaded:
$map = loadGlobal('map');
for($y = 0; $y < MAP_HEIGHT; $y += 1)
{
for($x = 0; $x < MAP_WIDTH; $x += 1)
{
$s = loadGlobal("m$x$y");
$map[$y][$x] = unserialize($s);
}
}
And here are the functions used:
function saveGlobal($varname,$value)
{
$_SESSION[$varname] = $value;
}
function loadGlobal($varname)
{
return $_SESSION[$varname];
}
The problem should not be in the session code I think because everything else works except the array saving.
Thank you, please understand that I am a beginner at php and more of an C++ coder so please feel free to comment the code, it would help me.