forked from External/mage
Some changes to userData handling. Added country flag to some dialogs. Saved and restored some more table columns width and order information.
This commit is contained in:
parent
cb3b5f895b
commit
87f3978589
32 changed files with 1982 additions and 1699 deletions
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.server;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -42,7 +41,6 @@ import mage.players.net.UserData;
|
|||
import mage.players.net.UserGroup;
|
||||
import mage.server.game.GamesRoomManager;
|
||||
import mage.server.util.ConfigSettings;
|
||||
import mage.view.UserDataView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.callback.AsynchInvokerCallbackHandler;
|
||||
import org.jboss.remoting.callback.Callback;
|
||||
|
|
@ -124,7 +122,7 @@ public class Session {
|
|||
}
|
||||
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
||||
return new StringBuilder("Error connecting ").append(userName).toString();
|
||||
}
|
||||
}
|
||||
this.userId = user.getId();
|
||||
if (reconnect) { // must be connected to receive the message
|
||||
UUID chatId = GamesRoomManager.getInstance().getRoom(GamesRoomManager.getInstance().getMainRoomId()).getChatId();
|
||||
|
|
@ -132,7 +130,7 @@ public class Session {
|
|||
ChatManager.getInstance().joinChat(chatId, userId);
|
||||
}
|
||||
ChatManager.getInstance().sendReconnectMessage(userId);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -144,75 +142,45 @@ public class Session {
|
|||
}
|
||||
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, false, false, null, "world.png", false));
|
||||
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
||||
logger.info("Error connecting Admin!");
|
||||
}
|
||||
logger.info("Error connecting Admin!");
|
||||
}
|
||||
this.userId = user.getId();
|
||||
}
|
||||
|
||||
public boolean setUserData(String userName, UserDataView userDataView) {
|
||||
public boolean setUserData(String userName, UserData userData) {
|
||||
User user = UserManager.getInstance().findUser(userName);
|
||||
if (user != null) {
|
||||
UserData userData = user.getUserData();
|
||||
if (userData == null) {
|
||||
userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(),
|
||||
userDataView.isShowAbilityPickerForced(), userDataView.allowRequestShowHandCards(),
|
||||
userDataView.confirmEmptyManaPool(), userDataView.getUserSkipPrioritySteps(),
|
||||
userDataView.getFlagName(), userDataView.askMoveToGraveOrder());
|
||||
if (user.getUserData() == null || user.getUserData().getGroupId() == UserGroup.DEFAULT.getGroupId()) {
|
||||
user.setUserData(userData);
|
||||
} else {
|
||||
if (userDataView.getAvatarId() == 51) { // Update special avatar if first avatar is selected
|
||||
updateAvatar(userName, userData);
|
||||
}
|
||||
userData.setAvatarId(userDataView.getAvatarId());
|
||||
userData.setShowAbilityPickerForced(userDataView.isShowAbilityPickerForced());
|
||||
userData.setAllowRequestShowHandCards(userDataView.allowRequestShowHandCards());
|
||||
userData.setUserSkipPrioritySteps(userDataView.getUserSkipPrioritySteps());
|
||||
userData.setConfirmEmptyManaPool(userDataView.confirmEmptyManaPool());
|
||||
userData.setAskMoveToGraveOrder(userDataView.askMoveToGraveOrder());
|
||||
user.getUserData().update(userData);
|
||||
}
|
||||
if (user.getUserData().getAvatarId() == 51) {
|
||||
user.getUserData().setAvatarId(updateAvatar(user.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateAvatar(String userName, UserData userData) {
|
||||
private int updateAvatar(String userName) {
|
||||
//TODO: move to separate class
|
||||
//TODO: add for checking for private key
|
||||
switch (userName) {
|
||||
case "nantuko":
|
||||
userData.setAvatarId(1000);
|
||||
break;
|
||||
case "i_no_k":
|
||||
userData.setAvatarId(1002);
|
||||
break;
|
||||
case "Askael":
|
||||
userData.setAvatarId(1004);
|
||||
break;
|
||||
return 1000;
|
||||
case "North":
|
||||
userData.setAvatarId(1006);
|
||||
break;
|
||||
return 1006;
|
||||
case "BetaSteward":
|
||||
userData.setAvatarId(1008);
|
||||
break;
|
||||
case "Arching":
|
||||
userData.setAvatarId(1010);
|
||||
break;
|
||||
return 1008;
|
||||
case "loki":
|
||||
userData.setAvatarId(1012);
|
||||
break;
|
||||
case "Alive":
|
||||
userData.setAvatarId(1014);
|
||||
break;
|
||||
case "Rahan":
|
||||
userData.setAvatarId(1016);
|
||||
break;
|
||||
return 1012;
|
||||
case "Ayrat":
|
||||
userData.setAvatarId(1018);
|
||||
break;
|
||||
return 1018;
|
||||
case "Bandit":
|
||||
userData.setAvatarId(1020);
|
||||
break;
|
||||
return 1020;
|
||||
}
|
||||
return 51;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
@ -220,10 +188,10 @@ public class Session {
|
|||
}
|
||||
|
||||
// because different threads can activate this
|
||||
public void userLostConnection() {
|
||||
public void userLostConnection() {
|
||||
boolean lockSet = false;
|
||||
try {
|
||||
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
if (lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
lockSet = true;
|
||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||
} else {
|
||||
|
|
@ -243,9 +211,8 @@ public class Session {
|
|||
|
||||
} catch (InterruptedException ex) {
|
||||
logger.error("SESSION LOCK lost connection - userId: " + userId, ex);
|
||||
}
|
||||
finally {
|
||||
if (lockSet) {
|
||||
} finally {
|
||||
if (lockSet) {
|
||||
lock.unlock();
|
||||
logger.trace("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
||||
}
|
||||
|
|
@ -256,18 +223,17 @@ public class Session {
|
|||
public void kill(DisconnectReason reason) {
|
||||
boolean lockSet = false;
|
||||
try {
|
||||
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
if (lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
lockSet = true;
|
||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||
} else {
|
||||
logger.error("SESSION LOCK - kill: userId " + userId);
|
||||
}
|
||||
UserManager.getInstance().removeUser(userId, reason);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.error("SESSION LOCK - kill: userId " + userId, ex);
|
||||
}
|
||||
finally {
|
||||
if (lockSet) {
|
||||
} finally {
|
||||
if (lockSet) {
|
||||
lock.unlock();
|
||||
logger.debug("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
||||
|
||||
|
|
@ -282,7 +248,7 @@ public class Session {
|
|||
callbackHandler.handleCallbackOneway(new Callback(call));
|
||||
} catch (HandleCallbackException ex) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
logger.warn("SESSION CALLBACK EXCEPTION - " + (user != null ? user.getName():"") + " userId " + userId);
|
||||
logger.warn("SESSION CALLBACK EXCEPTION - " + (user != null ? user.getName() : "") + " userId " + userId);
|
||||
logger.warn(" - method: " + call.getMethod());
|
||||
logger.warn(" - cause: " + getBasicCause(ex).toString());
|
||||
logger.trace("Stack trace:", ex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue