I have questions about Map Editing :
What becomes of the edited map ? Is the .map file modified ? if yes, how could I manage something like Player's home, where each player creates his own map from the same base map ? How is it linked to a server's Room ?
Thank you for your answers.
Question about Map Editing
Edited maps are saved on the disk, replacing the previous map file.
About the player home, there's no out-of-the-box feature (at least not yet), but a possible high-level workflow could be:
1) user clicks on a button to enter his own home: a custom request is sent to your application' server-side extension (which in turn must extend the default OpenSpace Extension);
2) if this is the first time the user enters his home, on the server-side the extension generates a map file by duplicating a predefined template (the empty home) created by map designers with the OpenSpace Editor;
3) a SmartFoxServer Room is created (with the user set as its owner) and the map is assigned to him by means of Room Variables (check the OpenSpace.loadMap method in the client-side API documentation for more informations on map-Room association);
4) by means of the OpenSpaceExtension.sendAvatarToMap method on the OpenSpace Extension, the user is joined to the newly created Room and the map data is sent to the OpenSpace client;
5) on the client-side, the user clicks on a button to start map editing;
6) user submits the map changes to the server: by overriding the OpenSpaceExtension._isMapUpdateAllowed method on the server-side extension, an additional check should be made to be sure that the user is the 'owner' of the Room: if yes, map updating is allowed.
In order to implement this workflow you will need to wait for the next release, in which the OpenSpaceExtension.sendAvatarToMap method has been made available.
About the player home, there's no out-of-the-box feature (at least not yet), but a possible high-level workflow could be:
1) user clicks on a button to enter his own home: a custom request is sent to your application' server-side extension (which in turn must extend the default OpenSpace Extension);
2) if this is the first time the user enters his home, on the server-side the extension generates a map file by duplicating a predefined template (the empty home) created by map designers with the OpenSpace Editor;
3) a SmartFoxServer Room is created (with the user set as its owner) and the map is assigned to him by means of Room Variables (check the OpenSpace.loadMap method in the client-side API documentation for more informations on map-Room association);
4) by means of the OpenSpaceExtension.sendAvatarToMap method on the OpenSpace Extension, the user is joined to the newly created Room and the map data is sent to the OpenSpace client;
5) on the client-side, the user clicks on a button to start map editing;
6) user submits the map changes to the server: by overriding the OpenSpaceExtension._isMapUpdateAllowed method on the server-side extension, an additional check should be made to be sure that the user is the 'owner' of the Room: if yes, map updating is allowed.
In order to implement this workflow you will need to wait for the next release, in which the OpenSpaceExtension.sendAvatarToMap method has been made available.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Check the OpenSpaceExtension class description in the server-side API documentation: you will understand why you can't override that method and what to do instead.
http://openspace-engine.com/_docs_v2/serverAPI/html/
http://openspace-engine.com/_docs_v2/serverAPI/html/
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Okay, I'm moving on my task, but now when I make the sendAvatarToMap, I have an error on the client which says :
I can't understand why, so please help me, the new map MapEditingTest#Whoohoo is a copy of my reference map, with the same prefix ("MapEditingTest")[/quote]
[ RECEIVED ]: <msg t='sys'><body action='joinOK' r='47'><pid id='1'/><vars><var n='_os_mapId' t='s'><![CDATA[MapEditingTest#Whoohoo]]></var></vars><uLs r='47'><u i='4' m='0' s='0' p='1'><n><![CDATA[fred]]></n><vars><var n='_os_aTime' t='n'><![CDATA[300]]></var><var n='_os_dir' t='n'><![CDATA[4]]></var><var n='_os_type' t='s'><![CDATA[girl]]></var></vars></u></uLs></body></msg><msg t='sys'><body action='uCount' r='44' u='0'></body></msg><msg t='sys'><body action='uCount' r='47' u='1' s='0'></body></msg>, (len: 493)
TypeError: Error #1088: Le marquage du document après l'élément root doit être composé correctement.
at it.gotoandplay.smartfoxserver::SmartFoxClient/xmlReceived()
at it.gotoandplay.smartfoxserver::SmartFoxClient/handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/handleSocketData()
I can't understand why, so please help me, the new map MapEditingTest#Whoohoo is a copy of my reference map, with the same prefix ("MapEditingTest")[/quote]
I come back to my "creating new map" problem :
Here is what i'm doing on the client side :
(I have a "Create New Map" button)
on my server extension (at zone level), here is what I do :
I'm strictly following your instructions.
And here are the traces :
- Client-side :
-Server-side :
Please help me, I don't understand what is going wrong.
Here is what i'm doing on the client side :
(I have a "Create New Map" button)
Code: Select all
private function onCreateBtClick(evt:Event):void
{
// Create New Map
trace("onCreateBtClick");
smartFox.sendXtMessage("M4ZoneExt", "EditNewMap", { name:"Whoohoo", pwd:"" } );
}
on my server extension (at zone level), here is what I do :
Code: Select all
public void _handleRequest(String cmd, ActionscriptObject params, User sender, int roomId)
{
trace("handleRequest: cmd = " + cmd + "; sender = " + sender.getName());
if(cmd.equals("EditNewMap"))
{
this.CreateNewMap(sender, params.getString("name"), params.getString("pwd"));
}
}
private void CreateNewMap(User owner, String name, String pwd)
{
trace("1 CreateNewMap");
File newMap = new File("openSpace/data/MapEditingTest#" + name + ".map");
if(newMap.exists())
{
trace("WARNING : Map already exists");
return;
}
File refMap = new File("openSpace/data/MapEditingTest#EditMapRef.map");
FileCopy.copy(refMap, newMap);
trace("2 CreateNewMap");
Map<String, String> params = new HashMap<String, String>();
params.put("name", name);
params.put("maxU", "4");
params.put("isGame", "true");
if(!pwd.equals(""))
params.put("pwd", pwd);
HashMap<String, RoomVariable> roomVars = new HashMap<String, RoomVariable>();
RoomVariable mapRoomVar = new RoomVariable("MapEditingTest#" + name, "s", null, true, false);
roomVars.put("_os_mapId", mapRoomVar);
Room newRoom = null;
try {
newRoom = api.createRoom(currentZone, params, owner, roomVars, null, false, false, true);
} catch (ExtensionHelperException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(newRoom != null)
{
Boolean joined = true;
try {
super.sendAvatarToMap(owner, newRoom.getId(), pwd);
} catch (JoinMapRoomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
joined = false;
} catch (LoadMapException e) {
// TODO Auto-generated catch block
e.printStackTrace();
joined = false;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
joined = false;
}
if(joined)
{
trace("joined ok");
// LinkedList<SocketChannel> channelList = new LinkedList<SocketChannel>();
// channelList.add(owner.getChannel());
// ActionscriptObject response = new ActionscriptObject();
// response.put("_cmd", "enterEditMode");
// super.sendResponse(response, newRoom.getId(), null, channelList);
}
}
}
I'm strictly following your instructions.
And here are the traces :
- Client-side :
onCreateBtClick
[Sending]: <msg t='xt'><body action='xtReq' r='45'><![CDATA[<dataObj><var n='cmd' t='s'>EditNewMap</var><var n='name' t='s'>M4ZoneExt</var><obj t='o' o='param'><var n='pwd' t='s'></var><var n='name' t='s'>Whoohoo</var></obj></dataObj>]]></body></msg>
[ RECEIVED ]: <msg t='sys'><body action='uVarsUpdate' r='45'><vars><var n='_os_pz' t='x' /><var n='_os_px' t='x' /><var n='_os_py' t='x' /></vars><user id='1' /></body></msg>, (len: 160)
[ RECEIVED ]: <msg t='sys'><body action='joinOK' r='47'><pid id='1'/><vars><var n='_os_mapId' t='s'><![CDATA[MapEditingTest#Whoohoo]]></var></vars><uLs r='47'><u i='1' m='0' s='0' p='1'><n><![CDATA[fred]]></n><vars><var n='_os_aTime' t='n'><![CDATA[300]]></var><var n='_os_dir' t='n'><![CDATA[4]]></var><var n='_os_type' t='s'><![CDATA[girl]]></var></vars></u></uLs></body></msg>, (len: 365)
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleJoinOk()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/xmlReceived()
at it.gotoandplay.smartfoxserver::SmartFoxClient/handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/handleSocketData()
[ RECEIVED ]: <msg t='sys'><body action='joinOK' r='47'><pid id='1'/><vars><var n='_os_mapId' t='s'><![CDATA[MapEditingTest#Whoohoo]]></var></vars><uLs r='47'><u i='1' m='0' s='0' p='1'><n><![CDATA[fred]]></n><vars><var n='_os_aTime' t='n'><![CDATA[300]]></var><var n='_os_dir' t='n'><![CDATA[4]]></var><var n='_os_type' t='s'><![CDATA[girl]]></var></vars></u></uLs></body></msg><msg t='sys'><body action='uCount' r='45' u='0' s='0'></body></msg>, (len: 432)
TypeError: Error #1088: Le marquage du document après l'élément root doit être composé correctement.
at it.gotoandplay.smartfoxserver::SmartFoxClient/xmlReceived()
at it.gotoandplay.smartfoxserver::SmartFoxClient/handleMessage()
at it.gotoandplay.smartfoxserver::SmartFoxClient/handleSocketData()
-Server-side :
[ com.playsoft.extension.zone.M4ZoneExtension ]: handleRequest: cmd = EditNewMap
; sender = fred
[ com.playsoft.extension.zone.M4ZoneExtension ]: 1 CreateNewMap
[ com.playsoft.extension.zone.M4ZoneExtension ]: 2 CreateNewMap
17:27:56.384 - [ INFO ] > [OpenSpace] 'Send avatar to map' command received on b
ehalf of user fred [1]
17:27:56.385 - [ INFO ] > [OpenSpace] Map load request received from user fred [
1]
17:27:56.386 - [ INFO ] > [OpenSpace] Joining user fred [1] to Room 'Whoohoo' [4
7]
17:27:56.388 - [ INFO ] > [OpenSpace] Room 'Whoohoo' [47] joined; now loading as
sociated map 'MapEditingTest#Whoohoo
17:27:56.390 - [ INFO ] > [OpenSpace] Loading assets library for map 'MapEditing
Test#Whoohoo'
17:27:56.391 - [ INFO ] > [OpenSpace] 'openSpace/data/MapEditingTest.lib' librar
y file loaded
17:27:56.410 - [ INFO ] > [OpenSpace] 'openSpace/data/MapEditingTest#Whoohoo.map
' map file loaded
17:27:56.453 - [ INFO ] > [OpenSpace] Map 'MapEditingTest#Whoohoo' sent to user
fred [1]
[ com.playsoft.extension.zone.M4ZoneExtension ]: joined ok
Please help me, I don't understand what is going wrong.
Return to “OpenSpace v2 discussions and help”
Who is online
Users browsing this forum: No registered users and 63 guests