Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411560 Posts in 69384 Topics- by 58443 Members - Latest Member: junkmail

May 03, 2024, 01:39:01 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Post if you just laughed at your code.
Pages: 1 ... 22 23 [24] 25 26 27
Print
Author Topic: Post if you just laughed at your code.  (Read 86678 times)
Geti
Level 10
*****



View Profile WWW
« Reply #460 on: October 04, 2013, 02:52:43 AM »

Every component starts off as null, then giving an entity a component is just making that void pointer point to something. So for example a position component, g_entities[id][COMPONENT_POSITION] is a pointer to a vector.
This still certainly doesn't let you have >1 of the same type of component, and wastes memory on pointers to nothing for every entity - I guess you've got a static size for g_entities, but personally I love being able to have gib particles that are just a sprite and a box collider and have them be almost as cheap as your regular instanced particle system - with sprite and box collider instances I guess they could be exactly as cheap Smiley

As I said, I also like to have the ability to have >1 sprite or shape working together as an object. Different strokes for different folks though. Cheers for the source link.
Logged

DerangedMind
Level 0
*


View Profile
« Reply #461 on: October 08, 2013, 12:50:18 PM »

I'm placing bosses as a subclass of enemies. Needed to do a check to see if this class was a Boss class or not and found a reasonable way of doing it. At least I think it is. Don't judge me on my lack of programming knowledge! Tongue

Code:
if (this is Boss) {
    trace('like a boss');}

Heheheheh Wink
Logged
Will Vale
Level 4
****



View Profile WWW
« Reply #462 on: October 08, 2013, 02:11:47 PM »

This still certainly doesn't let you have >1 of the same type of component, and wastes memory on pointers to nothing for every entity - I guess you've got a static size for g_entities,
If you allocate the entities from a pool then the fixed size can save you quite a bit in allocation overhead, alignment slop etc.

I do something similar but don't label the slots, so there's no problem having multiple sprites or whatever - like you say, that's really powerful. Labelling the slots is great for constant-time access to components though, but if you don't do much e.get_component(type) then that won't really benefit you.

Thinking about it I could get the best of both worlds (fixed size, no overhead) by having just a head pointer in the entity, and threading a linked list through the components themselves. Hmmm....

Will
Logged
Geti
Level 10
*****



View Profile WWW
« Reply #463 on: October 08, 2013, 06:52:01 PM »

If you allocate the components in a pool by system you can save more and still get the flexibility, especially from tight loops working over each component pool (data cache friendly and instruction cache friendly).

You can actually cast off the idea of "an entity" completely and just organise pointers to the components however you like.

Code:
typedef struct {
   Sprite* head;
   Sprite* body;
   Square* physics;
   Sound* explosion;
   Script* whatever;
} specific_object_t;

For constant time, named, non stringified, type checked access Smiley The time critical logic (eg rendering, physics updates) is done in the component subsystem and doesn't need an entity to work on anyway.
Logged

Will Vale
Level 4
****



View Profile WWW
« Reply #464 on: October 09, 2013, 02:11:18 AM »

If you allocate the components in a pool by system you can save more and still get the flexibility, especially from tight loops working over each component pool (data cache friendly and instruction cache friendly).
Yep, that's how I have things set up already.

Quote
You can actually cast off the idea of "an entity" completely and just organise pointers to the components however you like.
At the moment all my entity construction is data-driven so I don't have any specific types. I like how straightforward that approach is though.

I dealt with the constant-time access thing a bit differently in mine - since all the work is in components (well, in their systems) it's actually the components that need to refer to each other. So if a component has a member which is a SomeOtherComponent* then the runtime wires that up to a suitable target when the entity containing both is created.

This still feels like a bit of a crutch - I have messaging as well but I haven't embraced it for everything yet.

Will
Logged
Geti
Level 10
*****



View Profile WWW
« Reply #465 on: October 09, 2013, 02:35:38 AM »

My solution to the second problem is just not having components that depend on each other, haha. There's no reason for the sprite system to know anything about the physics - if they need to share a position then a system can copy stuff around when needed or it can be handled in the scripts.

IMO, Ideally, components are just data - they should work as a value type.

Re: Messaging - it should likely be between script/logic components, networking should be encapsulated as a separate component as well that the logic can send and read things from by accessing the component itself, or else registering a callback.

I may be doing a semi "clean room" 2d engine implementation in between projects soon, we'll see how far I take the technical purism there :^) In KAG, we have ugly entity objects with set components and I always feel limited by it - whenever I do a small jam game I end up writing rudimentary components like I've been discussing here and I'd really like to have a proper framework for it, considering it's just busy work.
Logged

Will Vale
Level 4
****



View Profile WWW
« Reply #466 on: October 09, 2013, 04:13:15 AM »

If you do get time to do a clean version, I'd be interested to see it.

I find that most of the messy stuff in mine is on the gameplay side - my pilot needs to set forces on the physics body, for example, and some game logic needs to manipulate sprites. But the engine-provided components are completely isolated from each other. As things solidify I've tended to move these interactions to messages.

I suspect if I added scripting into the mix then most of the that mess would hide inside it and it wouldn't distress me so much Smiley My progress on all of this is glacial, but I don't get to write gameplay code at work anymore so it's nice to have somewhere to try things out.
Logged
Kekskiller
Guest
« Reply #467 on: November 01, 2013, 04:40:34 AM »

Code:
class FixArr

If you ever need a fix... get a fixar.
Logged
M.C.THUGZ
BANNED
Level 0
*


卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐卐


View Profile WWW
« Reply #468 on: November 02, 2013, 11:07:10 PM »

Code:
bl vector::intersects( translation& _translation, bl _bl_dst_int, const vector& _vector, const line& l,
bl _bl_facing_away ) const
{
  if( !_bl_facing_away )
  {
    if( abs( math<f32>::diff_radians( l.get_normal_direction(),
    get_direction( _vector ) + math<f32>::pi() ) ) >= math<f32>::pi_05() )
    {
      return false;
  } }

  vector post( *this   );
  vector dest( _vector );

  f32 deno = ( l.p2.y - l.p1.y ) * ( dest.x - post.x ) - ( l.p2.x - l.p1.x ) * ( dest.y - post.y );
  f32 num1 = ( l.p2.x - l.p1.x ) * ( post.y - l.p1.y ) - ( l.p2.y - l.p1.y ) * ( post.x - l.p1.x );
  f32 num2 = ( dest.x - post.x ) * ( post.y - l.p1.y ) - ( dest.y - post.y ) * ( post.x - l.p1.x );

  if( math<f32>::equals( deno ) )
  {
    if( math<f32>::equals( num1 ) && math<f32>::equals( num2 ) )
    {
      vector vector_intersection;

      if(      l.p1 == post || l.p2 == post ) vector_intersection = post;
      else if( l.p2 == dest || l.p1 == dest ) vector_intersection = dest;
      else if( l.p1.x > post.x && l.p2.x > post.x && l.p1.x > dest.x && l.p2.x > dest.x ) return false;
      else if( l.p1.y > post.y && l.p2.y > post.y && l.p1.y > dest.y && l.p2.y > dest.y ) return false;
      else if( l.p1.x < post.x && l.p2.x < post.x && l.p1.x < dest.x && l.p2.x < dest.x ) return false;
      else if( l.p1.y < post.y && l.p2.y < post.y && l.p1.y < dest.y && l.p2.y < dest.y ) return false;
      else
      {
        vector vector_min, vector_max;

        if(      ( post.x > l.p1.x && post.x > l.p2.x && post.x > dest.x )
        ||       ( post.y > l.p1.y && post.y > l.p2.y && post.y > dest.y ) ) vector_max = post;
        else if( ( dest.x > l.p1.x && dest.x > l.p2.x && dest.x > post.x )
        ||       ( dest.y > l.p1.y && dest.y > l.p2.y && dest.y > post.y ) ) vector_max = dest;
        else if( ( l.p1.x > post.x && l.p1.x > l.p2.x && l.p1.x > dest.x )
        ||       ( l.p1.y > post.y && l.p1.y > l.p2.y && l.p1.y > dest.y ) ) vector_max = l.p1;
        else vector_max = l.p2;

        if( vector_max != post
        && ( ( post.x < l.p1.x && post.x < l.p2.x && post.x < dest.x )
        ||   ( post.y < l.p1.y && post.y < l.p2.y && post.y < dest.y ) ) ) vector_min = post;
        else if( vector_max != dest
        && ( ( dest.x < l.p1.x && dest.x < l.p2.x && dest.x < post.x )
        ||   ( dest.y < l.p1.y && dest.y < l.p2.y && dest.y < post.y ) ) ) vector_min = dest;
        else if( vector_max != l.p1
        && ( ( l.p1.x < post.x && l.p1.x < l.p2.x && l.p1.x < dest.x )
        || (   l.p1.y < post.y && l.p1.y < l.p2.y && l.p1.y < dest.y ) ) ) vector_min = l.p1;
        else vector_min = l.p2;

        vector_intersection = vector();

        if( post != vector_max && post != vector_min ) vector_intersection += post;
        if( dest != vector_max && dest != vector_min ) vector_intersection += dest;
        if( l.p1 != vector_max && l.p1 != vector_min ) vector_intersection += l.p1;
        if( l.p2 != vector_max && l.p2 != vector_min ) vector_intersection += l.p2;

        vector_intersection *= 0.5f;
      }

      _translation = translation( line( post, dest ), vector_intersection, l, _bl_dst_int );

      return true;
    }

    return false;
  }

  f32 f32_u1 = math<f32>::divide( num1, deno );
  if( f32_u1 < 0.f || f32_u1 > 1.f )
    return false;

  f32 f32_u2 = math<f32>::divide( num2, deno );
  if( f32_u2 < 0.f || f32_u2 > 1.f )
    return false;

  vector vector_intersection(
    post.x + f32_u1 * ( dest.x - post.x ),
    post.y + f32_u1 * ( dest.y - post.y ) );

  _translation = translation( line( post, dest ), vector_intersection, l, _bl_dst_int );

  return true;
}
Logged
Carrion
Level 10
*****

crowbro


View Profile
« Reply #469 on: November 02, 2013, 11:32:39 PM »

Stop waving your coding dick around Sigvator.
Logged

Geti
Level 10
*****



View Profile WWW
« Reply #470 on: November 03, 2013, 04:20:03 AM »

My favourite but was the massive block of incredibly similar conditionals in the middle. I hope no typos were ever made in there.

Can't say I've seen bool -> bl as a type before though, I can see how it would make code more terse but I'm not sure I find it "pretty". By similar logic your vectors should definitely be vecs and translations trans Smiley

What are the semantics of math<f32>::equals( f32 val ) ? implicit zero second argument or what?

2/10 would not bang this code.
Logged

Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #471 on: November 03, 2013, 09:20:25 AM »

Quote
//The magical VoodoSlayer Class ... Go check out bennybox tutorials for more info on Merlin's Life

That was the projection matrix class

Logged
Code_Assassin
Level 5
*****


freedom


View Profile
« Reply #472 on: November 04, 2013, 01:55:03 PM »

Code:
audio.loop = true;
// rain rain go away come again another day? nope.
audio.clip = RainSound;
audio.Play();
Logged
wbahnassi
Level 0
**


3D Programmer


View Profile WWW
« Reply #473 on: November 04, 2013, 04:05:04 PM »

This is for all you coding idealists out there  Evil
This is actual running code from my game Hyper Void (implements a virus enemy).
Just look how many beautiful goto's are there Well, hello there!
Oh, and please tell me you dig the variable names Durr...?

Code:
#include "LogicalsLib.h"
#include "Macros.h"

class Virus : public LogicalInterface
{
protected:
virtual V3* GetPrincipalPosition() { return &(m_Vec3_8); }
ILogicalRef *m_LogRef6; // SpawnerLogicalReference
V3 m_Vec3_8; // PODPos
float m_Number_15; // InfectionID
float m_Number_17; // Lifetime
float m_TimePeriodRemaining18; //
float m_Wait20; //
float m_Wait42; //
float m_Wait43; //
float m_Wait46; //
SWARM m_aSwarms[1]; //
float m_Number_50; // InfectionPeriod
float m_Wait51; //
float m_TimePeriodRemaining53; //
float m_Number_56; // MoveVelocity
float m_TimePeriodRemaining61; //
VALUEFADER<float,false,false,false,false> m_Fader70; //
void FaderUpdate70(bool bInitial=false)
{
m_Fader70.Update(bInitial ? 0.0f : TimeDiff());
lbl_ScreenTint_69:
ScreenTint(V3(1.000000,0.000000,0.000000),m_Fader70.Value,0,15);
goto lbl_EndBranch_71;
lbl_EndBranch_71:
return;
}
VALUEFADER<float,false,false,false,false> m_Fader73; //
void FaderUpdate73(bool bInitial=false)
{
m_Fader73.Update(bInitial ? 0.0f : TimeDiff());
lbl_ScreenTint_72:
ScreenTint(V3(0.000000,1.000000,0.000000),m_Fader73.Value,0,15);
goto lbl_EndBranch_74;
lbl_EndBranch_74:
return;
}
VALUEFADER<float,true,false,false,false> m_Fader76; //
void FaderUpdate76(bool bInitial=false)
{
m_Fader76.Update(bInitial ? 0.0f : TimeDiff());
lbl_ScreenTint_75:
ScreenTint(V3(0.000000,0.000000,0.000000),m_Fader76.Value,0,14);
goto lbl_EndBranch_77;
lbl_EndBranch_77:
return;
}

public:
virtual void Construct(LogicalInterface *pSpawner) override
{
pSpawner;
Init(1,0,0);
m_LogRef6 = CreateLogicalRef();
m_LogRef6->Init(pSpawner);
m_Vec3_8 = V3(0.000000,0.000000,0.000000);
{
const int aGoalRefs[] = { 68 };
InitSim(0,aGoalRefs,1,float(0.25),243);
}
m_Number_15 = float(0.000000);
m_Number_17 = float(10.000000);
m_TimePeriodRemaining18 = m_Number_17;
m_Wait20 = 0.0f;
m_Wait42 = 0.0f;
m_Wait43 = 0.0f;
m_Wait46 = 0.0f;
m_Number_50 = float(10.000000);
m_Wait51 = 0.0f;
m_TimePeriodRemaining53 = m_Number_50;
m_Number_56 = float(0.000000);
m_TimePeriodRemaining61 = m_Number_50;
}

~Virus()
{
delete m_LogRef6;
}

virtual const char* GetName() const { return "Virus"; }

virtual float* GetExportedFloatValue(unsigned int uValueNameHash) override
{
switch (uValueNameHash)
{
case 1413454353: return &m_Number_15; // InfectionID (float)
case 2457142870: return &m_Number_17; // Lifetime (float)
case 772930044: return &m_Number_50; // InfectionPeriod (float)
}
return 0;
}

Status Think()
{
int iResultCheckedThisTick_9 = -1; // For events anticipation
if (m_TimePeriodRemaining18 > 0.0f)
m_TimePeriodRemaining18 -= TimeDiff();
int iResultCheckedThisTick_52 = -1; // For events anticipation
if (m_TimePeriodRemaining53 > 0.0f)
m_TimePeriodRemaining53 -= TimeDiff();
if (m_TimePeriodRemaining61 > 0.0f)
m_TimePeriodRemaining61 -= TimeDiff();
int iResultCheckedThisTick_62 = -1; // For events anticipation
if (m_Fader70.bActive)
FaderUpdate70();
if (m_Fader73.bActive)
FaderUpdate73();
if (m_Fader76.bActive)
FaderUpdate76();
RETURN_FROM_YIELD_ON(m_pYieldLocation);

lbl_OnSpawned_11:
goto lbl_SubBranch_5;
lbl_SubBranch_5:
BOOKMARK_ON(m_pYieldLocation);
if (m_pYieldLocation)
goto lbl_ImportValue_7;
else goto lbl_Play_16;
lbl_ImportValue_7:
{
LogicalInterface *pLogical = m_LogRef6->Access();
if (pLogical)
{
{
V3 *pVal = pLogical->GetExportedVec3Value(4288994382);
if (pVal)
m_Vec3_8 = *pVal;
}
}
}
goto lbl_SimulationPosition_14;
lbl_AnticipateEvents_9:
m_TimePeriodRemaining18 = m_Number_17;
lbl_AnticipateEvents_9_EventEntry:
for (;;)
{
if (iResultCheckedThisTick_9 != -1) goto ResultsCheck_9;
bool aEvalCond[] = { true,true };
bool aResult[] = { false,false };
if (aEvalCond[0])
aResult[0] = aResult[0] || ((((((((1)==0.0f) ? (m_Vec3_8):(PhaseToPos(m_Vec3_8)))-(PlayerPos(false))).len())) <= (4)));
if (aEvalCond[1])
aResult[1] = aResult[1] || ((m_TimePeriodRemaining18 <= 0.0f));
ResultsCheck_9:
if ((iResultCheckedThisTick_9<0) && aResult[0])
{ iResultCheckedThisTick_9=0; goto lbl_Stop_32; }
if ((iResultCheckedThisTick_9<1) && aResult[1])
{ iResultCheckedThisTick_9=1; goto lbl_Shatter_19; }
{
lbl_SubBranch_4:
BOOKMARK_ON(m_pYieldLocation);
if (m_pYieldLocation)
goto lbl_ImportValue_7;
else goto lbl_MeanwhileEnd_3;
lbl_MeanwhileEnd_3:
goto lbl_AnticipateEvents_9_MeanwhileEnd;
lbl_AnticipateEvents_9_MeanwhileEnd: ;
}
YIELD_ON(m_pYieldLocation);
}
lbl_End_10:
return Dead;
lbl_EndBranch_1:
RETURN_TO_BOOKMARK_ON(m_pYieldLocation);
lbl_SimulationPosition_14:
SimPosition(0,m_Vec3_8,true);
goto lbl_EndBranch_1;
lbl_Play_16:
PlayGoal(GOALREF(0,0),float(1),int(0));
goto lbl_AnticipateEvents_9;
lbl_Shatter_19:
Shatter(0,float(1),float(1));
goto lbl_Wait_20;
lbl_Wait_20:
m_Wait20 = (1) - TimeDiff();
while (m_Wait20 > 0.0f)
{
YIELD_ON(m_pYieldLocation);
m_Wait20 -= TimeDiff();
}
goto lbl_End_10;
lbl_EvaluateEvents_22:
lbl_EvaluateEvents_22_EventEntry:
{
bool aEvalCond[] = { true,true,true,true,true,true,true,true };
bool aResult[] = { false,false,false,false,false,false,false,false };
if (aEvalCond[0])
aResult[0] = aResult[0] || (((m_Number_15) == (0)));
if (aEvalCond[1])
aResult[1] = aResult[1] || (((m_Number_15) == (4)));
if (aEvalCond[2])
aResult[2] = aResult[2] || (((m_Number_15) == (1)));
if (aEvalCond[3])
aResult[3] = aResult[3] || (((m_Number_15) == (2)));
if (aEvalCond[4])
aResult[4] = aResult[4] || (((m_Number_15) == (3)));
if (aEvalCond[5])
aResult[5] = aResult[5] || (((m_Number_15) == (5)));
if (aEvalCond[6])
aResult[6] = aResult[6] || (((m_Number_15) == (6)));
if (aEvalCond[7])
aResult[7] = aResult[7] || (((m_Number_15) == (7)));
if (aResult[0])
{ goto lbl_EventLog_34; }
if (aResult[1])
{ goto lbl_EventLog_38; }
if (aResult[2])
{ goto lbl_EventLog_35; }
if (aResult[3])
{ goto lbl_EventLog_36; }
if (aResult[4])
{ goto lbl_EventLog_37; }
if (aResult[5])
{ goto lbl_EventLog_39; }
if (aResult[6])
{ goto lbl_EventLog_40; }
if (aResult[7])
{ goto lbl_EventLog_41; }
{ goto lbl_End_10; }
}
lbl_Route_31:
goto lbl_ValueFader_73;
lbl_Stop_32:
StopGoal(GOALREF(0,0));
goto lbl_EventLog_33;
lbl_EventLog_33:
LogEvent("INFECTED!#$%!!",0);
goto lbl_ValueFader_70;
lbl_EventLog_34:
LogEvent("VRAM CO#RUPT!0N",0);
goto lbl_ValueFader_76;
lbl_EventLog_35:
LogEvent("KEYBOARD $H0RT CIRCU!T",0);
goto lbl_SetValue_57;
lbl_EventLog_36:
LogEvent("$!DE T#RUSTER MALFUNCT!0N",0);
goto lbl_Route_31;
lbl_EventLog_37:
LogEvent("C#ARGE LEAK%",0);
goto lbl_AnticipateEvents_52;
lbl_EventLog_38:
LogEvent("WEAP0N I/O E&CEPT!0N",0);
goto lbl_Route_31;
lbl_EventLog_39:
LogEvent("THRU$TER C!RCUIT !NVERTE|)",0);
goto lbl_Route_31;
lbl_EventLog_40:
LogEvent("BAD TAR5ET ALL0C@T0R",0);
goto lbl_Route_31;
lbl_EventLog_41:
LogEvent("WEAP0N GRID M!SALI5N",0);
goto lbl_Route_31;
lbl_Wait_42:
m_Wait42 = (0.5) - TimeDiff();
while (m_Wait42 > 0.0f)
{
YIELD_ON(m_pYieldLocation);
m_Wait42 -= TimeDiff();
}
goto lbl_EvaluateEvents_22;
lbl_Wait_43:
m_Wait43 = (0.5) - TimeDiff();
while (m_Wait43 > 0.0f)
{
YIELD_ON(m_pYieldLocation);
m_Wait43 -= TimeDiff();
}
goto lbl_EventLog_45;
lbl_End_44:
return Dead;
lbl_EventLog_45:
LogEvent("<Virus Deleted>",2);
goto lbl_End_44;
lbl_Wait_46:
m_Wait46 = (m_Number_50) - TimeDiff();
while (m_Wait46 > 0.0f)
{
YIELD_ON(m_pYieldLocation);
m_Wait46 -= TimeDiff();
}
goto lbl_EndSwarm_49;
lbl_SpawnLogicals_48:
{
int SpawnCount = (int)(500);
unsigned int uRandomSeed = 0;
for (int SpawnChainID=1;SpawnChainID<=SpawnCount;SpawnChainID++)
{
float fTimeOffset = (0)*SpawnChainID;
LogicalInterface *pLogical = SpawnLogical(1907384993,fTimeOffset,uRandomSeed,SpawnChainID,&m_aSwarms[0],false);
}
}
goto lbl_Wait_46;
lbl_EndSwarm_49:
EndSwarm(&m_aSwarms[0]);
goto lbl_Route_31;
lbl_Wait_51:
m_Wait51 = (0.5) - TimeDiff();
while (m_Wait51 > 0.0f)
{
YIELD_ON(m_pYieldLocation);
m_Wait51 -= TimeDiff();
}
goto lbl_SpawnLogicals_48;
lbl_AnticipateEvents_52:
m_TimePeriodRemaining53 = m_Number_50;
lbl_AnticipateEvents_52_EventEntry:
for (;;)
{
if (iResultCheckedThisTick_52 != -1) goto ResultsCheck_52;
bool aEvalCond[] = { true };
bool aResult[] = { false };
if (aEvalCond[0])
aResult[0] = aResult[0] || ((m_TimePeriodRemaining53 <= 0.0f));
ResultsCheck_52:
if ((iResultCheckedThisTick_52<0) && aResult[0])
{ iResultCheckedThisTick_52=0; goto lbl_Route_31; }
{
lbl_PlayerBatteryCharge_55:
SetPlayerBatteryCharge(0);
goto lbl_MeanwhileEnd_54;
lbl_MeanwhileEnd_54:
goto lbl_AnticipateEvents_52_MeanwhileEnd;
lbl_AnticipateEvents_52_MeanwhileEnd: ;
}
YIELD_ON(m_pYieldLocation);
}
lbl_SetValue_57:
m_Number_56 = (((Random(0,1,0)) > 0.5f) ? -1 : 1);
goto lbl_AnticipateEvents_62;
lbl_AnticipateEvents_62:
m_TimePeriodRemaining61 = m_Number_50;
lbl_AnticipateEvents_62_EventEntry:
for (;;)
{
if (iResultCheckedThisTick_62 != -1) goto ResultsCheck_62;
bool aEvalCond[] = { true };
bool aResult[] = { false };
if (aEvalCond[0])
aResult[0] = aResult[0] || ((m_TimePeriodRemaining61 <= 0.0f));
ResultsCheck_62:
if ((iResultCheckedThisTick_62<0) && aResult[0])
{ iResultCheckedThisTick_62=0; goto lbl_Route_31; }
{
lbl_PlayerInputOverride_63:
OverridePlayerInput(0,false,((m_Number_56)*(Random(1,2,0))),true);
goto lbl_MeanwhileEnd_60;
lbl_MeanwhileEnd_60:
goto lbl_AnticipateEvents_62_MeanwhileEnd;
lbl_AnticipateEvents_62_MeanwhileEnd: ;
}
YIELD_ON(m_pYieldLocation);
}
lbl_ValueFader_70:
m_Fader70.Initial = 1;
m_Fader70.Value = m_Fader70.Initial;
m_Fader70.Goal = 0;
m_Fader70.Activate(0.5,0,0);
FaderUpdate70(true);
goto lbl_Wait_42;
lbl_ValueFader_73:
m_Fader73.Initial = 1;
m_Fader73.Value = m_Fader73.Initial;
m_Fader73.Goal = 0;
m_Fader73.Activate(0.5,0,0);
FaderUpdate73(true);
goto lbl_Wait_43;
lbl_ValueFader_76:
m_Fader76.Initial = 0;
m_Fader76.Value = m_Fader76.Initial;
m_Fader76.Goal = 1;
m_Fader76.Activate(0.5,0.5,m_Number_50);
FaderUpdate76(true);
goto lbl_Wait_51;
FUNCTION_END: return StillAlive;
}
};
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #474 on: November 04, 2013, 05:18:48 PM »

I don't get it. Is this generated code? A lot of those gotos seem superfluous and just go to the very next line. I'd assume some of the macros you're calling might use them, but you don't seem to be passing them anything that would identify the label to jump to.
Logged

wbahnassi
Level 0
**


3D Programmer


View Profile WWW
« Reply #475 on: November 04, 2013, 09:25:48 PM »

Bingo, it is generated code. The labels/gotos correspond to the graph nodes that generated them. Indeed some jumps are unnecessary as the flow is quite serial. But sometimes the flow forks and joins and loops, hence it's not generally possible to order the lines and remove the goto's/labels completely. But yes, this shows that I haven't spent much time optimizing the code generator's output Coffee

I don't know if the VC compiler does any effort to optimize this. I'm now interested in looking at the disassembly  Smiley but I know well that I'm running hundreds of objects with such code at only 1 or 2 ms.
Logged

Geti
Level 10
*****



View Profile WWW
« Reply #476 on: November 04, 2013, 09:30:34 PM »

"Hundreds" in a few ms isn't really anything to write home about unless they're networked, particularly heavy weight objects Wink

Still, code generation like that (intermediate high level language instead of low level or vm/machine code) is quite interesting. Looks ugly as sin, of course.
Logged

MegaMasterX
Level 0
*



View Profile
« Reply #477 on: November 05, 2013, 04:44:56 AM »

Code:
Private PlayerHasWon As Boolean = False 'YOU AINT WON NUTTIN YET FOOL

Code:
..... Case Else
   ActionInformation = "Uhm...Broken..." 'You should never see this.

Apparently I have a knack of putting in goofy comments when I get seriously frustrated.
Logged

"It is arrogant for one to reject change because it is undesirable. Rejection of change is the rejection of possibilities."
— Harald Hoerwick
wbahnassi
Level 0
**


3D Programmer


View Profile WWW
« Reply #478 on: November 05, 2013, 08:14:15 AM »

Bingo, it is generated code. The labels/gotos correspond to the graph nodes that generated them. Indeed some jumps are unnecessary as the flow is quite serial. But sometimes the flow forks and joins and loops, hence it's not generally possible to order the lines and remove the goto's/labels completely. But yes, this shows that I haven't spent much time optimizing the code generator's output Coffee

I don't know if the VC compiler does any effort to optimize this. I'm now interested in looking at the disassembly  Smiley but I know well that I'm running hundreds of objects with such code at only 1 or 2 ms.

Ok, just looked at the disassembly of the optimized binary. It's all jmps Evil  I think the compiler just didn't want to bother tracing at all. So there you go, it's probably not funny code, but scary one (it's Halloween right Big Laff).
Logged

Will Vale
Level 4
****



View Profile WWW
« Reply #479 on: November 06, 2013, 03:58:04 PM »

I'd assume some of the macros you're calling might use them, but you don't seem to be passing them anything that would identify the label to jump to.

Extreme pedant mode: CPP macro syntax looks like function call syntax, but you don't really call a macro, it's just a text substitution.

W
Logged
Pages: 1 ... 22 23 [24] 25 26 27
Print
Jump to:  

Theme orange-lt created by panic