Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/world_entities/weapons/targeting_turret.cc @ 9615

Last change on this file since 9615 was 9614, checked in by bensch, 18 years ago

get segfault when changing the team

the turret is reparenting:
PNode::checkIntegrity (this=0x932a408, checkParent=0x90bfd50) at p_node.h:164
164 inline PNode* getParent () const { return this→parent; };
(gdb) bt
#0 PNode::checkIntegrity (this=0x932a408, checkParent=0x90bfd50)

at p_node.h:164

#1 0x082925d5 in PNode::addChild (this=0x932a408) at p_node.cc:493
#2 0x0808a05e in TargetingTurret::fire (this=0x8ed75f8)

at targeting_turret.cc:144

#3 0x0815f2d9 in Weapon::fireW (this=0x8ed75f8) at weapon.cc:511
#4 0x0815f0d5 in Weapon::execute (this=0x102) at weapon.cc:411
#5 0x0815f182 in Weapon::tickW (this=0x1, dt=0) at weapon.cc:597
#6 0x08089b9e in TargetingTurret::tick (this=0x8ed75f8, dt=0.104750276)

at targeting_turret.cc:116

#7 0x080f7b04 in GameWorld::tick (this=0x85ada60, entityList=

{<std::_List_base<WorldEntity*,std::allocator<WorldEntity*> >> = {_M_impl = {<std::allocator<std::_List_node<WorldEntity*> >> = {<gnu_cxx::new_allocator<std::_List_node<WorldEntity*> >> = {<No data fields>}, <No data fields>}, _M_node = {_M_next = 0x90063c8, _M_prev = 0x93a9c28}}}, <No data fields>},

dt=0.104750276) at stl_list.h:131

#8 0x080f8c73 in GameWorld::tick (this=0x85ada60) at new_allocator.h:69
#9 0x080f731e in GameWorld::run (this=0x85ada60) at game_world.cc:318
#10 0x080f7245 in GameWorld::start (this=0x102) at game_world.cc:252
#11 0x080f57d8 in Campaign::run (this=0x85ad1e8) at campaign.cc:152
#12 0x080f56e1 in Campaign::start (this=0x85ad1e8) at campaign.cc:83
#13 0x0817fd98 in GameLoader::start (this=0x102) at game_loader.cc:170
#14 0x0810fb53 in Orxonox::start (this=0x8382f68) at orxonox.cc:417
#15 0x0811266b in startOrxonox (argc=4, argv=0xbf8e0894, name=@0x102, port=258)

at orxonox.cc:573

#16 0x081136e0 in startNetworkOrxonox (argc=4, argv=0xbf8e0894)

at basic_string.h:1458

#17 0x081140af in main (argc=4, argv=0xbf8e0894) at orxonox.cc:479

this manly comes from the idea, that entities are not deleted during runtime, which obviously they do :/

so the bug is in PNode and is being traced

File size: 4.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific
12   main-programmer: Benjamin Grauer
13   co-programmer:
14*/
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
16
17#include "targeting_turret.h"
18
19#include "projectiles/projectile.h"
20
21#include "model.h"
22
23#include "animation3d.h"
24
25#include "util/loading/load_param.h"
26#include "util/loading/factory.h"
27
28CREATE_FACTORY(TargetingTurret, CL_TARGETING_TURRET);
29
30
31TargetingTurret::TargetingTurret(const TiXmlElement* root)
32  : target(this)
33{
34  this->init();
35  if( root != NULL)
36    this->loadParams(root);
37}
38
39/**
40 *  standard deconstructor
41*/
42TargetingTurret::~TargetingTurret ()
43{
44  // model will be deleted from WorldEntity-destructor
45//  delete this->target;
46}
47
48void TargetingTurret::init()
49{
50  this->setClassID(CL_TARGETING_TURRET, "TargetingTurret");
51
52  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
53  Animation3D* animation2 = this->getAnimation(WS_DEACTIVATING, this);
54
55  animation1->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
56  animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
57  animation2->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
58  animation2->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
59
60  animation1->setInfinity(ANIM_INF_CONSTANT);
61  animation2->setInfinity(ANIM_INF_CONSTANT);
62
63  this->setStateDuration(WS_SHOOTING, .5);
64  this->setStateDuration(WS_RELOADING, 1.0);
65  this->setStateDuration(WS_ACTIVATING, .4);
66  this->setStateDuration(WS_DEACTIVATING, .4);
67
68  this->setEnergyMax(100);
69  this->increaseEnergy(100);
70
71  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
72  this->setProjectileType(CL_GUIDED_MISSILE);
73
74
75  this->setEmissionPoint(1.684, 0.472, 0);
76  //this->getProjectileFactory()->prepare(100);
77
78  this->target.setVisibility(false);
79  this->target.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE);
80  this->target.setRange(1000);
81  this->target.setAngle(M_PI_4);
82  this->lockedTarget = &this->target;
83
84  this->lockedTime = 0;
85  this->neededLockTime = 2;
86  this->lockedTarget->setParent(PNode::getNullParent());
87  this->loadModel("models/guns/turret2.obj");
88
89
90  this->setActionSound(WA_SHOOT, "sound/explosions/explosion_3.wav");
91  this->setActionSound(WA_ACTIVATE, "sound/voices/rockets.wav");
92  this->setActionSound(WA_RELOAD, "sound/vocals/reload.wav");
93}
94
95void TargetingTurret::loadParams(const TiXmlElement* root)
96{
97  Weapon::loadParams(root);
98
99  LoadParam(root, "target-group", &target, Aim, setTargetGroupS);
100
101}
102
103void TargetingTurret::activate()
104{
105  // TODO move this back in
106  //this->target->setVisibility(true);
107}
108
109void TargetingTurret::deactivate()
110{
111  this->target.setVisibility(false);
112}
113
114void TargetingTurret::tick(float dt)
115{
116  if (!Weapon::tickW(dt))
117    return;
118
119  this->target.tick(dt);
120
121  if( lockedTime >= neededLockTime )
122   {
123    lockedTarget = this->target.getParent();
124    lockedTime = 0;
125   }
126
127
128  if(this->target.getParent() == PNode::getNullParent())
129   lockedTime = 0;
130  else
131   lockedTime += dt;
132
133}
134
135void TargetingTurret::fire()
136{
137  Projectile* pj = this->getProjectile();
138  if (pj == NULL)
139    return;
140
141  pj->setVelocity(this->getVelocity() + /*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13)
142            /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
143
144  pj->setTarget(lockedTarget);
145  pj->setParent(PNode::getNullParent());
146  pj->setAbsCoor(this->getEmissionPoint());
147  pj->setAbsDir(this->getAbsDir());
148  pj->activate();
149}
150
151/**
152 * draws the TargetingTurret
153*/
154void TargetingTurret::draw () const
155{
156  /* draw gun body */
157  glMatrixMode(GL_MODELVIEW);
158  glPushMatrix();
159  glTranslatef (this->getAbsCoor ().x,
160                this->getAbsCoor ().y,
161                this->getAbsCoor ().z);
162  Vector tmpRot = this->getAbsDir().getSpacialAxis();
163  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
164  if (this->getModel() != NULL)
165    this->getModel()->draw();
166  glPopMatrix();
167}
168
Note: See TracBrowser for help on using the repository browser.