[Opentnl-cvs] tnl/zap barrier.cpp,1.15,1.16 barrier.h,1.5,1.6 gameType.cpp,1.63,1.64 gameType.h,1.37
Brought to you by:
mark_frohnmayer,
s_alanet
From: Mark F. <mar...@us...> - 2004-10-15 18:01:41
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21764/zap Modified Files: barrier.cpp barrier.h gameType.cpp gameType.h Log Message: Added facility for variable width barriers Index: gameType.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** gameType.cpp 8 Oct 2004 00:17:47 -0000 1.63 --- gameType.cpp 15 Oct 2004 18:01:15 -0000 1.64 *************** *** 49,52 **** --- 49,53 ---- mGameOver = false; mTeamScoreLimit = DefaultTeamScoreLimit; + mBarrierWidth = Barrier::BarrierWidth; } *************** *** 411,415 **** } ! extern void constructBarriers(Game *theGame, const Vector<F32> &barrier); bool GameType::processLevelItem(S32 argc, const char **argv) --- 412,416 ---- } ! extern void constructBarriers(Game *theGame, const Vector<F32> &barrier, F32 width); bool GameType::processLevelItem(S32 argc, const char **argv) *************** *** 439,451 **** else if(!stricmp(argv[0], "BarrierMaker")) { ! Vector<F32> barrier; for(S32 i = 1; i < argc; i++) ! barrier.push_back(atof(argv[i]) * getGame()->getGridSize()); ! if(barrier.size() > 3) { mBarriers.push_back(barrier); ! constructBarriers(getGame(), barrier); } } else if(!stricmp(argv[0], "LevelName") && argc > 1) mLevelName.set(argv[1]); --- 440,455 ---- else if(!stricmp(argv[0], "BarrierMaker")) { ! BarrierRec barrier; for(S32 i = 1; i < argc; i++) ! barrier.verts.push_back(atof(argv[i]) * getGame()->getGridSize()); ! if(barrier.verts.size() > 3) { + barrier.width = mBarrierWidth; mBarriers.push_back(barrier); ! constructBarriers(getGame(), barrier.verts, mBarrierWidth); } } + else if(!stricmp(argv[0], "BarrierWidth")) + mBarrierWidth = atof(argv[1]); else if(!stricmp(argv[0], "LevelName") && argc > 1) mLevelName.set(argv[1]); *************** *** 889,897 **** // an empty list clears the barriers Vector<F32> v; ! s2cAddBarriers(v); for(S32 i = 0; i < mBarriers.size(); i++) { ! s2cAddBarriers(mBarriers[i]); } s2cSetTimeRemaining(mGameTimer.getCurrent()); --- 893,901 ---- // an empty list clears the barriers Vector<F32> v; ! s2cAddBarriers(v, 0); for(S32 i = 0; i < mBarriers.size(); i++) { ! s2cAddBarriers(mBarriers[i].verts, mBarriers[i].width); } s2cSetTimeRemaining(mGameTimer.getCurrent()); *************** *** 916,925 **** } ! GAMETYPE_RPC_S2C(GameType, s2cAddBarriers, (const Vector<F32> &barrier)) { if(!barrier.size()) getGame()->deleteObjects(BarrierType); else ! constructBarriers(getGame(), barrier); } --- 920,929 ---- } ! GAMETYPE_RPC_S2C(GameType, s2cAddBarriers, (const Vector<F32> &barrier, F32 width)) { if(!barrier.size()) getGame()->deleteObjects(BarrierType); else ! constructBarriers(getGame(), barrier, width); } Index: barrier.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/barrier.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** barrier.h 20 Aug 2004 18:26:58 -0000 1.5 --- barrier.h 15 Oct 2004 18:01:15 -0000 1.6 *************** *** 42,45 **** --- 42,46 ---- Point start; ///< The start point of the barrier Point end; ///< The end point of the barrier + F32 mWidth; enum { *************** *** 53,68 **** /// Barrier constructor. ! Barrier(Point st = Point(), Point e = Point()); /// Adds the server object to the net interface's scope always list void onAddedToGame(Game *theGame); - /// writes the Barrier state into the packet. Since Barrier objects never change - /// network state, this will only be called for the initial update of a barrier. - U32 packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream); - - /// reads the Barrier state from a packet. - void unpackUpdate(GhostConnection *connection, BitStream *stream); - /// renders this barrier by drawing the render line segments, void render(U32 layer); --- 54,62 ---- /// Barrier constructor. ! Barrier(Point st = Point(), Point e = Point(), F32 width = BarrierWidth); /// Adds the server object to the net interface's scope always list void onAddedToGame(Game *theGame); /// renders this barrier by drawing the render line segments, void render(U32 layer); Index: gameType.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.h,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** gameType.h 8 Oct 2004 00:17:47 -0000 1.37 --- gameType.h 15 Oct 2004 18:01:15 -0000 1.38 *************** *** 77,81 **** }; ! Vector<Vector<F32> > mBarriers; Vector<RefPtr<ClientRef> > mClientList; --- 77,88 ---- }; ! F32 mBarrierWidth; ! struct BarrierRec ! { ! Vector<F32> verts; ! F32 width; ! }; ! ! Vector<BarrierRec> mBarriers; Vector<RefPtr<ClientRef> > mClientList; *************** *** 182,186 **** void onGhostAvailable(GhostConnection *theConnection); TNL_DECLARE_RPC(s2cSetLevelInfo, (StringTableEntryRef levelName, StringTableEntryRef levelDesc)); ! TNL_DECLARE_RPC(s2cAddBarriers, (const Vector<F32> &barrier)); TNL_DECLARE_RPC(s2cAddTeam, (StringTableEntryRef teamName, F32 r, F32 g, F32 b)); TNL_DECLARE_RPC(s2cAddClient, (StringTableEntryRef clientName, bool isMyClient)); --- 189,193 ---- void onGhostAvailable(GhostConnection *theConnection); TNL_DECLARE_RPC(s2cSetLevelInfo, (StringTableEntryRef levelName, StringTableEntryRef levelDesc)); ! TNL_DECLARE_RPC(s2cAddBarriers, (const Vector<F32> &barrier, F32 width)); TNL_DECLARE_RPC(s2cAddTeam, (StringTableEntryRef teamName, F32 r, F32 g, F32 b)); TNL_DECLARE_RPC(s2cAddClient, (StringTableEntryRef clientName, bool isMyClient)); Index: barrier.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/barrier.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** barrier.cpp 28 Jul 2004 16:05:27 -0000 1.15 --- barrier.cpp 15 Oct 2004 18:01:15 -0000 1.16 *************** *** 41,45 **** U32 Barrier::mBarrierChangeIndex = 1; ! void constructBarriers(Game *theGame, const Vector<F32> &barrier) { Vector<Point> vec; --- 41,45 ---- U32 Barrier::mBarrierChangeIndex = 1; ! void constructBarriers(Game *theGame, const Vector<F32> &barrier, F32 width) { Vector<Point> vec; *************** *** 74,78 **** if(cosTheta >= 0) { ! F32 extendAmt = Barrier::BarrierWidth * 0.5 * tan( acos(cosTheta) / 2 ); if(extendAmt > 0.01) extendAmt -= 0.01; --- 74,78 ---- if(cosTheta >= 0) { ! F32 extendAmt = width * 0.5 * tan( acos(cosTheta) / 2 ); if(extendAmt > 0.01) extendAmt -= 0.01; *************** *** 97,106 **** Point start = vec[i] - edgeVector[i] * extendBack; Point end = vec[i+1] + edgeVector[i] * extendForward; ! Barrier *b = new Barrier(start, end); b->addToGame(theGame); } } ! Barrier::Barrier(Point st, Point e) { mObjectTypeMask = BarrierType | CommandMapVisType; --- 97,106 ---- Point start = vec[i] - edgeVector[i] * extendBack; Point end = vec[i+1] + edgeVector[i] * extendForward; ! Barrier *b = new Barrier(start, end, width); b->addToGame(theGame); } } ! Barrier::Barrier(Point st, Point e, F32 width) { mObjectTypeMask = BarrierType | CommandMapVisType; *************** *** 108,112 **** end = e; Rect r(start, end); ! r.expand(Point(BarrierWidth, BarrierWidth)); setExtent(r); mLastBarrierChangeIndex = 0; --- 108,113 ---- end = e; Rect r(start, end); ! mWidth = width; ! r.expand(Point(width, width)); setExtent(r); mLastBarrierChangeIndex = 0; *************** *** 117,147 **** } - U32 Barrier::packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream) - { - stream->write(start.x); - stream->write(start.y); - stream->write(end.x); - stream->write(end.y); - return 0; - } - - void Barrier::unpackUpdate(GhostConnection *connection, BitStream *stream) - { - stream->read(&start.x); - stream->read(&start.y); - stream->read(&end.x); - stream->read(&end.y); - - Rect r(start, end); - r.expand(Point(BarrierWidth, BarrierWidth)); - setExtent(r); - mBarrierChangeIndex++; - } - bool Barrier::getCollisionPoly(Vector<Point> &polyPoints) { Point vec = end - start; Point crossVec(vec.y, -vec.x); ! crossVec.normalize(BarrierWidth * 0.5); polyPoints.push_back(Point(start.x + crossVec.x, start.y + crossVec.y)); --- 118,126 ---- } bool Barrier::getCollisionPoly(Vector<Point> &polyPoints) { Point vec = end - start; Point crossVec(vec.y, -vec.x); ! crossVec.normalize(mWidth * 0.5); polyPoints.push_back(Point(start.x + crossVec.x, start.y + crossVec.y)); *************** *** 248,252 **** Rect bounds(start, end); ! bounds.expand(Point(BarrierWidth, BarrierWidth)); findObjects(BarrierType, fillObjects, bounds); --- 227,231 ---- Rect bounds(start, end); ! bounds.expand(Point(mWidth, mWidth)); findObjects(BarrierType, fillObjects, bounds); |