2025-07-18 02:51 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001634AIAIpublic2009-09-11 12:47
Reporterhughperkins 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
Summary0001634: AI Line-drawing seems totally borked in git master head
DescriptionAI Line-drawing seems totally borked in git master head

In Spring 0.80.2 and Spring 0.80.4, the following command, through the Java AI Interface 0.1, draws a line:

[code]
         csai.handleEngineCommand(
               new AddLineDrawAICommand(startpos.toAIFloat3(), endpos.toAIFloat3()));
[/code]

Not so in git head, does nothing ;-)

Additional InformationIt is much easier, and more fun, to write AIs when one can see what the AI is 'thinking' so this is quite important to me, although I can understand that relative to most people's requirements it is fairly low down on the priority list...
TagsNo tags attached.
Attached Files

-Relationships
parent of 0001722resolvedabma Spring engine Cannot erase AI startpoint marker anymore. 
related to 0001624resolvedzerver Spring engine Drawing 8000 lines, then viewing them causes Spring to segfault 
+Relationships

-Notes

~0004079

hughperkins (reporter)

Ok, so I spent a couple of hours looking into this issue this morning.

It may not be linked to a change between Spring 0.80.4 and git head.

Line drawing via Java Interface v0.1 seems to fail under either of the following circumstances:
- an AI is the second AI to be loaded (see attached file for a test example of this)
- Cheats are activated!

Strangely, disactivating cheats re-enables line-drawing once more! and instantly, so an easy work-around that I am using myself now is:

[code]
public void AddLine(Float3 startpos, Float3 endpos ) {
    // workaround for too many lines causing sigfault
         if( linesDrawn >= maxlines ) {
            csai.sendTextMessage( "DrawingUtils.AddLine: too many lines drawn. drawing more would crash Spring..." );
            return;
            // throw new RuntimeException("DrawingUtils.AddLine: too many lines drawn. drawing more would crash Spring..." );
         }

  // workaround for activating cheats disables linedrawing
         pushCheating();
         setCheating( false );
         csai.handleEngineCommand(
               new AddLineDrawAICommand(startpos.toAIFloat3(), endpos.toAIFloat3()));
         linesDrawn++;
         popCheating();
   }
   
   Stack<Boolean> cheatingStack = new Stack<Boolean>();
   void pushCheating() {
      cheatingStack.push( isCheating() );
   }
   
   boolean isCheating() {
      return playerObjects.getAicallback().getCheats().isEnabled();
   }
   
   void setCheating( boolean cheating ) {
      if( isCheating() != cheating ) {
         playerObjects.getAicallback().getCheats().setEnabled( cheating );
      }
   }
   
   void popCheating() {
      boolean oldCheating = cheatingStack.pop();
      setCheating( oldCheating );
   }
[/code]

This also contains the workaround for too many lines causing Spring to segfault.

~0004102

hoijui (reporter)

in rts/ExternalAI/AICallback.cpp:1352, we have the following line:
net->Send(CBaseNetProtocol::Get().SendMapDrawLine(team, (short)line->posfrom.x, (short)line->posfrom.z, (short)line->posto.x, (short)line->posto.z, false));

The first param to this function is playerId, not team, so this is part of the problem. The thing is, we would need this method changed to be usable by AIs. This is sync related, and therefore sensible.
The best way to solve this is making AIs even more similar to humans, and make htem share a single ID space with players (Auswaschbar suggested that once). this is a big change though, will take a lot of editing in a lot of files, create a few till many bugs to be fixed in turn, and be little rewarding. I did part of it already with the airefactor branch (now integrated into master).
bla bla ...

short:
problem detected, fix non-simple, needs discussing/worktime.
+Notes

-Issue History
Date Modified Username Field Change
2009-09-08 09:01 hughperkins New Issue
2009-09-09 07:52 hughperkins Note Added: 0004079
2009-09-09 07:52 hughperkins File Added: NullOOJavaAI.java
2009-09-11 12:47 hoijui Note Added: 0004102
2009-09-11 12:48 hoijui Relationship added related to 0001625
2009-09-11 13:29 hoijui Relationship deleted related to 0001625
2009-09-11 13:40 hoijui Relationship added related to 0001624
2009-11-08 18:47 hoijui Relationship added parent of 0001722
+Issue History