rarified
4 years ago
6 changed files with 1482 additions and 1482 deletions
@ -1,235 +1,235 @@ |
|||||||
|
|
||||||
struct HS_RECT_NAME { |
struct HS_RECT_NAME { |
||||||
HS_RECT_TYPE fLeft, fTop, fRight, fBottom; |
HS_RECT_TYPE fLeft, fTop, fRight, fBottom; |
||||||
|
|
||||||
HS_RECT_TYPE Width() const { return fRight - fLeft; } |
HS_RECT_TYPE Width() const { return fRight - fLeft; } |
||||||
HS_RECT_TYPE Height() const { return fBottom - fTop; } |
HS_RECT_TYPE Height() const { return fBottom - fTop; } |
||||||
hsBool IsEmpty() const { return fLeft >= fRight || fTop >= fBottom; } |
hsBool IsEmpty() const { return fLeft >= fRight || fTop >= fBottom; } |
||||||
|
|
||||||
void SetEmpty() { fLeft = fTop = fRight = fBottom = 0; } |
void SetEmpty() { fLeft = fTop = fRight = fBottom = 0; } |
||||||
HS_RECT_NAME* Set(HS_RECT_TYPE left, HS_RECT_TYPE top, HS_RECT_TYPE right, HS_RECT_TYPE bottom) |
HS_RECT_NAME* Set(HS_RECT_TYPE left, HS_RECT_TYPE top, HS_RECT_TYPE right, HS_RECT_TYPE bottom) |
||||||
{ |
{ |
||||||
fLeft = left; fTop = top; fRight = right; fBottom = bottom; |
fLeft = left; fTop = top; fRight = right; fBottom = bottom; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* Set(const HS_RECT_POINT* p1, const HS_RECT_POINT* p2) |
HS_RECT_NAME* Set(const HS_RECT_POINT* p1, const HS_RECT_POINT* p2) |
||||||
{ |
{ |
||||||
if (p1->fX < p2->fX) |
if (p1->fX < p2->fX) |
||||||
{ fLeft = p1->fX; |
{ fLeft = p1->fX; |
||||||
fRight = p2->fX; |
fRight = p2->fX; |
||||||
} else |
} else |
||||||
{ fLeft = p2->fX; |
{ fLeft = p2->fX; |
||||||
fRight = p1->fX; |
fRight = p1->fX; |
||||||
} |
} |
||||||
|
|
||||||
if (p1->fY < p2->fY) |
if (p1->fY < p2->fY) |
||||||
{ fTop = p1->fY; |
{ fTop = p1->fY; |
||||||
fBottom = p2->fY; |
fBottom = p2->fY; |
||||||
} else |
} else |
||||||
{ fTop = p2->fY; |
{ fTop = p2->fY; |
||||||
fBottom = p1->fY; |
fBottom = p1->fY; |
||||||
} |
} |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* Set(UInt32 count, const HS_RECT_POINT pts[]) |
HS_RECT_NAME* Set(UInt32 count, const HS_RECT_POINT pts[]) |
||||||
{ |
{ |
||||||
if (count > 0) |
if (count > 0) |
||||||
{ fLeft = fRight = pts[0].fX; |
{ fLeft = fRight = pts[0].fX; |
||||||
fTop = fBottom = pts[0].fY; |
fTop = fBottom = pts[0].fY; |
||||||
(void)this->Union(count - 1, &pts[1]); |
(void)this->Union(count - 1, &pts[1]); |
||||||
} |
} |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
hsBool Contains(HS_RECT_TYPE x, HS_RECT_TYPE y) const |
hsBool Contains(HS_RECT_TYPE x, HS_RECT_TYPE y) const |
||||||
{ |
{ |
||||||
return x >= fLeft && x < fRight && y >= fTop && y < fBottom; |
return x >= fLeft && x < fRight && y >= fTop && y < fBottom; |
||||||
} |
} |
||||||
hsBool Contains(const HS_RECT_POINT* p) const |
hsBool Contains(const HS_RECT_POINT* p) const |
||||||
{ |
{ |
||||||
return this->Contains(p->fX, p->fY); |
return this->Contains(p->fX, p->fY); |
||||||
} |
} |
||||||
hsBool Contains(const HS_RECT_NAME* r) const |
hsBool Contains(const HS_RECT_NAME* r) const |
||||||
{ |
{ |
||||||
return fLeft <= r->fLeft && fTop <= r->fTop && fRight >= r->fRight && fBottom >= r->fBottom; |
return fLeft <= r->fLeft && fTop <= r->fTop && fRight >= r->fRight && fBottom >= r->fBottom; |
||||||
} |
} |
||||||
hsBool Contains(HS_RECT_TYPE left, HS_RECT_TYPE top, HS_RECT_TYPE right, HS_RECT_TYPE bottom) const |
hsBool Contains(HS_RECT_TYPE left, HS_RECT_TYPE top, HS_RECT_TYPE right, HS_RECT_TYPE bottom) const |
||||||
{ |
{ |
||||||
return fLeft <= left && fTop <= top && fRight >= right && fBottom >= bottom; |
return fLeft <= left && fTop <= top && fRight >= right && fBottom >= bottom; |
||||||
} |
} |
||||||
HS_RECT_NAME* Offset(HS_RECT_TYPE dx, HS_RECT_TYPE dy) |
HS_RECT_NAME* Offset(HS_RECT_TYPE dx, HS_RECT_TYPE dy) |
||||||
{ |
{ |
||||||
fLeft += dx; fTop += dy; fRight += dx; fBottom += dy; |
fLeft += dx; fTop += dy; fRight += dx; fBottom += dy; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* MoveTo(HS_RECT_TYPE x, HS_RECT_TYPE y) |
HS_RECT_NAME* MoveTo(HS_RECT_TYPE x, HS_RECT_TYPE y) |
||||||
{ |
{ |
||||||
this->fRight += x - this->fLeft; |
this->fRight += x - this->fLeft; |
||||||
this->fBottom += y - this->fTop; |
this->fBottom += y - this->fTop; |
||||||
this->fLeft = x; |
this->fLeft = x; |
||||||
this->fTop = y; |
this->fTop = y; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* Inset(HS_RECT_TYPE dx, HS_RECT_TYPE dy) |
HS_RECT_NAME* Inset(HS_RECT_TYPE dx, HS_RECT_TYPE dy) |
||||||
{ |
{ |
||||||
fLeft += dx; fRight -= dx; |
fLeft += dx; fRight -= dx; |
||||||
fTop += dy; fBottom -= dy; |
fTop += dy; fBottom -= dy; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
HS_RECT_NAME* UnionX(HS_RECT_TYPE x) |
HS_RECT_NAME* UnionX(HS_RECT_TYPE x) |
||||||
{ |
{ |
||||||
if (x < fLeft) fLeft = x; else |
if (x < fLeft) fLeft = x; else |
||||||
if (x > fRight) fRight = x; |
if (x > fRight) fRight = x; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* UnionY(HS_RECT_TYPE y) |
HS_RECT_NAME* UnionY(HS_RECT_TYPE y) |
||||||
{ |
{ |
||||||
if (y < fTop) fTop = y; else |
if (y < fTop) fTop = y; else |
||||||
if (y > fBottom) fBottom = y; |
if (y > fBottom) fBottom = y; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* Union(const HS_RECT_NAME* r) |
HS_RECT_NAME* Union(const HS_RECT_NAME* r) |
||||||
{ |
{ |
||||||
if (r->fLeft < fLeft) fLeft = r->fLeft; |
if (r->fLeft < fLeft) fLeft = r->fLeft; |
||||||
if (r->fTop < fTop) fTop = r->fTop; |
if (r->fTop < fTop) fTop = r->fTop; |
||||||
if (r->fRight > fRight) fRight = r->fRight; |
if (r->fRight > fRight) fRight = r->fRight; |
||||||
if (r->fBottom > fBottom) fBottom = r->fBottom; |
if (r->fBottom > fBottom) fBottom = r->fBottom; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* Union(const HS_RECT_POINT* p) |
HS_RECT_NAME* Union(const HS_RECT_POINT* p) |
||||||
{ |
{ |
||||||
if (p->fX < fLeft) fLeft = p->fX; |
if (p->fX < fLeft) fLeft = p->fX; |
||||||
if (p->fX > fRight) fRight = p->fX; |
if (p->fX > fRight) fRight = p->fX; |
||||||
if (p->fY < fTop) fTop = p->fY; |
if (p->fY < fTop) fTop = p->fY; |
||||||
if (p->fY> fBottom) fBottom = p->fY; |
if (p->fY> fBottom) fBottom = p->fY; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
HS_RECT_NAME* Union(UInt32 count, const HS_RECT_POINT p[]) |
HS_RECT_NAME* Union(UInt32 count, const HS_RECT_POINT p[]) |
||||||
{ |
{ |
||||||
HS_RECT_TYPE left = this->fLeft; |
HS_RECT_TYPE left = this->fLeft; |
||||||
HS_RECT_TYPE top = this->fTop; |
HS_RECT_TYPE top = this->fTop; |
||||||
HS_RECT_TYPE right = this->fRight; |
HS_RECT_TYPE right = this->fRight; |
||||||
HS_RECT_TYPE bottom = this->fBottom; |
HS_RECT_TYPE bottom = this->fBottom; |
||||||
|
|
||||||
for (; count > 0; ++p, --count) |
for (; count > 0; ++p, --count) |
||||||
{ HS_RECT_TYPE value = p->fX; |
{ HS_RECT_TYPE value = p->fX; |
||||||
if (value < left) left = value; |
if (value < left) left = value; |
||||||
else if (value > right) right = value; |
else if (value > right) right = value; |
||||||
|
|
||||||
value = p->fY; |
value = p->fY; |
||||||
if (value < top) top = value; |
if (value < top) top = value; |
||||||
else if (value > bottom) bottom = value; |
else if (value > bottom) bottom = value; |
||||||
} |
} |
||||||
return this->Set(left, top, right, bottom); |
return this->Set(left, top, right, bottom); |
||||||
} |
} |
||||||
|
|
||||||
#if 0 // Havok reeks |
#if 0 // Havok reeks |
||||||
friend int operator==(const HS_RECT_NAME& a, const HS_RECT_NAME& b) |
friend int operator==(const HS_RECT_NAME& a, const HS_RECT_NAME& b) |
||||||
{ |
{ |
||||||
return a.fLeft == b.fLeft && a.fTop == b.fTop && |
return a.fLeft == b.fLeft && a.fTop == b.fTop && |
||||||
a.fRight == b.fRight && a.fBottom == b.fBottom; |
a.fRight == b.fRight && a.fBottom == b.fBottom; |
||||||
} |
} |
||||||
friend int operator!=(const HS_RECT_NAME& a, const HS_RECT_NAME& b) |
friend int operator!=(const HS_RECT_NAME& a, const HS_RECT_NAME& b) |
||||||
{ |
{ |
||||||
return !(a == b); |
return !(a == b); |
||||||
} |
} |
||||||
#else // Havok reeks |
#else // Havok reeks |
||||||
int operator==(const HS_RECT_NAME& aa) const |
int operator==(const HS_RECT_NAME& aa) const |
||||||
{ |
{ |
||||||
return aa.fLeft == fLeft && aa.fTop == fTop && |
return aa.fLeft == fLeft && aa.fTop == fTop && |
||||||
aa.fRight == fRight && aa.fBottom == fBottom; |
aa.fRight == fRight && aa.fBottom == fBottom; |
||||||
} |
} |
||||||
int operator!=(const HS_RECT_NAME& aa) const |
int operator!=(const HS_RECT_NAME& aa) const |
||||||
{ |
{ |
||||||
return !(aa == *this); |
return !(aa == *this); |
||||||
} |
} |
||||||
#endif // Havok reeks |
#endif // Havok reeks |
||||||
|
|
||||||
// Intersect Test |
// Intersect Test |
||||||
friend int operator&&(const HS_RECT_NAME& a, const HS_RECT_NAME& b) |
friend int operator&&(const HS_RECT_NAME& a, const HS_RECT_NAME& b) |
||||||
{ |
{ |
||||||
return a.fLeft < b.fRight && a.fRight > b.fLeft && |
return a.fLeft < b.fRight && a.fRight > b.fLeft && |
||||||
a.fTop < b.fBottom && a.fBottom > b.fTop; |
a.fTop < b.fBottom && a.fBottom > b.fTop; |
||||||
} |
} |
||||||
|
|
||||||
hsBool Intersect(const HS_RECT_NAME* r) |
hsBool Intersect(const HS_RECT_NAME* r) |
||||||
{ |
{ |
||||||
return this->Intersect(r->fLeft, r->fTop, r->fRight, r->fBottom); |
return this->Intersect(r->fLeft, r->fTop, r->fRight, r->fBottom); |
||||||
} |
} |
||||||
hsBool Intersect(HS_RECT_TYPE left, HS_RECT_TYPE top, HS_RECT_TYPE right, HS_RECT_TYPE bottom) |
hsBool Intersect(HS_RECT_TYPE left, HS_RECT_TYPE top, HS_RECT_TYPE right, HS_RECT_TYPE bottom) |
||||||
{ |
{ |
||||||
if (left < fRight && top < fBottom && fLeft < right && fTop < bottom) |
if (left < fRight && top < fBottom && fLeft < right && fTop < bottom) |
||||||
{ if (left > fLeft) fLeft = left; |
{ if (left > fLeft) fLeft = left; |
||||||
if (top > fTop) fTop = top; |
if (top > fTop) fTop = top; |
||||||
if (right < fRight) fRight = right; |
if (right < fRight) fRight = right; |
||||||
if (bottom < fBottom) fBottom = bottom; |
if (bottom < fBottom) fBottom = bottom; |
||||||
return true; |
return true; |
||||||
} |
} |
||||||
return false; |
return false; |
||||||
} |
} |
||||||
hsBool Intersect(const HS_RECT_NAME* a, const HS_RECT_NAME* b) |
hsBool Intersect(const HS_RECT_NAME* a, const HS_RECT_NAME* b) |
||||||
{ |
{ |
||||||
if (a->fLeft < b->fRight && a->fTop < b->fBottom && b->fLeft < a->fRight && b->fTop < a->fBottom) |
if (a->fLeft < b->fRight && a->fTop < b->fBottom && b->fLeft < a->fRight && b->fTop < a->fBottom) |
||||||
{ *this = *b; |
{ *this = *b; |
||||||
if (a->fLeft > fLeft) fLeft = a->fLeft; |
if (a->fLeft > fLeft) fLeft = a->fLeft; |
||||||
if (a->fTop > fTop) fTop = a->fTop; |
if (a->fTop > fTop) fTop = a->fTop; |
||||||
if (a->fRight < fRight) fRight = a->fRight; |
if (a->fRight < fRight) fRight = a->fRight; |
||||||
if (a->fBottom < fBottom) fBottom = a->fBottom; |
if (a->fBottom < fBottom) fBottom = a->fBottom; |
||||||
return true; |
return true; |
||||||
} |
} |
||||||
return false; // "this" is not changed |
return false; // "this" is not changed |
||||||
} |
} |
||||||
|
|
||||||
HS_RECT_POINT* ToQuad(HS_RECT_POINT quad[4]) const |
HS_RECT_POINT* ToQuad(HS_RECT_POINT quad[4]) const |
||||||
{ |
{ |
||||||
quad[0].fX = fLeft; quad[0].fY = fTop; |
quad[0].fX = fLeft; quad[0].fY = fTop; |
||||||
quad[1].fX = fRight; quad[1].fY = fTop; |
quad[1].fX = fRight; quad[1].fY = fTop; |
||||||
quad[2].fX = fRight; quad[2].fY = fBottom; |
quad[2].fX = fRight; quad[2].fY = fBottom; |
||||||
quad[3].fX = fLeft; quad[3].fY = fBottom; |
quad[3].fX = fLeft; quad[3].fY = fBottom; |
||||||
return quad; |
return quad; |
||||||
} |
} |
||||||
|
|
||||||
hsBool CornerTest(const HS_RECT_NAME* area, |
hsBool CornerTest(const HS_RECT_NAME* area, |
||||||
HS_RECT_POINT* hitPt = nil, HS_RECT_POINT* oppositePt = nil) const |
HS_RECT_POINT* hitPt = nil, HS_RECT_POINT* oppositePt = nil) const |
||||||
{ |
{ |
||||||
if (area->Contains(fLeft, fTop)) |
if (area->Contains(fLeft, fTop)) |
||||||
{ if (hitPt) hitPt->Set(fLeft, fTop); |
{ if (hitPt) hitPt->Set(fLeft, fTop); |
||||||
if (oppositePt) oppositePt->Set(fRight, fBottom); |
if (oppositePt) oppositePt->Set(fRight, fBottom); |
||||||
return true; |
return true; |
||||||
} |
} |
||||||
if (area->Contains(fLeft, fBottom)) |
if (area->Contains(fLeft, fBottom)) |
||||||
{ if (hitPt) hitPt->Set(fLeft, fBottom); |
{ if (hitPt) hitPt->Set(fLeft, fBottom); |
||||||
if (oppositePt) oppositePt->Set(fRight, fTop); |
if (oppositePt) oppositePt->Set(fRight, fTop); |
||||||
return true; |
return true; |
||||||
} |
} |
||||||
if (area->Contains(fRight, fTop)) |
if (area->Contains(fRight, fTop)) |
||||||
{ if (hitPt) hitPt->Set(fRight, fTop); |
{ if (hitPt) hitPt->Set(fRight, fTop); |
||||||
if (oppositePt) oppositePt->Set(fLeft, fBottom); |
if (oppositePt) oppositePt->Set(fLeft, fBottom); |
||||||
return true; |
return true; |
||||||
} |
} |
||||||
if (area->Contains(fRight, fBottom)) |
if (area->Contains(fRight, fBottom)) |
||||||
{ if (hitPt) hitPt->Set(fRight, fBottom); |
{ if (hitPt) hitPt->Set(fRight, fBottom); |
||||||
if (oppositePt) oppositePt->Set(fLeft, fTop); |
if (oppositePt) oppositePt->Set(fLeft, fTop); |
||||||
return true; |
return true; |
||||||
} |
} |
||||||
return false; |
return false; |
||||||
} |
} |
||||||
hsBool CornerTest(HS_RECT_POINT* pt, HS_RECT_TYPE tolerance, |
hsBool CornerTest(HS_RECT_POINT* pt, HS_RECT_TYPE tolerance, |
||||||
HS_RECT_POINT* hitPt = nil, HS_RECT_POINT* oppositePt = nil) const |
HS_RECT_POINT* hitPt = nil, HS_RECT_POINT* oppositePt = nil) const |
||||||
{ |
{ |
||||||
HS_RECT_NAME area = { pt->fX - tolerance, pt->fY - tolerance, |
HS_RECT_NAME area = { pt->fX - tolerance, pt->fY - tolerance, |
||||||
pt->fX + tolerance, pt->fY + tolerance }; |
pt->fX + tolerance, pt->fY + tolerance }; |
||||||
|
|
||||||
return this->CornerTest(&area, hitPt, oppositePt); |
return this->CornerTest(&area, hitPt, oppositePt); |
||||||
} |
} |
||||||
|
|
||||||
#if !(HS_RECT_EXTEND) |
#if !(HS_RECT_EXTEND) |
||||||
}; |
}; |
||||||
#endif |
#endif |
||||||
|
|
||||||
#undef HS_RECT_NAME |
#undef HS_RECT_NAME |
||||||
#undef HS_RECT_POINT |
#undef HS_RECT_POINT |
||||||
#undef HS_RECT_TYPE |
#undef HS_RECT_TYPE |
||||||
#undef HS_RECT_EXTEND |
#undef HS_RECT_EXTEND |
||||||
|
|
||||||
|
@ -1,2 +1,2 @@ |
|||||||
|
|
||||||
Moving hsRect here since it doesn't have a lot to do with transforms. mf |
Moving hsRect here since it doesn't have a lot to do with transforms. mf |
@ -1,4 +1,4 @@ |
|||||||
|
|
||||||
Collection of geometry intersection routines between various primitives, e.g. TriList/Box, Box/Box, Box/Sphere, etc. |
Collection of geometry intersection routines between various primitives, e.g. TriList/Box, Box/Box, Box/Sphere, etc. |
||||||
|
|
||||||
Mesh types will often convert themselves to appropriate type, and call from this lib when queried for intersection. |
Mesh types will often convert themselves to appropriate type, and call from this lib when queried for intersection. |
@ -1,163 +1,163 @@ |
|||||||
""" *==LICENSE==* |
""" *==LICENSE==* |
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools |
CyanWorlds.com Engine - MMOG client, server and tools |
||||||
Copyright (C) 2011 Cyan Worlds, Inc. |
Copyright (C) 2011 Cyan Worlds, Inc. |
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify |
This program is free software: you can redistribute it and/or modify |
||||||
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
||||||
the Free Software Foundation, either version 3 of the License, or |
the Free Software Foundation, either version 3 of the License, or |
||||||
(at your option) any later version. |
(at your option) any later version. |
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
GNU General Public License for more details. |
GNU General Public License for more details. |
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7 |
Additional permissions under GNU GPL version 3 section 7 |
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or |
If you modify this Program, or any covered work, by linking or |
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||||
(or a modified version of those libraries), |
(or a modified version of those libraries), |
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||||
licensors of this Program grant you additional |
licensors of this Program grant you additional |
||||||
permission to convey the resulting work. Corresponding Source for a |
permission to convey the resulting work. Corresponding Source for a |
||||||
non-source form of such a combination shall include the source code for |
non-source form of such a combination shall include the source code for |
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||||
work. |
work. |
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
You can contact Cyan Worlds, Inc. by email legal@cyan.com |
||||||
or by snail mail at: |
or by snail mail at: |
||||||
Cyan Worlds, Inc. |
Cyan Worlds, Inc. |
||||||
14617 N Newport Hwy |
14617 N Newport Hwy |
||||||
Mead, WA 99021 |
Mead, WA 99021 |
||||||
|
|
||||||
*==LICENSE==* """ |
*==LICENSE==* """ |
||||||
from pyPlasma import * |
from pyPlasma import * |
||||||
from pyPlasmaHelpers import * |
from pyPlasmaHelpers import * |
||||||
from traceback import print_exc |
from traceback import print_exc |
||||||
|
|
||||||
kLogToDebugger = 32 |
kLogToDebugger = 32 |
||||||
kPeristentNode = 1 |
kPeristentNode = 1 |
||||||
kTransientNode = 0 |
kTransientNode = 0 |
||||||
kQuittingGame = 7 |
kQuittingGame = 7 |
||||||
kLinkingOut = 8 |
kLinkingOut = 8 |
||||||
kExitingLobby = 9 |
kExitingLobby = 9 |
||||||
|
|
||||||
#------------------------------------- |
#------------------------------------- |
||||||
|
|
||||||
print "BEGIN" |
print "BEGIN" |
||||||
|
|
||||||
# create client-side networking |
# create client-side networking |
||||||
net = ptNetClientComm() |
net = ptNetClientComm() |
||||||
# init log. this must be done before creating the vault manager |
# init log. this must be done before creating the vault manager |
||||||
net.setLog("pyPlasmaTest.log", kLogToDebugger ) |
net.setLog("pyPlasmaTest.log", kLogToDebugger ) |
||||||
# create vault manager |
# create vault manager |
||||||
#vault = ptPlayerVNodeMgr(net) |
#vault = ptPlayerVNodeMgr(net) |
||||||
vault = ptAdminVNodeMgr(net) |
vault = ptAdminVNodeMgr(net) |
||||||
vault.setWantGlobalSDL(1) |
vault.setWantGlobalSDL(1) |
||||||
vault.setWantAllPlayers(1) |
vault.setWantAllPlayers(1) |
||||||
# create the NetClientMgr. |
# create the NetClientMgr. |
||||||
nc = NetClientMgr(net) |
nc = NetClientMgr(net) |
||||||
# create the VaultConnectMgr |
# create the VaultConnectMgr |
||||||
vc = VaultConnectMgr(vault) |
vc = VaultConnectMgr(vault) |
||||||
|
|
||||||
# startup networking |
# startup networking |
||||||
print "Net: starting up..." |
print "Net: starting up..." |
||||||
net.init() |
net.init() |
||||||
print "Net: started" |
print "Net: started" |
||||||
|
|
||||||
# point to lobby server |
# point to lobby server |
||||||
net.setActiveServer('ea1-2k',5000) |
net.setActiveServer('ea1-2k',5000) |
||||||
# set acct username/password |
# set acct username/password |
||||||
net.setAuthInfo('reseng0221','tooann42') |
net.setAuthInfo('reseng0221','tooann42') |
||||||
# specify the name of player we want to use. |
# specify the name of player we want to use. |
||||||
nc.setDesiredPlayer('Scooby5',1) |
nc.setDesiredPlayer('Scooby5',1) |
||||||
|
|
||||||
#------------------ |
#------------------ |
||||||
success = 0 |
success = 0 |
||||||
|
|
||||||
while 1: |
while 1: |
||||||
try: |
try: |
||||||
# login to the lobby server |
# login to the lobby server |
||||||
if nc.login(NetClientMgr.kLobby)<0: break |
if nc.login(NetClientMgr.kLobby)<0: break |
||||||
|
|
||||||
# connect to vault |
# connect to vault |
||||||
if vc.connect()<0: break |
if vc.connect()<0: break |
||||||
# get root node |
# get root node |
||||||
rootNode = vault.getRootNode() |
rootNode = vault.getRootNode() |
||||||
print rootNode |
print rootNode |
||||||
# create a template node for finding the global sdl folder node |
# create a template node for finding the global sdl folder node |
||||||
tmpNode = vault.createNode(PtVaultNodeTypes.kFolderNode,kTransientNode).upcastToFolderNode() |
tmpNode = vault.createNode(PtVaultNodeTypes.kFolderNode,kTransientNode).upcastToFolderNode() |
||||||
tmpNode.setFolderType(PtVaultStandardNodes.kAllAgeGlobalSDLNodesFolder) |
tmpNode.setFolderType(PtVaultStandardNodes.kAllAgeGlobalSDLNodesFolder) |
||||||
# find global SDL folder |
# find global SDL folder |
||||||
globalSDLFolder = vault.findNode(tmpNode) |
globalSDLFolder = vault.findNode(tmpNode) |
||||||
if globalSDLFolder: |
if globalSDLFolder: |
||||||
globalSDLFolder = globalSDLFolder.upcastToFolderNode() |
globalSDLFolder = globalSDLFolder.upcastToFolderNode() |
||||||
print globalSDLFolder |
print globalSDLFolder |
||||||
|
|
||||||
# startup an age or three (forces global sdl nodes to initialize) |
# startup an age or three (forces global sdl nodes to initialize) |
||||||
ageLink = ptAgeLinkStruct() |
ageLink = ptAgeLinkStruct() |
||||||
# ageLink.getAgeInfo().setAgeFilename('Teledahn') |
# ageLink.getAgeInfo().setAgeFilename('Teledahn') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('city') |
# ageLink.getAgeInfo().setAgeFilename('city') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('Personal') |
# ageLink.getAgeInfo().setAgeFilename('Personal') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('Garden') |
# ageLink.getAgeInfo().setAgeFilename('Garden') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('BaronCityOffice') |
# ageLink.getAgeInfo().setAgeFilename('BaronCityOffice') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('Kadish') |
# ageLink.getAgeInfo().setAgeFilename('Kadish') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('Neighborhood') |
# ageLink.getAgeInfo().setAgeFilename('Neighborhood') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('Cleft') |
# ageLink.getAgeInfo().setAgeFilename('Cleft') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
# ageLink.getAgeInfo().setAgeFilename('Garrison') |
# ageLink.getAgeInfo().setAgeFilename('Garrison') |
||||||
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
# nc.startFindingAge(ageLink) # we don't need to wait around for the operation to complete |
||||||
|
|
||||||
# spawn a game |
# spawn a game |
||||||
ageLink.getAgeInfo().setAgeFilename('Teledahn') |
ageLink.getAgeInfo().setAgeFilename('Teledahn') |
||||||
ageLink.setLinkingRules(PtLinkingRules.kOriginalBook) |
ageLink.setLinkingRules(PtLinkingRules.kOriginalBook) |
||||||
if nc.findAge(ageLink)<0: break |
if nc.findAge(ageLink)<0: break |
||||||
serverInfo = nc.fCbArgs[0] |
serverInfo = nc.fCbArgs[0] |
||||||
|
|
||||||
# leave the lobby |
# leave the lobby |
||||||
nc.logout(kExitingLobby) |
nc.logout(kExitingLobby) |
||||||
|
|
||||||
# log into the game server |
# log into the game server |
||||||
net.setActiveServer(serverInfo) |
net.setActiveServer(serverInfo) |
||||||
if nc.login(NetClientMgr.kGame)<0: break |
if nc.login(NetClientMgr.kGame)<0: break |
||||||
|
|
||||||
# join the age |
# join the age |
||||||
if nc.joinAge()<0: break |
if nc.joinAge()<0: break |
||||||
|
|
||||||
# done trying things |
# done trying things |
||||||
success = 1 |
success = 1 |
||||||
break |
break |
||||||
except: |
except: |
||||||
print_exc() |
print_exc() |
||||||
break |
break |
||||||
|
|
||||||
# disconnect from vault |
# disconnect from vault |
||||||
vc.disconnect() |
vc.disconnect() |
||||||
# leave the server |
# leave the server |
||||||
nc.logout(kQuittingGame) |
nc.logout(kQuittingGame) |
||||||
|
|
||||||
#------------------ |
#------------------ |
||||||
|
|
||||||
# shutdown networking. only flush msgs if all went well (not required, but speeds up shutdown on error) |
# shutdown networking. only flush msgs if all went well (not required, but speeds up shutdown on error) |
||||||
print "Net: shutting down..." |
print "Net: shutting down..." |
||||||
net.fini(success) |
net.fini(success) |
||||||
print "Net: shut down" |
print "Net: shut down" |
||||||
|
|
||||||
|
|
||||||
print "END" |
print "END" |
||||||
raw_input("\npress return") |
raw_input("\npress return") |
||||||
|
@ -1,38 +1,38 @@ |
|||||||
/*==README.txt== |
/*==README.txt== |
||||||
|
|
||||||
About Non-Free Libraries: |
About Non-Free Libraries: |
||||||
|
|
||||||
This software uses some non-free libraries for which exceptions appear in the |
This software uses some non-free libraries for which exceptions appear in the |
||||||
source code license inserts. It is suggested that anyone who thinks of doing |
source code license inserts. It is suggested that anyone who thinks of doing |
||||||
substantial further work on this program should first free it from dependence |
substantial further work on this program should first free it from dependence |
||||||
on the non-free libraries so that it does the same job without the non-free |
on the non-free libraries so that it does the same job without the non-free |
||||||
libraries. Further introduction of non-free libraries likely would require a |
libraries. Further introduction of non-free libraries likely would require a |
||||||
revised license and thus permission from all contributors to the codebase. |
revised license and thus permission from all contributors to the codebase. |
||||||
That being problematic, any additional non-free libraries are unlikely to be |
That being problematic, any additional non-free libraries are unlikely to be |
||||||
accepted by Cyan Worlds or the development community. |
accepted by Cyan Worlds or the development community. |
||||||
|
|
||||||
Acknowledgements: |
Acknowledgements: |
||||||
|
|
||||||
OPENSSL: |
OPENSSL: |
||||||
|
|
||||||
This product includes software developed by the OpenSSL Project for use in |
This product includes software developed by the OpenSSL Project for use in |
||||||
the OpenSSL Toolkit (http://www.openssl.org/). This product includes |
the OpenSSL Toolkit (http://www.openssl.org/). This product includes |
||||||
cryptographic software written by Eric A. Young (eay@cryptsoft.com). This |
cryptographic software written by Eric A. Young (eay@cryptsoft.com). This |
||||||
product includes software written by Tim J. Hudson (tjh@cryptsoft.com)." |
product includes software written by Tim J. Hudson (tjh@cryptsoft.com)." |
||||||
|
|
||||||
Independent JPEG Group (IJG) JPEG Library: |
Independent JPEG Group (IJG) JPEG Library: |
||||||
|
|
||||||
This software is based in part on the work of the Independent JPEG Group. |
This software is based in part on the work of the Independent JPEG Group. |
||||||
|
|
||||||
Jani Kajala: |
Jani Kajala: |
||||||
|
|
||||||
Copyright (c) 2001 Jani Kajala |
Copyright (c) 2001 Jani Kajala |
||||||
|
|
||||||
Permission to use, copy, modify, distribute and sell this software and its |
Permission to use, copy, modify, distribute and sell this software and its |
||||||
documentation for any purpose is hereby granted without fee, provided that |
documentation for any purpose is hereby granted without fee, provided that |
||||||
the above copyright notice appear in all copies and that both that copyright |
the above copyright notice appear in all copies and that both that copyright |
||||||
notice and this permission notice appear in supporting documentation. Jani |
notice and this permission notice appear in supporting documentation. Jani |
||||||
Kajala makes no representations about the suitability of this software for |
Kajala makes no representations about the suitability of this software for |
||||||
any purpose. It is provided "as is" without express or implied warranty. |
any purpose. It is provided "as is" without express or implied warranty. |
||||||
|
|
||||||
*==README==*/ |
*==README==*/ |
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue