~luke-jr/tr2norigins/armagetron-0.2.8-t2o-accesslvls

« back to all changes in this revision

Viewing changes to src/tron/gWall.h

  • Committer: luke-jr
  • Date: 2006-05-29 01:55:42 UTC
  • Revision ID: svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Fbranches%2F0.2.8%2Farmagetronad:4612
Unify tags/branches of modules released together

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
*************************************************************************
 
4
 
 
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
 
6
Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
 
7
#include <stdio>
 
8
#include <stdlib.h> 
 
9
**************************************************************************
 
10
 
 
11
This program is free software; you can redistribute it and/or
 
12
modify it under the terms of the GNU General Public License
 
13
as published by the Free Software Foundation; either version 2
 
14
of the License, or (at your option) any later version.
 
15
 
 
16
This program is distributed in the hope that it will be useful,
 
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
GNU General Public License for more details.
 
20
 
 
21
You should have received a copy of the GNU General Public License
 
22
along with this program; if not, write to the Free Software
 
23
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
24
  
 
25
***************************************************************************
 
26
 
 
27
*/
 
28
 
 
29
#ifndef ArmageTron_gWALL_H
 
30
#define ArmageTron_gWALL_H
 
31
 
 
32
#include "eAdvWall.h"
 
33
#include "nNetObject.h"
 
34
//#include "nObserver.h"
 
35
class gCycle;
 
36
class gCycleMovement;
 
37
class gNetPlayerWall;
 
38
class eTempEdge;
 
39
 
 
40
class gWallRim:public eWallRim{
 
41
public:
 
42
    gWallRim(eGrid *grid, REAL h=10000);
 
43
    gWallRim(eGrid *grid, REAL tBeg, REAL tEnd, REAL h=10000);
 
44
    virtual ~gWallRim();
 
45
 
 
46
    virtual bool Splittable() const;
 
47
 
 
48
    virtual void Split(eWall *& w1,eWall *& w2,REAL a);
 
49
    virtual bool RunsParallelPassive( eWall * newWall );
 
50
 
 
51
#ifndef DEDICATED
 
52
    void RenderReal(const eCamera *cam);
 
53
protected:
 
54
    virtual void OnBlocksCamera( eCamera * cam, REAL height ) const; //!< called by the camera code when this wall is between the cycle and the camera
 
55
#endif
 
56
    virtual REAL Height();
 
57
    virtual REAL SeeHeight();
 
58
 
 
59
private:
 
60
    mutable REAL renderHeight_; //!< the height with which this wall is really rendered
 
61
    mutable REAL lastUpdate_;   //!< time of the last render height update
 
62
 
 
63
    REAL tBeg_, tEnd_;          //!< begin and end texture coordinates
 
64
};
 
65
 
 
66
class gPlayerWallCoord{
 
67
public:
 
68
    REAL Pos;
 
69
    REAL Time;
 
70
    bool IsDangerous;
 
71
};
 
72
 
 
73
class gPlayerWall:public eWall{
 
74
public:
 
75
    gPlayerWall(gNetPlayerWall*w, gCycle *p);
 
76
    virtual ~gPlayerWall();
 
77
 
 
78
    //  virtual ArmageTron_eWalltype type();
 
79
 
 
80
    virtual void Flip();
 
81
    virtual void SplitByActive( eWall* oldWall );
 
82
    virtual bool RunsParallelActive( eWall* oldWall );
 
83
 
 
84
    virtual bool Splittable() const;
 
85
    virtual bool Deletable() const;
 
86
 
 
87
    virtual void Split(eWall *& w1,eWall *& w2,REAL a);
 
88
 
 
89
#ifndef DEDICATED
 
90
    virtual void Render(const eCamera *cam);
 
91
    void RenderList(bool list);
 
92
#endif
 
93
 
 
94
    virtual REAL BlockHeight() const;
 
95
    virtual REAL SeeHeight() const;
 
96
 
 
97
    int WindingNumber() const {return windingNumber_;}
 
98
 
 
99
    REAL LocalToGlobal( REAL a ) const;
 
100
    REAL GlobalToLocal( REAL a ) const;
 
101
 
 
102
    REAL Time(REAL a) const;
 
103
    REAL Pos(REAL a) const;
 
104
    REAL Alpha(REAL pos) const;
 
105
    bool IsDangerousAnywhere( REAL time ) const;
 
106
    bool IsDangerous( REAL a, REAL time ) const;
 
107
 
 
108
    void BlowHole       ( REAL dbeg, REAL dend ); // blow a hole into the wall form distance dbeg to dend
 
109
 
 
110
    REAL BegPos() const;
 
111
    REAL EndPos() const;
 
112
    REAL BegTime() const;
 
113
    REAL EndTime() const;
 
114
 
 
115
    gCycle *Cycle() const;
 
116
    gCycleMovement *CycleMovement() const;
 
117
    gNetPlayerWall* NetWall() const;
 
118
 
 
119
    void Insert();
 
120
 
 
121
    //  void SetNetWall( const gNetPlayerWall* netWall );
 
122
    //  void SetCoords( const tArray< gPlayerWallCoord >& coords );
 
123
    //  const tArray< gPlayerWallCoord >&  GetCoords() const;
 
124
private:
 
125
    void Check() const;
 
126
    tCONTROLLED_PTR(gCycle) cycle_;
 
127
    tCONTROLLED_PTR(gNetPlayerWall) netWall_;
 
128
 
 
129
    //  nObserverPtr< gNetPlayerWall > netWall_;
 
130
 
 
131
    int windingNumber_;
 
132
    REAL begAlpha_, endAlpha_;  // relative position i gNetPlayerWall
 
133
 
 
134
    gPlayerWall();
 
135
};
 
136
 
 
137
 
 
138
// the sn_netObjects that represents eWalls across the network.
 
139
class gNetPlayerWall: public nNetObject{
 
140
    friend class gCycle;
 
141
    int id,griddedid;
 
142
 
 
143
    tCONTROLLED_PTR(gCycle) cycle_;       // our cycle
 
144
    tCONTROLLED_PTR(eTempEdge) edge_;       // the eEdge we are representing
 
145
 
 
146
    eCoord dir;      // the direction from start to end
 
147
    REAL dbegin;    // the start position
 
148
    eCoord beg,end;  // start and end points
 
149
    REAL tBeg,tEnd; // start and end time
 
150
 
 
151
    unsigned short inGrid;   // are we planned to be insite the grid?
 
152
    REAL           gridding; // when are we going to enter the grid?
 
153
 
 
154
bool           preliminary:1; // is it a eWall preliminary installed?
 
155
    REAL       obsoleted_;    // the game time this preliminary wall got obsoleted by a final wall (negative if it is not yet obsolete)
 
156
    // by the client while it is waiting for the real eWall from the server?
 
157
 
 
158
    void CreateEdge();
 
159
    void InitArray();
 
160
    void MyInitAfterCreation();
 
161
    void real_CopyIntoGrid(eGrid *grid);
 
162
    void real_Update(REAL tEnd,const eCoord &pend, bool force );
 
163
public:
 
164
    virtual void InitAfterCreation();
 
165
    gNetPlayerWall(gCycle *c,
 
166
                   const eCoord &beg,const eCoord &dir,
 
167
                   REAL tBeg, REAL dbeg);
 
168
 
 
169
    //  void Update(REAL tEnd,REAL dend);
 
170
    void Update(REAL tEnd,const eCoord &pend);
 
171
    void CopyIntoGrid(eGrid *grid,bool force=false);
 
172
    static void s_CopyIntoGrid();
 
173
    void RealWallReceived( gNetPlayerWall* realwall );
 
174
 
 
175
    gNetPlayerWall(nMessage &m);
 
176
 
 
177
    //eCoord Vec(){return w->Vec();}
 
178
    eCoord Vec();  //!< returns the vector from the beginning to the end of the wall
 
179
protected:
 
180
    virtual ~gNetPlayerWall();
 
181
    void ReleaseData(); // release all references
 
182
public:
 
183
    void SetEndTime(REAL et);
 
184
    void SetEndPos(REAL ep);
 
185
 
 
186
    int  IndexAlpha(REAL a) const;
 
187
    int  IndexPos(REAL d) const;
 
188
    REAL Time(REAL a) const;
 
189
    REAL Pos(REAL a) const;
 
190
    REAL Alpha(REAL pos) const;
 
191
    bool IsDangerousAnywhere( REAL time ) const;
 
192
    bool IsDangerous( REAL a, REAL time ) const;
 
193
 
 
194
    void BlowHole       ( REAL dbeg, REAL dend ); // blow a hole into the wall form distance dbeg to dend
 
195
 
 
196
    REAL BegPos() const;
 
197
    REAL EndPos() const;
 
198
    REAL BegTime() const;
 
199
    REAL EndTime() const;
 
200
 
 
201
    const eCoord& EndPoint(int i) const
 
202
    {
 
203
        switch ( i )
 
204
        {
 
205
        case 0:
 
206
            return beg;
 
207
        case 1:
 
208
        default:
 
209
            return end;
 
210
        }
 
211
    }
 
212
 
 
213
 
 
214
#ifndef DEDICATED
 
215
    virtual void Render(const eCamera *cam);
 
216
    void RenderList(bool list);
 
217
    virtual void RenderNormal(const eCoord &x1,const eCoord &x2,REAL ta,REAL te,REAL r,REAL g,REAL b,REAL a);
 
218
    virtual void RenderBegin(const eCoord &x1,const eCoord &x2,REAL ta,REAL te,REAL ra,REAL rb,REAL r,REAL g,REAL b,REAL a);
 
219
#endif
 
220
 
 
221
    virtual bool ActionOnQuit();
 
222
 
 
223
    virtual bool ClearToTransmit(int user) const;
 
224
 
 
225
    virtual void WriteSync(nMessage &m);
 
226
    virtual void ReadSync(nMessage &m);
 
227
 
 
228
    virtual void WriteCreate(nMessage &m);
 
229
    virtual nDescriptor &CreatorDescriptor() const;
 
230
    virtual void PrintName(tString &s) const;
 
231
 
 
232
    virtual bool SyncIsNew(nMessage &m);
 
233
 
 
234
 
 
235
eTempEdge   *Edge(){return this->edge_;}
 
236
    gPlayerWall *Wall();
 
237
    gCycle *Cycle() const {return this->cycle_;}
 
238
    gCycleMovement *CycleMovement() const;
 
239
 
 
240
    bool Preliminary()const{return preliminary;}
 
241
    bool InGrid()const{return inGrid;}
 
242
 
 
243
    static void Clear(); // delete all sg_netPlayerWalls.
 
244
 
 
245
private:
 
246
    void Check() const;
 
247
    tArray<gPlayerWallCoord> coords_;
 
248
 
 
249
    unsigned int displayList_;
 
250
};
 
251
 
 
252
extern tList<gNetPlayerWall> sg_netPlayerWalls;
 
253
 
 
254
#endif