Problems with switching room maps
Problems with switching room maps
I have a situation where a map is shown on screen and I try to load a new map and replace the former.
I seem to do everything that is neccessary to switch room (and map), including changing room on server (had to do it server side), loading the new room and map assets and calling "loadMap" with the new room id.
The result is the screen turning white (but without any exception) and every attempt to call the component afterwards, follows with a null reference exception in the SmartFoxClient.
I must say that the SFS admin shows a complete transfer to the new room.
What am I missing in the process?
I seem to do everything that is neccessary to switch room (and map), including changing room on server (had to do it server side), loading the new room and map assets and calling "loadMap" with the new room id.
The result is the screen turning white (but without any exception) and every attempt to call the component afterwards, follows with a null reference exception in the SmartFoxClient.
I must say that the SFS admin shows a complete transfer to the new room.
What am I missing in the process?
Maybe this Log can help (including loading the first and the second map):
Code: Select all
[INFO] Configuration loaded: resources/config/OpenSpace.xml
[INFO] Requesting initialization data to OpenSpace Extension
[INFO] Initialization data received from OpenSpace Extension
[INFO] Initialization completed
[INFO] Requesting map to OpenSpace Extension
[INFO] Map received from OpenSpace Extension
[INFO] Map parsing completed (13 ms)
[INFO] Tiles creation progress: 19%
[INFO] Tiles creation progress: 36%
[INFO] Tiles creation progress: 55%
[INFO] Tiles creation progress: 77%
[INFO] Tiles creation progress: 100%
[INFO] Map generation completed (86 ms)
[INFO] Map rendering duration: 5 ms
[INFO] Map shifted
[INFO] Avatars creation completed
[INFO] Map rendering completed
[INFO] Avatar '159' created in (3,16,0)
[INFO] Path to (0,1,0) coordinates received for avatar 159
[INFO] Requesting map to OpenSpace Extension
[INFO] Map received from OpenSpace Extension
[INFO] Avatar '159' removed
[INFO] OpenSpace was reset
[INFO] Map parsing completed (3 ms)
[INFO] Tiles creation progress: 19%
[INFO] Tiles creation progress: 35%
[INFO] Tiles creation progress: 51%
[INFO] Tiles creation progress: 72%
[INFO] Tiles creation progress: 100%
[INFO] Map generation completed (81 ms)
[INFO] Avatars creation completed
[INFO] Map rendering completed
[INFO] Avatar '159' created in (5,18,0)Re: Problems with switching room maps
Did you check the server-side logs? No errors?
Also, is the map (including background and foreground) size equal to the viewport size? In this case there's a known issue which causes the map not to be show. Try making the viewport 1 pixel smaller than the overall map size.
Also, is the map (including background and foreground) size equal to the viewport size? In this case there's a known issue which causes the map not to be show. Try making the viewport 1 pixel smaller than the overall map size.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
No errors on server during the room change.
To keep it simple I used the same background swf but built a new server ".map" file for the new room to exclude the skins. Therefore I think it is not the viewport (the first room loads without any problem).
One think to notice is the luck of the component to respond after the map loading. Any attempt to send a public message to show in the avatar message balloon is refused with null reference exception.
To keep it simple I used the same background swf but built a new server ".map" file for the new room to exclude the skins. Therefore I think it is not the viewport (the first room loads without any problem).
One think to notice is the luck of the component to respond after the map loading. Any attempt to send a public message to show in the avatar message balloon is refused with null reference exception.
Hi Paolo!
As I suspected it was only a matter of invalidating the OS component after the new map is loaded, which means there is a small thing to fix with the component.
With the help of the very effective DeMonster Debugger I could notice that if I change the component width (invalidating it by doing that) the room suddenly appears and everything works just great.
By now I can invalidate the component myself, but that's just an hotfix and it would be great if the component does that by itself.
As I suspected it was only a matter of invalidating the OS component after the new map is loaded, which means there is a small thing to fix with the component.
With the help of the very effective DeMonster Debugger I could notice that if I change the component width (invalidating it by doing that) the room suddenly appears and everything works just great.
By now I can invalidate the component myself, but that's just an hotfix and it would be great if the component does that by itself.
I'll try to simplify the process:
1. Join a room and initiate and connect the OS client.
2. Send an extension message and change the user's room at server.
At this stage the OS still shows the old room.
3. handle the extension response in the client and tell OS to load the map of the newly entered room.
At this stage you will notice that the process of loading the map logs as if everything went OK, but the OS client faded to white.
4. In that stage, if you do something like changing the width of the OS client, it will show the new room.
Tell me if you were able to reproduce the issue.
1. Join a room and initiate and connect the OS client.
2. Send an extension message and change the user's room at server.
At this stage the OS still shows the old room.
3. handle the extension response in the client and tell OS to load the map of the newly entered room.
At this stage you will notice that the process of loading the map logs as if everything went OK, but the OS client faded to white.
4. In that stage, if you do something like changing the width of the OS client, it will show the new room.
Tell me if you were able to reproduce the issue.
Well, I've tried setting the viewport size to be 1px smaller than the background (no foreground) - it's still white and happens everytime, not randomly.
The only solution that works, is invalidating the component by setting:
I hope can you find a better fix than what I came with.
The only solution that works, is invalidating the component by setting:
Code: Select all
osClient.width = (osClient.width == 1000) ? 1001 : 1000;