Question about Map Editing

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Question about Map Editing

Postby ffourcad » 29 Mar 2010, 15:40

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.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 29 Mar 2010, 20:13

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.
Paolo Bax
The SmartFoxServer Team
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 30 Mar 2010, 07:52

that's great.
But I thought that when you load a new map (by entering a new room), the avatar was moved automatically. I don't quite understand the use of the sendAvatarToMap method.

Another question : when is the next release ?
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 31 Mar 2010, 07:58

The above workflow is used if you want to control the map change process on the server side. The sendAvatarToMap method joins the user in the room you created dynamically, loads the corresponding map and sends the map data to the client.
Paolo Bax
The SmartFoxServer Team
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 02 Apr 2010, 09:46

I tried to do as you said, but when I extend OpenSpaceExtension, I can't override the handleRequest method, and so I can't catch the the message sent by the client when the user enters edit mode.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 02 Apr 2010, 10:40

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/
Paolo Bax
The SmartFoxServer Team
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 02 Apr 2010, 15:36

Okay, I'm moving on my task, but now when I make the sendAvatarToMap, I have an error on the client which says :
[ 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]
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 03 Apr 2010, 14:16

THis is an issue we are not able to reproduce. Does it happen systematically? If yes, can you please send to our email address an example, so we can understand what is going on?
Paolo Bax
The SmartFoxServer Team
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 06 Apr 2010, 08:32

Maybe it is caused by the fact that I don't have an avatar on the map, when I do the moveAvatarToMap. In fact, in my project, I didn't want the avatar to go inside his room before editing it. I just wanted to make the client load the map without the avatar.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 06 Apr 2010, 10:11

This doesn't seem to be related with the error you get, which is at the SmartFoxServer API level, not at the OpenSpace level.
Paolo Bax
The SmartFoxServer Team
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 06 Apr 2010, 10:30

I will send my map, and my server extension code, and maybe you will be able to help me. What is the email is must use ?
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 06 Apr 2010, 10:39

info AT smartfoxserver DOT com
Paolo Bax
The SmartFoxServer Team
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 12 Apr 2010, 15:48

I'm sorry, my email doesn't seem to reach you. Do you have another e-mail address, or do you know if it's the java file joined with it, which can cause the problem ?
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 16 Apr 2010, 15:15

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)

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.
ffourcad
Posts: 130
Joined: 25 Feb 2010, 10:26

Postby ffourcad » 20 Apr 2010, 07:35

up

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 63 guests