Page 1 of 1

Big problem, little time!!!!!!! [URGENT]

Posted: 19 Dec 2010, 08:22
by Flappi282
Hello yet again everyone!
With one day until my game is releasing, I have found a major bug
All of the game (apart from login and connection) is based server side, including the item parsing, room joining etc...

The problem is that the player cannot join a room they just came from. The console outputs the user is already in this room. But on the server side, it is running a _server.joinRoom.

The problem is that the leaveRoom parameter is set to true.

To fix this, I tried to add _server.leaveRoom(user, fromRoom);

This, however, made absolutely no difference


Heres the code for the joinRoom event

Code: Select all

	} else if (cmd == "j") {
		var rID = params[0];
		if (Number(rID) == -1) {
			rID = chooseStartRoom();
		}
		var roomObj = _zone.getRoom(Number(rID));
		if (roomObj != null) {
			_server.leaveRoom(user,fromRoom);
			
			if (_server.joinRoom(user, fromRoom, true, Number(rID), null, null, false)) {
				user.properties.put("x",330);
				user.properties.put("y",300);
				var res = [];
				res[0] = "j";
				res[1] = roomObj.getId();
				res[2] = roomObj.getName();
				var userList = roomObj.getAllUsers();
				res.push("0|ZobbieBot|1|0|0|0|0|0|0|1|330|300");
				for (var i in userList) {
					if (userList[i].properties.get("hidden") != false && userList[i].properties.get("id") != user.properties.get("id")) {
						res.push(userList[i].properties.get("id") + "|" + userList[i].getName() + "|" + userList[i].properties.get("colour") + "|" + userList[i].properties.get("head") + "|" + userList[i].properties.get("face") + "|" + userList[i].properties.get("neck") + "|" + userList[i].properties.get("body") + "|" + userList[i].properties.get("hands") + "|" + userList[i].properties.get("feet") + "|" + userList[i].properties.get("rank") + "|" + userList[i].properties.get("x") + "|" + userList[i].properties.get("y"));
					}
				}
				_server.sendResponse(res,-1,null,[user],"str");
				var userStr = user.properties.get("id") + "|" + user.getName() + "|" + user.properties.get("colour") + "|" + user.properties.get("head") + "|" + user.properties.get("face") + "|" + user.properties.get("neck") + "|" + user.properties.get("body") + "|" + user.properties.get("hands") + "|" + user.properties.get("feet") + "|" + user.properties.get("rank") + "|" + user.properties.get("x") + "|" + user.properties.get("y");
				_server.sendResponse(["ap", userStr],-1,null,userList,"str");
			} else {
				_server.sendResponse(["j", "0", "10"],-1,null,[user],"str");
			}
		} else {
			_server.sendResponse(["j", "0", "3"],-1,null,[user],"str");
		}
	}
If you look at the code, the leaveRoom event is being fired, and so is the userExit internal event, but the user doesn't leave the room.


In case they are needed, here are the errors that are represented by numbers

Error 3: System error, room not found
Error 10: Room Full, try again later

And the error that is returned is code 10, but the debug is that the user is already in the room.

Why isn't the leaveRoom function working?

Posted: 19 Dec 2010, 09:19
by trueicecold
Are you logging in with the foceLogin parameter set to true? it might be a matter of ghosts users, and logging in again with forceLogin will disconnect the old user.

Posted: 19 Dec 2010, 10:03
by Flappi282
trueicecold wrote:Are you logging in with the foceLogin parameter set to true? it might be a matter of ghosts users, and logging in again with forceLogin will disconnect the old user.
Nope, since I this happens the first time I login. I can join the room (Town) successfully the first time, but when I join the shop, and try to leave, it tells me I'm already in the room, which I'm not

Posted: 19 Dec 2010, 10:26
by Flappi282
Hmm, it seems if I broadcast the event to the clients, the player would leave the room. But for some reason, if I disable broadcast, it doesnt leave the original room.

But I need to disable broadcast, otherwise more bandwidth is used, which I don't want

Posted: 19 Dec 2010, 21:48
by BigFIsh
In the joinRoom method, you specified 'true' to 'leave current room' (3rd param) - so that's why leaveRoom doesn't really do anything.

It looks like your client was trying to join a room that s/he was already in. Have you performed a check on client side to determine whether or not that user is already in that room prior to joining it?

Also, you mentioned that you prevented broadcasting of an event. Which one?

Posted: 20 Dec 2010, 14:50
by Flappi282
The problem is, I think this might be a bug, is that if the Join Room event is broadcasted, the user leaves the room. But when the join room event isn't broadcasted, regardless that the leaveRoom flag is set to true, the user doesn't leave the room.

The client side doesn't use the SFS api, it only uses extensions.

On the server side, after the room was being joined, I traced the rooms the user was in. It traced all the rooms the user had joined.

So basically, if the event isn't broadcasted, the user won't leave the room.

Posted: 21 Dec 2010, 14:47
by Lapo
The broadcast updates the client, not the server.
It's not clear where do you see the user not leaving the Room. If it's the client then of course you already have the answer.
But I need to disable broadcast, otherwise more bandwidth is used, which I don't want
Ok... it's good to check bandwidth usage, but stopping necessary system updates will break the API. Please allow the update to be sent.

Posted: 22 Dec 2010, 20:33
by Flappi282
I see what you mean. But I also see that Club Penguin got it working. That the user doesn't leave the room when I ran the function is either a bug or just a mistake I made, I don't understand how they do it just fine.

Posted: 22 Dec 2010, 23:27
by rjgtav
can you provide an example about it? What does club penguin do?

Posted: 24 Dec 2010, 22:04
by Flappi282
As I have found, Club Penguin uses a _server.joinRoom from the server side, but has broadcastEvent turned off, which I cannot do without causing the player to get stuck in that room.

The solution was to turn on broadcastEvent, but this sent a <msg t="sys"> packet to my game, which does nothing but waste bandwidth, since my game is server sided

Posted: 25 Dec 2010, 03:10
by Rutter
Don't compare yourself to CP yet. If you get to the concurrent volume they have then you can worry about bandwidth, for now just let the server broadcast the event.