3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
8
**************************************************************************
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
***************************************************************************
33
class tPTRList:public tArray<tCheckedPTRBase *> {
34
friend tCheckedPTRBase;
38
tPTRList():tArray<tCheckedPTRBase *>(10000){}
40
void Add(tCheckedPTRBase *t){
41
if (t->id<0){ // tEventQueue relies on the fact that we put t in
42
t->id=Len(); // the last place.
48
void Remove(tCheckedPTRBase *t){
49
// con << "offset=" << offset << '\n';
50
if (t->id>=0 && Len()>0){
56
tERR_ERROR("Scr. list structure!");
58
tCheckedPTRBase *test=operator()(t->id);
60
tERR_ERROR("Screwed list structure!");
62
// the check for Len() is done, since this may be
63
// called on an allready descructed list.
64
tCheckedPTRBase *other=operator()(Len()-1);
65
operator()(t->id)=other;
78
List<tCheckedPTRBase> tCheckedPTRs;
80
tCheckedPTRBase::tCheckedPTRBase(void *x):id(-1),target(x){
82
tCheckedPTRs.Add(this,id);
84
//con << "Added defined tCheckedPTR " << this << " no " << id << '\n';
89
tCheckedPTRBase::tCheckedPTRBase(const tCheckedPTRBase& x)
90
:id(-1),target(x.target){
92
tCheckedPTRs.Add(this,id);
94
//con << "Added defined tCheckedPTR " << this << " no " << id << '\n';
99
tCheckedPTRBase::tCheckedPTRBase():id(-1),target(NULL){
101
tCheckedPTRs.Add(this,id);
103
//con << "Added NULL tCheckedPTR " << this << " no " << id << '\n';
109
tCheckedPTRBase::~tCheckedPTRBase(){
111
//con << "Removed tCheckedPTR no " << id << '\n';
114
tCheckedPTRs.Remove(this,id);
125
class gNetPlayerWall;
134
#include "tConfiguration.h"
135
#include "eGameObject.h"
139
extern List<gWallRim> se_rimWalls;
140
extern List<gNetPlayerWall> sg_netPlayerWalls;
141
extern List<gNetPlayerWall> gridded_sg_netPlayerWalls;
142
extern List<eCamera> se_cameras;
143
//extern List<tConfItemBase> tConfItemBase::tConfItems;
144
//extern List<eGameObject> eGameObject::gameObjects;
145
extern List<ePlayer> PlayerConfig;
146
extern List<ePlayerNetID> se_PlayerNetIDs;
147
extern List<uAction> s_playerActions;
148
extern List<uAction> s_cameraActions;
149
extern List<uAction> s_globalActions;
150
extern List<uAction> su_allActions;
151
//extern List<ePoint> ePoint::points;
152
//extern List<eEdge> eEdge::edges;
153
//extern List<eFace> eFace::faces;
156
template<class T> void suspicious(const List<T> &l,tCheckedPTRBase *adr){
160
for (i=l.Len()-1;i>=0;i--){
162
int dist=int(adr)-int(t);
163
if (dist>=0 && dist <1000 && int(t)>int(best)){
169
tERR_ERROR("Suspicious object has index " << best_ind << " and is at adress "
178
void tCheckedPTRBase::CheckDestructed(void *test){
179
for(int i=tCheckedPTRs.Len()-1;i>=0;i--){
180
tCheckedPTRBase * adr=tCheckedPTRs(i);
182
tERR_ERROR("Checked ptr list screwed! "
183
<< adr << ":" << adr->id << ":" << adr->target << ":" << i);
185
if (adr->target==test){
187
suspicious(se_rimWalls,adr);
188
suspicious(sg_netPlayerWalls,adr);
189
suspicious(gridded_sg_netPlayerWalls,adr);
190
suspicious(se_cameras,adr);
191
suspicious(tConfItemBase::tConfItems,adr);
192
suspicious(eGameObject::gameObjects,adr);
193
suspicious(eGameObject::gameObjectsInactive,adr);
194
suspicious(PlayerConfig,adr);
195
suspicious(se_PlayerNetID,adr);
196
suspicious(s_playerActions,adr);
197
suspicious(s_cameraActions,adr);
198
suspicious(s_globalActions,adr);
199
suspicious(su_allActions,adr);
200
suspicious(ePoint::points,adr);
201
suspicious(eEdge::edges,adr);
202
suspicious(eFace::faces,adr);
205
tERR_ERROR("Object destroyed, but pointer at " << adr <<
206
" still points to it!");
212
void tCheckedPTRBase::Check(){
213
for(int i=tCheckedPTRs.Len()-1;i>=0;i--){
214
tCheckedPTRBase * adr=tCheckedPTRs(i);
216
tERR_ERROR("Checked ptr list screwed! "
217
<< adr << ":" << adr->id << ":" << adr->target << ":" << i);