mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:23:06 +02:00
standardize data init/clear
This commit is contained in:
parent
d41a911fd2
commit
92481bf475
1 changed files with 16 additions and 19 deletions
|
@ -452,6 +452,11 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function clearConnecting() {
|
||||||
|
connectingId = undefined;
|
||||||
|
connectingHandString = undefined;
|
||||||
|
connectingHandJointIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
function lookForWaitingAvatar() {
|
function lookForWaitingAvatar() {
|
||||||
// we started with nobody close enough, but maybe I've moved
|
// we started with nobody close enough, but maybe I've moved
|
||||||
|
@ -486,9 +491,7 @@
|
||||||
debug("starting handshake for", currentHand);
|
debug("starting handshake for", currentHand);
|
||||||
pollCount = 0;
|
pollCount = 0;
|
||||||
state = STATES.WAITING;
|
state = STATES.WAITING;
|
||||||
connectingId = undefined;
|
clearConnecting();
|
||||||
connectingHandString = undefined;
|
|
||||||
connectingHandJointIndex = -1;
|
|
||||||
// just in case
|
// just in case
|
||||||
stopWaiting();
|
stopWaiting();
|
||||||
stopConnecting();
|
stopConnecting();
|
||||||
|
@ -517,9 +520,7 @@
|
||||||
// as we ignore the key release event when inactive. See updateTriggers
|
// as we ignore the key release event when inactive. See updateTriggers
|
||||||
// below.
|
// below.
|
||||||
state = STATES.INACTIVE;
|
state = STATES.INACTIVE;
|
||||||
connectingId = undefined;
|
clearConnecting();
|
||||||
connectingHandString = undefined;
|
|
||||||
connectingHandJointIndex = -1;
|
|
||||||
stopWaiting();
|
stopWaiting();
|
||||||
stopConnecting();
|
stopConnecting();
|
||||||
stopMakingConnection();
|
stopMakingConnection();
|
||||||
|
@ -674,6 +675,11 @@
|
||||||
function getConnectingHandJointIndex() {
|
function getConnectingHandJointIndex() {
|
||||||
return AvatarList.getAvatarIdentifiers().indexOf(connectingId) !== -1 ? getIdealHandJointIndex(AvatarList.getAvatar(connectingId), stringToHand(connectingHandString)) : -1;
|
return AvatarList.getAvatarIdentifiers().indexOf(connectingId) !== -1 ? getIdealHandJointIndex(AvatarList.getAvatar(connectingId), stringToHand(connectingHandString)) : -1;
|
||||||
}
|
}
|
||||||
|
function setupConnecting(id, handString) {
|
||||||
|
connectingId = id;
|
||||||
|
connectingHandString = handString;
|
||||||
|
connectingHandJointIndex = getConnectingHandJointIndex();
|
||||||
|
}
|
||||||
|
|
||||||
// we change states, start the connectionInterval where we check
|
// we change states, start the connectionInterval where we check
|
||||||
// to be sure the hand is still close enough. If not, we terminate
|
// to be sure the hand is still close enough. If not, we terminate
|
||||||
|
@ -683,9 +689,7 @@
|
||||||
var count = 0;
|
var count = 0;
|
||||||
debug("connecting", id, "hand", handString);
|
debug("connecting", id, "hand", handString);
|
||||||
// do we need to do this?
|
// do we need to do this?
|
||||||
connectingId = id;
|
setupConnecting(id, handString);
|
||||||
connectingHandString = handString;
|
|
||||||
connectingHandJointIndex = getConnectingHandJointIndex();
|
|
||||||
state = STATES.CONNECTING;
|
state = STATES.CONNECTING;
|
||||||
|
|
||||||
// play sound
|
// play sound
|
||||||
|
@ -770,9 +774,7 @@
|
||||||
if (state === STATES.WAITING && message.id === MyAvatar.sessionUUID && (!connectingId || connectingId === senderID)) {
|
if (state === STATES.WAITING && message.id === MyAvatar.sessionUUID && (!connectingId || connectingId === senderID)) {
|
||||||
// you were waiting for a connection request, so send the ack. Or, you and the other
|
// you were waiting for a connection request, so send the ack. Or, you and the other
|
||||||
// guy raced and both send connectionRequests. Handle that too
|
// guy raced and both send connectionRequests. Handle that too
|
||||||
connectingId = senderID;
|
setupConnecting(senderID, message[HAND_STRING_PROPERTY]);
|
||||||
connectingHandString = message[HAND_STRING_PROPERTY];
|
|
||||||
connectingHandJointIndex = getConnectingHandJointIndex();
|
|
||||||
handStringMessageSend({
|
handStringMessageSend({
|
||||||
key: "connectionAck",
|
key: "connectionAck",
|
||||||
id: senderID,
|
id: senderID,
|
||||||
|
@ -787,10 +789,7 @@
|
||||||
delete waitingList[senderID];
|
delete waitingList[senderID];
|
||||||
if (state === STATES.WAITING && (!connectingId || connectingId === senderID)) {
|
if (state === STATES.WAITING && (!connectingId || connectingId === senderID)) {
|
||||||
if (message.id === MyAvatar.sessionUUID) {
|
if (message.id === MyAvatar.sessionUUID) {
|
||||||
// start connecting...
|
setupConnecting(senderID, message[HAND_STRING_PROPERTY]);
|
||||||
connectingId = senderID;
|
|
||||||
connectingHandString = message[HAND_STRING_PROPERTY];
|
|
||||||
connectingHandJointIndex = getConnectingHandJointIndex();
|
|
||||||
stopWaiting();
|
stopWaiting();
|
||||||
startConnecting(senderID, connectingHandString);
|
startConnecting(senderID, connectingHandString);
|
||||||
} else if (connectingId) {
|
} else if (connectingId) {
|
||||||
|
@ -835,9 +834,7 @@
|
||||||
// if waiting or inactive, lets clear the connecting id. If in makingConnection,
|
// if waiting or inactive, lets clear the connecting id. If in makingConnection,
|
||||||
// do nothing
|
// do nothing
|
||||||
if (state !== STATES.MAKING_CONNECTION && connectingId === senderID) {
|
if (state !== STATES.MAKING_CONNECTION && connectingId === senderID) {
|
||||||
connectingId = undefined;
|
clearConnecting();
|
||||||
connectingHandString = undefined;
|
|
||||||
connectingHandJointIndex = -1;
|
|
||||||
if (state !== STATES.INACTIVE) {
|
if (state !== STATES.INACTIVE) {
|
||||||
startHandshake();
|
startHandshake();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue