Fixed lookup of neighbor screens. The first problem was an old

code in a conditional for moving left that blew an assert verifying
that the mouse position was really on the screen if the neighbor
screen wasn't connected.

After that was fixed there was another problem when one screen
linked to another which then linked (in the same direction) to
itself.  If the latter screen wasn't connected then it'd get into
an infinite loop.
This commit is contained in:
crs 2003-01-16 21:28:15 +00:00
parent a8bd4e7ff0
commit 24c0b3fd32
1 changed files with 22 additions and 8 deletions

View File

@ -841,30 +841,44 @@ CServer::getNeighbor(IClient* src, EDirection dir) const
assert(src != NULL); assert(src != NULL);
// get source screen name
CString srcName = src->getName(); CString srcName = src->getName();
assert(!srcName.empty()); assert(!srcName.empty());
LOG((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str())); LOG((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
for (;;) {
// look up name of neighbor
const CString dstName(m_config.getNeighbor(srcName, dir));
// if nothing in that direction then return NULL // get first neighbor. if it's the source then the source jumps
if (dstName.empty()) { // to itself and we return the source.
CString dstName(m_config.getNeighbor(srcName, dir));
if (dstName == srcName) {
LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
return src;
}
// keep checking
for (;;) {
// if nothing in that direction then return NULL. if the
// destination is the source then we can make no more
// progress in this direction. since we haven't found a
// connected neighbor we return NULL.
if (dstName.empty() || dstName == srcName) {
LOG((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str())); LOG((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
return NULL; return NULL;
} }
// look up neighbor cell. if the screen is connected and // look up neighbor cell. if the screen is connected and
// ready then we can stop. otherwise we skip over an // ready then we can stop.
// unconnected screen.
CClientList::const_iterator index = m_clients.find(dstName); CClientList::const_iterator index = m_clients.find(dstName);
if (index != m_clients.end()) { if (index != m_clients.end()) {
LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str())); LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
return index->second; return index->second;
} }
// skip over unconnected screen
LOG((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str())); LOG((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
srcName = dstName; srcName = dstName;
// look up name of neighbor of skipped screen
dstName = m_config.getNeighbor(srcName, dir);
} }
} }
@ -897,7 +911,7 @@ CServer::getNeighbor(IClient* src,
switch (srcSide) { switch (srcSide) {
case kLeft: case kLeft:
x -= dx; x -= dx;
while (dst != NULL && dst != lastGoodScreen) { while (dst != NULL) {
lastGoodScreen = dst; lastGoodScreen = dst;
lastGoodScreen->getShape(dx, dy, dw, dh); lastGoodScreen->getShape(dx, dy, dw, dh);
x += dw; x += dw;