Creation of objects

Creation of objects

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Creation of objects

Post by zerver »

Is it safe to assume all Units/Projectiles (synced and unsynced) will be created in Sim code?

I'm optimizing the ProjectileHandler and the above assumption simplifies things a great deal...
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Creation of objects

Post by Tobi »

If "Sim code" includes synced Lua callouts and possibly Game.cpp (where is /give handled?) then I think that is right.

How does it simplify things?
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Creation of objects

Post by zerver »

Well, if object creation is limited to a single thread, I can create projectiles without using any synchronization at all. Creating synced objects in non-Sim code wouldn't be very clever, but I was a bit concerned about unsynced projectiles and that someone might want to create them in a rendering thread.

Also, u have a clue what this code is supposed to accomplish?

Code: Select all

 void CLightningProjectile::DrawOnMinimap(CVertexArray& lines, CVertexArray& points)
 {
-	unsigned char color[4] = {(unsigned char)color[0]*255,(unsigned char)color[1]*255,(unsigned char)color[2]*255,255};
The array accesses itself upon initialization. Hmm.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Creation of objects

Post by Kloot »

Code: Select all

class CLightningProjectile ... {
   ...
   float3 color; // float3 overloads operator []
}
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Creation of objects

Post by imbaczek »

confusing code is confusing. suggest adding this-> in that initialization.
Post Reply

Return to “Engine”