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