Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3   Go Down

Author Topic: PlMisAir for 4.15m  (Read 1044 times)

0 Members and 2 Guests are viewing this topic.

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #12 on: January 27, 2025, 12:45:44 AM »

 String var59 = var49.next((String)null);
  if (var59 != null && var59.startsWith("F")) {
  var59 = var59.substring(1);
 }
Why when I add the same check and I want to add a new line after changing the squirrels without choosing my line does not work?

 String var59c = var49.next((String)null);
                                                if (var59c != null && var59c.startsWith("C")) {
                                                    var59c = var59c.substring(1);
                                                }


if (var59 != null) {
                                                    var43.formation = Integer.parseInt(var59);
                                                }
                                                if (var59c != null) {
                                                    var43.gattackcounter = Integer.parseInt(var59c);
                                                }



GATTACKDIRECTION 83562.58 58774.38 500.00 300.00 &0 C4
So does not work.
He cannot count C4.



GATTACKDIRECTION 83562.58 58774.38 500.00 300.00 &0 F3 C4
However, so if formation  everything works for the point.


Logged

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #13 on: January 27, 2025, 01:05:33 AM »



this.wGattackcounterLabel = new GWindowLabel(var1, 1.0F, 5.0F, 19.0F, 1.3F, i18n("GAttackCount"), (String)null);
        var1.addLabel(this.wGattackcounterLabel);
        this.wGattackcounterType =  new GWindowComboControl(var1, 19.0F, 5.0F, 5.0F){
             public void afterCreated() {
                super.afterCreated();
                boolean[] var1 = new boolean[PAir.count.length];

                for(int var2 = 0; var2 < PAir.count.length; ++var2) {
                    this.add(Plugin.i18n(PAir.count[var2]));
                    var1[var2] = true;
                }

                this.posEnable = var1;
   
               
            }

            public boolean notify(int var1, int var2) {
                if (var1 == 2) {
                    PAir var3 = (PAir)Plugin.builder.selectedPoint();
                    int var4 = PlMisAir.this.wGattackcounterType.getSelected();
                    if (var4 < 0) {
                        var4 = 0;
                    }

                    if (var4 > PAir.count.length - 1) {
                        var4 = PAir.count.length - 1;
                    }
                   
                   
                    var3.gattackcounter = var4 == 0 ? var4 : var4 + 0;
                   
                    PlMisAir.this.fillDialogWay2();
                    PlMission.setChanged();
                }

                return true;
            }
         };
        var1.addControl(this.wGattackcounterType);


This adds the interface.

Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 24030
  • Taking a timeout
    • STFU
Re: PlMisAir for 4.15m
« Reply #14 on: January 27, 2025, 05:11:09 AM »

That code snippet is a bit too limited to judge what's going wrong.
Could you post the whole method's code please, prior and after your modification?

]cheers[
Mike
Logged
Don't split your mentality without thinking twice.

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #15 on: January 27, 2025, 07:07:19 AM »

That code snippet is a bit too limited to judge what's going wrong.
Could you post the whole method's code please, prior and after your modification?

]cheers[
Mike

Too many lines. The whole method is not included.
I'm trying to add a meter for the number of attacks.
So that in the editor it is possible to set how many times the aircraft will attack the target.
There is a sample Formation I try to add my parameter after it.
It works only if the type Fornation is indicated at the point. Without it, I get a mistake.

1)GWindowComboControl wFormations;
This creates an element for the window.

public void load(SectFile var1) {


Object var58 = null;
String var59 = var49.next((String)null);
if (var59 != null && var59.startsWith("F")) {
var59 = var59.substring(1);
                                                }
String count = var49.next((String)null);
                                                if (count != null && count.startsWith("C")) {
                                                    count = count.substring(1);
                                                }

I added the same code for my line. Only to make if the line begins with S.


 if (var59 != null) {
                                                    var43.formation = Integer.parseInt(var59);
                                                }
                                                if (count != null ) {
                                                    var43.gattackcounter = Integer.parseInt(count);
                                                }
This transforms into a whole value from the line.
I made exactly my same line.
}

   public boolean save(SectFile var1) {

   for(int var15 = 0; var15 < var9; ++var15) {
                        PAir var16 = (PAir)var8.point(var15);
                        Point3d var17 = var16.pos.getAbsPoint();
                        switch (var16.type()) {
                        case 4:
                                String var31 = "";
                                if (var16.waypointType > 0) {
                                    var31 = "_" + var16.waypointType;
                                }
                                var1.lineAdd(var20, "GATTACKDIRECTION" + var31, this.fmt(var17.x) + " " + this.fmt(var17.y) + " " + this.fmt(var16.height) + " " + this.fmt(var16.speed) + this.saveTarget(var16) + this.saveRadioSilence(var16) + this.saveFormation(var16) +  this.saveGattackcounter(var16));
                               
                         
                                if (var16.waypointType > 800) {
                                    var1.lineAdd(var20, "TRIGGERS", var16.cycles + " " + var16.delayTimer + " " + (int)var16.orient + " " + var16.baseSize + " " + var16.targetTrigger + " " + var16.altDifference);
                                }
                               
                                break;
                           


Saving points of the route to the file.
I created my type with index 4.
0 flight.
1 take -off.
2 posterity.
3 attack.
4 My attack.
Therefore, there are 4 case.
}
Save in file.
There is a record of the type of point, coordinates, speed, height, radio silence, the goal if any, and Formation I added my option in exactly the same essentially.

 this.saveFormation(var16) +  this.saveGattackcounter(var16)

private String saveFormation(PAir var1) {
        return var1.formation == 0 ? "" : " F" + var1.formation;
    }
   
    private String saveGattackcounter(PAir var1) {
        return var1.gattackcounter == 0 ? "" : " C" + var1.gattackcounter;
    }
Here is my exactly the same as the original team for that line.


 public void initEditWay2() {
this.wGattackcounterLabel = new GWindowLabel(var1, 1.0F, 5.0F, 19.0F, 1.3F, i18n("GAttackCount"), (String)null);
        var1.addLabel(this.wGattackcounterLabel);
        this.wGattackcounterType =  new GWindowComboControl(var1, 19.0F, 5.0F, 5.0F){
             public void afterCreated() {
                super.afterCreated();
                boolean[] var1 = new boolean[PAir.count.length];

                for(int var2 = 0; var2 < PAir.count.length; ++var2) {
                    this.add(Plugin.i18n(PAir.count[var2]));
                    var1[var2] = true;
                }

                this.posEnable = var1;
   
               
            }

            public boolean notify(int var1, int var2) {
                if (var1 == 2) {
                    PAir var3 = (PAir)Plugin.builder.selectedPoint();
                    int var4 = PlMisAir.this.wGattackcounterType.getSelected();
                    if (var4 < 0) {
                        var4 = 0;
                    }

                    if (var4 > PAir.count.length - 1) {
                        var4 = PAir.count.length - 1;
                    }
                   
                   
                    var3.gattackcounter = var4 == 0 ? var4  : var4 + 1;
                   
                    PlMisAir.this.fillDialogWay2();
                    PlMission.setChanged();
                }

                return true;
            }
         };
        var1.addControl(this.wGattackcounterType);

}
This creates options in the editor on 2 window settings window.

private void fillDialogWay2() {
        PAir var1 = (PAir)Plugin.builder.selectedPoint();
        int var2 = var1.waypointType;

int var7 = var1.gattackcounter;
        int var10000;
        if (var7 <= 0) {
            var10000 = 0;
        } else {
            --var7;
            var10000 = var7;
        }

        var7 = var10000;
        this.wGattackcounterType.setSelected(var7, true, false);

}
This is how I understand the filling out data. In the editor.





Logged

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #16 on: January 27, 2025, 07:48:13 AM »

That code snippet is a bit too limited to judge what's going wrong.
Could you post the whole method's code please, prior and after your modification?

]cheers[
Mike

Too many lines. The whole method is not included.
I'm trying to add a meter for the number of attacks.
So that in the editor it is possible to set how many times the aircraft will attack the target.
There is a sample Formation I try to add my parameter after it.
It works only if the type Fornation is indicated at the point. Without it, I get a mistake.

1)GWindowComboControl wFormations;
This creates an element for the window.

public void load(SectFile var1) {


Object var58 = null;
String var59 = var49.next((String)null);
if (var59 != null && var59.startsWith("F")) {
var59 = var59.substring(1);
                                                }
String count = var49.next((String)null);
                                                if (count != null && count.startsWith("C")) {
                                                    count = count.substring(1);
                                                }

I added the same code for my line. Only to make if the line begins with S.


 if (var59 != null) {
                                                    var43.formation = Integer.parseInt(var59);
                                                }
                                                if (count != null ) {
                                                    var43.gattackcounter = Integer.parseInt(count);
                                                }
This transforms into a whole value from the line.
I made exactly my same line.
}

   public boolean save(SectFile var1) {

   for(int var15 = 0; var15 < var9; ++var15) {
                        PAir var16 = (PAir)var8.point(var15);
                        Point3d var17 = var16.pos.getAbsPoint();
                        switch (var16.type()) {
                        case 4:
                                String var31 = "";
                                if (var16.waypointType > 0) {
                                    var31 = "_" + var16.waypointType;
                                }
                                var1.lineAdd(var20, "GATTACKDIRECTION" + var31, this.fmt(var17.x) + " " + this.fmt(var17.y) + " " + this.fmt(var16.height) + " " + this.fmt(var16.speed) + this.saveTarget(var16) + this.saveRadioSilence(var16) + this.saveFormation(var16) +  this.saveGattackcounter(var16));
                               
                         
                                if (var16.waypointType > 800) {
                                    var1.lineAdd(var20, "TRIGGERS", var16.cycles + " " + var16.delayTimer + " " + (int)var16.orient + " " + var16.baseSize + " " + var16.targetTrigger + " " + var16.altDifference);
                                }
                               
                                break;
                           


Saving points of the route to the file.
I created my type with index 4.
0 flight.
1 take -off.
2 posterity.
3 attack.
4 My attack.
Therefore, there are 4 case.
}
Save in file.
There is a record of the type of point, coordinates, speed, height, radio silence, the goal if any, and Formation I added my option in exactly the same essentially.

 this.saveFormation(var16) +  this.saveGattackcounter(var16)

private String saveFormation(PAir var1) {
        return var1.formation == 0 ? "" : " F" + var1.formation;
    }
   
    private String saveGattackcounter(PAir var1) {
        return var1.gattackcounter == 0 ? "" : " C" + var1.gattackcounter;
    }
Here is my exactly the same as the original team for that line.


 public void initEditWay2() {
this.wGattackcounterLabel = new GWindowLabel(var1, 1.0F, 5.0F, 19.0F, 1.3F, i18n("GAttackCount"), (String)null);
        var1.addLabel(this.wGattackcounterLabel);
        this.wGattackcounterType =  new GWindowComboControl(var1, 19.0F, 5.0F, 5.0F){
             public void afterCreated() {
                super.afterCreated();
                boolean[] var1 = new boolean[PAir.count.length];

                for(int var2 = 0; var2 < PAir.count.length; ++var2) {
                    this.add(Plugin.i18n(PAir.count[var2]));
                    var1[var2] = true;
                }

                this.posEnable = var1;
   
               
            }

            public boolean notify(int var1, int var2) {
                if (var1 == 2) {
                    PAir var3 = (PAir)Plugin.builder.selectedPoint();
                    int var4 = PlMisAir.this.wGattackcounterType.getSelected();
                    if (var4 < 0) {
                        var4 = 0;
                    }

                    if (var4 > PAir.count.length - 1) {
                        var4 = PAir.count.length - 1;
                    }
                   
                   
                    var3.gattackcounter = var4 == 0 ? var4  : var4 + 1;
                   
                    PlMisAir.this.fillDialogWay2();
                    PlMission.setChanged();
                }

                return true;
            }
         };
        var1.addControl(this.wGattackcounterType);

}
This creates options in the editor on 2 window settings window.

private void fillDialogWay2() {
        PAir var1 = (PAir)Plugin.builder.selectedPoint();
        int var2 = var1.waypointType;

int var7 = var1.gattackcounter;
        int var10000;
        if (var7 <= 0) {
            var10000 = 0;
        } else {
            --var7;
            var10000 = var7;
        }

        var7 = var10000;
        this.wGattackcounterType.setSelected(var7, true, false);

}
This is how I understand the filling out data. In the editor.







Logged

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #17 on: January 27, 2025, 07:52:52 AM »

[r0101_Way]
  NORMFLY 78320.19 60883.53 500.00 300.00 &0
  NORMFLY 78883.13 61493.37 500.00 300.00 &0
  NORMFLY 79406.97 62025.04 500.00 300.00 &0
  GATTACKDIRECTION 80446.83 62380.78 500.00 300.00 &0 F2 C2
This is how it looks in the editor.
C2 is 0 sample in the editor.
It works if there is F.
If the system is not indicated, but it costs by default, then when adding my line, an error emerges.

GATTACKDIRECTION 80446.83 62380.78 500.00 300.00 &0  C2
This no job.

Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 24030
  • Taking a timeout
    • STFU
Re: PlMisAir for 4.15m
« Reply #18 on: January 27, 2025, 08:01:19 AM »

Quite confusing posts.
Your initial full method post revealed the issue.

Your code:
Code: [Select]
String var59 = var49.next((String)null);
if (var59 != null && var59.startsWith("F")) {
  var59 = var59.substring(1);
}
Object var58c = null;

String count = var49.next((String)null);
if (count != null && count.startsWith("C")) {
  count = count.substring(1);}

Problem no.1: "var58c" apparently never gets referenced anywhere. If that's true you can simply remove that line.
Problem no.2 (this is your issue): "String count = var49.next((String)null);".
You've been reading the token right after "&0" in this line already: "String var59 = var49.next((String)null);". Therefore, "String count = var49.next((String)null);" refers to the 2nd token after "&0". That second token only exists if your planes have a formation set ("F<n>").
You need to cover both cases, with and without "F" token, which means only read the next token if there is an "F" token, otherwise re-use the same token which was not "F":

Code: [Select]
String var59 = var49.next((String)null);
String count = var59;
if (var59 != null && var59.startsWith("F")) {
  var59 = var59.substring(1);
  count = var49.next((String)null);
}
if (count != null && count.startsWith("C")) {
  count = count.substring(1);
}

]cheers[
Mike
Logged
Don't split your mentality without thinking twice.

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #19 on: January 27, 2025, 08:08:23 AM »






Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 24030
  • Taking a timeout
    • STFU
Re: PlMisAir for 4.15m
« Reply #20 on: January 27, 2025, 08:19:35 AM »

Code please.
I can't guess how and where you implemented the code.
Logged
Don't split your mentality without thinking twice.

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #21 on: January 27, 2025, 08:40:21 AM »

Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 24030
  • Taking a timeout
    • STFU
Re: PlMisAir for 4.15m
« Reply #22 on: January 27, 2025, 09:10:35 AM »

Alright.

Code: [Select]
String var59 = var49.next((String)null);
String count = var59;
if (var59 != null && var59.startsWith("F")) {
  var59 = var59.substring(1);
  count = var49.next((String)null);
}
if (count != null && count.startsWith("C")) {
  count = count.substring(1);
}
...becomes...
Code: [Select]
boolean hasFormation = false;
boolean hasAttackCount = false;
String var59 = var49.next((String)null);
String count = var59;
if (var59 != null && var59.startsWith("F")) {
  hasFormation = true;
  var59 = var59.substring(1);
  count = var49.next((String)null);
}
if (count != null && count.startsWith("C")) {
  hasAttackCount = true;
  count = count.substring(1);
}

...and...
Code: [Select]
if (var59 != null) {
  var43.formation = Integer.parseInt(var59);
}
if (count != null) {
  var43.gattackcounter = Integer.parseInt(count);
}
...becomes...
Code: [Select]
if (hasFormation) {
  var43.formation = Integer.parseInt(var59);
}
if (hasAttackCount) {
  var43.gattackcounter = Integer.parseInt(count);
}

]cheers[
Mike
Logged
Don't split your mentality without thinking twice.

Ghostil

  • member
  • Offline Offline
  • Posts: 22
Re: PlMisAir for 4.15m
« Reply #23 on: January 27, 2025, 09:52:09 AM »

Alright.

Code: [Select]
String var59 = var49.next((String)null);
String count = var59;
if (var59 != null && var59.startsWith("F")) {
  var59 = var59.substring(1);
  count = var49.next((String)null);
}
if (count != null && count.startsWith("C")) {
  count = count.substring(1);
}
...becomes...
Code: [Select]
boolean hasFormation = false;
boolean hasAttackCount = false;
String var59 = var49.next((String)null);
String count = var59;
if (var59 != null && var59.startsWith("F")) {
  hasFormation = true;
  var59 = var59.substring(1);
  count = var49.next((String)null);
}
if (count != null && count.startsWith("C")) {
  hasAttackCount = true;
  count = count.substring(1);
}

...and...
Code: [Select]
if (var59 != null) {
  var43.formation = Integer.parseInt(var59);
}
if (count != null) {
  var43.gattackcounter = Integer.parseInt(count);
}
...becomes...
Code: [Select]
if (hasFormation) {
  var43.formation = Integer.parseInt(var59);
}
if (hasAttackCount) {
  var43.gattackcounter = Integer.parseInt(count);
}

]cheers[
Mike
Thanks a lot. Everything works now.
Logged
Pages: 1 [2] 3   Go Up
 

Page created in 0.101 seconds with 24 queries.