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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*

*************************************************************************

ArmageTron -- Just another Tron Lightcycle Game in 3D.
Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
#include <stdio>
#include <stdlib.h> 
**************************************************************************

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 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  
***************************************************************************

*/

#ifndef ArmageTron_gWALL_H
#define ArmageTron_gWALL_H

#include "eAdvWall.h"
#include "nNetObject.h"
//#include "nObserver.h"
class gCycle;
class gCycleMovement;
class gNetPlayerWall;
class eTempEdge;

class gWallRim:public eWallRim{
public:
    gWallRim(eGrid *grid, REAL h=10000);
    gWallRim(eGrid *grid, REAL tBeg, REAL tEnd, REAL h=10000);
    virtual ~gWallRim();

    virtual bool Splittable() const;

    virtual void Split(eWall *& w1,eWall *& w2,REAL a);
    virtual bool RunsParallelPassive( eWall * newWall );

#ifndef DEDICATED
    void RenderReal(const eCamera *cam);
protected:
    virtual void OnBlocksCamera( eCamera * cam, REAL height ) const; //!< called by the camera code when this wall is between the cycle and the camera
#endif
    virtual REAL Height();
    virtual REAL SeeHeight();

private:
    mutable REAL renderHeight_; //!< the height with which this wall is really rendered
    mutable REAL lastUpdate_;   //!< time of the last render height update

    REAL tBeg_, tEnd_;          //!< begin and end texture coordinates
};

class gPlayerWallCoord{
public:
    REAL Pos;
    REAL Time;
    bool IsDangerous;
};

class gPlayerWall:public eWall{
public:
    gPlayerWall(gNetPlayerWall*w, gCycle *p);
    virtual ~gPlayerWall();

    //  virtual ArmageTron_eWalltype type();

    virtual void Flip();
    virtual void SplitByActive( eWall* oldWall );
    virtual bool RunsParallelActive( eWall* oldWall );

    virtual bool Splittable() const;
    virtual bool Deletable() const;

    virtual void Split(eWall *& w1,eWall *& w2,REAL a);

#ifndef DEDICATED
    virtual void Render(const eCamera *cam);
    void RenderList(bool list);
#endif

    virtual REAL BlockHeight() const;
    virtual REAL SeeHeight() const;

    int WindingNumber() const {return windingNumber_;}

    REAL LocalToGlobal( REAL a ) const;
    REAL GlobalToLocal( REAL a ) const;

    REAL Time(REAL a) const;
    REAL Pos(REAL a) const;
    REAL Alpha(REAL pos) const;
    bool IsDangerousAnywhere( REAL time ) const;
    bool IsDangerous( REAL a, REAL time ) const;

    void BlowHole	( REAL dbeg, REAL dend ); // blow a hole into the wall form distance dbeg to dend

    REAL BegPos() const;
    REAL EndPos() const;
    REAL BegTime() const;
    REAL EndTime() const;

    gCycle *Cycle() const;
    gCycleMovement *CycleMovement() const;
    gNetPlayerWall* NetWall() const;

    void Insert();

    //  void SetNetWall( const gNetPlayerWall* netWall );
    //  void SetCoords( const tArray< gPlayerWallCoord >& coords );
    //  const tArray< gPlayerWallCoord >&  GetCoords() const;
private:
    void Check() const;
    tCONTROLLED_PTR(gCycle) cycle_;
    tCONTROLLED_PTR(gNetPlayerWall) netWall_;

    //  nObserverPtr< gNetPlayerWall > netWall_;

    int windingNumber_;
    REAL begAlpha_, endAlpha_;	// relative position i gNetPlayerWall

    gPlayerWall();
};


// the sn_netObjects that represents eWalls across the network.
class gNetPlayerWall: public nNetObject{
    friend class gCycle;
    int id,griddedid;

    tCONTROLLED_PTR(gCycle) cycle_;       // our cycle
    tCONTROLLED_PTR(eTempEdge) edge_;       // the eEdge we are representing

    eCoord dir;      // the direction from start to end
    REAL dbegin;    // the start position
    eCoord beg,end;  // start and end points
    REAL tBeg,tEnd; // start and end time

    unsigned short inGrid;   // are we planned to be insite the grid?
    REAL           gridding; // when are we going to enter the grid?

bool           preliminary:1; // is it a eWall preliminary installed?
    REAL       obsoleted_;    // the game time this preliminary wall got obsoleted by a final wall (negative if it is not yet obsolete)
    // by the client while it is waiting for the real eWall from the server?

    void CreateEdge();
    void InitArray();
    void MyInitAfterCreation();
    void real_CopyIntoGrid(eGrid *grid);
    void real_Update(REAL tEnd,const eCoord &pend, bool force );
public:
    virtual void InitAfterCreation();
    gNetPlayerWall(gCycle *c,
                   const eCoord &beg,const eCoord &dir,
                   REAL tBeg, REAL dbeg);

    //  void Update(REAL tEnd,REAL dend);
    void Update(REAL tEnd,const eCoord &pend);
    void CopyIntoGrid(eGrid *grid,bool force=false);
    static void s_CopyIntoGrid();
    void RealWallReceived( gNetPlayerWall* realwall );

    gNetPlayerWall(nMessage &m);

    //eCoord Vec(){return w->Vec();}
    eCoord Vec();  //!< returns the vector from the beginning to the end of the wall
protected:
    virtual ~gNetPlayerWall();
    void ReleaseData(); // release all references
public:
    void SetEndTime(REAL et);
    void SetEndPos(REAL ep);

    int  IndexAlpha(REAL a) const;
    int  IndexPos(REAL d) const;
    REAL Time(REAL a) const;
    REAL Pos(REAL a) const;
    REAL Alpha(REAL pos) const;
    bool IsDangerousAnywhere( REAL time ) const;
    bool IsDangerous( REAL a, REAL time ) const;

    void BlowHole	( REAL dbeg, REAL dend ); // blow a hole into the wall form distance dbeg to dend

    REAL BegPos() const;
    REAL EndPos() const;
    REAL BegTime() const;
    REAL EndTime() const;

    const eCoord& EndPoint(int i) const
    {
        switch ( i )
        {
        case 0:
            return beg;
        case 1:
        default:
            return end;
        }
    }


#ifndef DEDICATED
    virtual void Render(const eCamera *cam);
    void RenderList(bool list);
    virtual void RenderNormal(const eCoord &x1,const eCoord &x2,REAL ta,REAL te,REAL r,REAL g,REAL b,REAL a);
    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);
#endif

    virtual bool ActionOnQuit();

    virtual bool ClearToTransmit(int user) const;

    virtual void WriteSync(nMessage &m);
    virtual void ReadSync(nMessage &m);

    virtual void WriteCreate(nMessage &m);
    virtual nDescriptor &CreatorDescriptor() const;
    virtual void PrintName(tString &s) const;

    virtual bool SyncIsNew(nMessage &m);


eTempEdge   *Edge(){return this->edge_;}
    gPlayerWall *Wall();
    gCycle *Cycle() const {return this->cycle_;}
    gCycleMovement *CycleMovement() const;

    bool Preliminary()const{return preliminary;}
    bool InGrid()const{return inGrid;}

    static void Clear(); // delete all sg_netPlayerWalls.

private:
    void Check() const;
    tArray<gPlayerWallCoord> coords_;

    unsigned int displayList_;
};

extern tList<gNetPlayerWall> sg_netPlayerWalls;

#endif