Cleanup, coupled with complete failure to fix leaks.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4229 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2011-02-04 20:13:56 +00:00
parent 6415676c0e
commit 7da10a764a
5 changed files with 36 additions and 32 deletions

View File

@ -37,9 +37,10 @@ MA 02110-1301, USA.
@private
GLfloat _color[4];
OOTimeDelta _lifetime;
GLfloat _range;
}
- (id) initLaserFromShip:(ShipEntity *)ship view:(OOViewID)view offset:(Vector)offset;
+ (id) laserFromShip:(ShipEntity *)ship view:(OOViewID)view offset:(Vector)offset;
- (void) setColor:(OOColor *)color;

View File

@ -98,7 +98,7 @@ MA 02110-1301, USA.
position = vector_add(pos, viewOffset);
[self setOrientation:q];
[self setCollisionRadius:[srcEntity weaponRange]];
_range = [srcEntity weaponRange];
[self setOwner:ship];
_color[0] = kLaserRed;
@ -112,6 +112,12 @@ MA 02110-1301, USA.
}
+ (id) laserFromShip:(ShipEntity *)ship view:(OOViewID)view offset:(Vector)offset
{
return [[[self alloc] initLaserFromShip:ship view:view offset:offset] autorelease];
}
- (void) dealloc
{
[self setColor:nil];
@ -173,15 +179,15 @@ static const GLfloat kLaserVertices[] =
OOGL(glEnableClientState(GL_VERTEX_ARRAY));
/* FIXME: ideally, collision_radius would be updated by tracing along the
initial firing vector. Even ideallier, we should spread damage across
the lifetime of the shot, hurting whatever is hit in a given frame.
Something for EMMSTRAN.
/* FIXME: ideally, _range would be updated by tracing along the initial
firing vector (or the initial vector relative to the owner). Even
ideallier, we should spread damage across the lifetime of the shot,
hurting whatever is hit in a given frame. Something for EMMSTRAN.
-- Ahruman 2011-01-31
*/
OOGL(glColor4fv(_color));
glScaled(kLaserHalfWidth, kLaserHalfWidth, collision_radius);
glScaled(kLaserHalfWidth, kLaserHalfWidth, _range);
glVertexPointer(3, GL_FLOAT, 0, kLaserVertices);
glDrawArrays(GL_QUADS, 0, 8);

View File

@ -57,7 +57,6 @@ MA 02110-1301, USA.
NSSize size;
}
//- (id) initLaserFromShip:(ShipEntity *) ship view:(OOViewID) view offset:(Vector)offset;
- (id) initEnergyMineFromShip:(ShipEntity *) ship;
- (id) initHyperringFromShip:(ShipEntity *) ship;
- (id) initFragburstSize:(GLfloat) fragSize fromPosition:(Vector) fragPos;

View File

@ -4183,6 +4183,7 @@ static GLfloat scripted_color[4] = { 0.0, 0.0, 0.0, 0.0}; // to be defined by s
else [self deactivateCloakingDevice];
}
- (BOOL)hasAutoCloak
{
return cloakAutomatic;
@ -4225,10 +4226,9 @@ static GLfloat scripted_color[4] = { 0.0, 0.0, 0.0, 0.0}; // to be defined by s
setUpShipFromDictionary:, when the mesh is initially set up.
-- Ahruman 2008-04-19
*/
OODrawable *drawable_ = [self drawable];
if (isSubEntity)
{
[drawable_ setBindingTarget:self];
[[self drawable] setBindingTarget:self];
}
}
@ -7506,7 +7506,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
ShipEntity *victim = [UNIVERSE getFirstShipHitByLaserFromShip:self inView:direction offset: make_vector(0,0,0) rangeFound: &hit_at_range];
[self setShipHitByLaser:victim];
shot = [[OOLaserShotEntity alloc] initLaserFromShip:self view:direction offset:kZeroVector];
shot = [OOLaserShotEntity laserFromShip:self view:direction offset:kZeroVector];
[shot setColor:laser_color];
[shot setScanClass: CLASS_NO_DRAW];
@ -7535,7 +7535,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
}
[UNIVERSE addEntity:shot];
[shot release];
[self resetShotTime];
@ -7570,7 +7569,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
Vector vel = vector_multiply_scalar(v_forward, flightSpeed);
// do special effects laser line
shot = [[OOLaserShotEntity alloc] initLaserFromShip:self view:VIEW_FORWARD offset:kZeroVector];
shot = [OOLaserShotEntity laserFromShip:self view:VIEW_FORWARD offset:kZeroVector];
[shot setColor:laser_color];
[shot setScanClass: CLASS_NO_DRAW];
[shot setPosition: position];
@ -7602,7 +7601,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
}
[UNIVERSE addEntity:shot];
[shot release];
[self resetShotTime];
@ -7645,7 +7643,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
ShipEntity *victim = [UNIVERSE getFirstShipHitByLaserFromShip:self inView:direction offset:laserPortOffset rangeFound: &hit_at_range];
[self setShipHitByLaser:victim];
shot = [[OOLaserShotEntity alloc] initLaserFromShip:self view:direction offset:laserPortOffset]; // alloc retains!
shot = [OOLaserShotEntity laserFromShip:self view:direction offset:laserPortOffset];
[shot setColor:laser_color];
[shot setScanClass: CLASS_NO_DRAW];
@ -7684,7 +7682,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
}
[UNIVERSE addEntity:shot];
[shot release]; //release
[self resetShotTime];

View File

@ -5007,21 +5007,8 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
if (!no_update)
{
NSString * volatile update_stage = @"initialisation";
#ifndef NDEBUG
id volatile update_stage_param = nil;
#endif
NS_DURING
int i;
PlayerEntity* player = PLAYER;
int ent_count = n_entities;
Entity* my_entities[ent_count];
skyClearColor[0] = 0.0;
skyClearColor[1] = 0.0;
skyClearColor[2] = 0.0;
skyClearColor[3] = 0.0;
unsigned i, ent_count = n_entities;
Entity *my_entities[ent_count];
// use a retained copy so this can't be changed under us.
for (i = 0; i < ent_count; i++)
@ -5029,6 +5016,19 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
my_entities[i] = [sortedEntities[i] retain]; // explicitly retain each one
}
NSString * volatile update_stage = @"initialisation";
#ifndef NDEBUG
id volatile update_stage_param = nil;
#endif
NS_DURING
PlayerEntity *player = PLAYER;
skyClearColor[0] = 0.0;
skyClearColor[1] = 0.0;
skyClearColor[2] = 0.0;
skyClearColor[3] = 0.0;
time_delta = delta_t;
universal_time += delta_t;
@ -5208,12 +5208,6 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
doLinkedListMaintenanceThisUpdate = NO;
}
// dispose of the non-mutable copy and everything it references neatly
update_stage = @"clean up";
for (i = 0; i < ent_count; i++)
[my_entities[i] release]; // explicitly release each one
NS_HANDLER
if ([[localException name] hasPrefix:@"Oolite"])
[self handleOoliteException:localException];
@ -5226,6 +5220,13 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
[localException raise];
}
NS_ENDHANDLER
// dispose of the non-mutable copy and everything it references neatly
update_stage = @"clean up";
for (i = 0; i < ent_count; i++)
{
[my_entities[i] release]; // explicitly release each one
}
}
[entitiesDeadThisUpdate autorelease];