Attempting to make Non-Combat Movement of Paratroopers a property, need help

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Attempting to make Non-Combat Movement of Paratroopers a property, need help

Veqryn
Administrator
Ok, so I am taking my experience creating the "Selectable Zero Movement Units" property, and putting it towards something just a step up from here.  With any luck, I'll be learning more about the TripleA and creating a property people would love to use.  

As usual, I've ran into a bug.

The file I am screwing with here is the /src/games/strategy/triplea/delegate/MoveValidator.java

Based on what I learned with the previous property i made, I created the property in both the Constants.java and the Properties.java files, then made sure both those files were being imported into MoveValidator.java.
Then I added this line:
games.strategy.triplea.Properties.getParatroopersCanMoveDuringNonCombat(getData())

for example, like this:
        if(nonCombat && !games.strategy.triplea.Properties.getParatroopersCanMoveDuringNonCombat(games.strategy.triplea.ui.ActionPanel.getData()))
            return result.setErrorReturnResult("Paratroops may not move during NonCombat");

Except, Eclipse underlines the "getData()" in red, and says no such method exists.
Ok, I understand what that means.  Obviously I need to import the java file that contains the class or method called "getData()".
So I went and investigated a couple other java files and found that the "getData()" method is located in ActionPanel.java (/src/games/strategy/triplea/ui/ActionPanel.java)

so I added ActionPanel.java to the list of things being imported.  This did not fix the issue though.

so next I tried specifying the path to getData:
games.strategy.triplea.Properties.getParatroopersCanMoveDuringNonCombat(games.strategy.triplea.ui.ActionPanel.getData())

This also does not work, with eclipse telling me that getData() is protected, and is not public, and that it will work if i make it public.  However, I don't want to change it to public, as there must be a good reason it is not public already.

So my questions are:
1) how come sometimes when I see some java file looking up a property it looks like this, with just "data" instead of "getData()"?
games.strategy.triplea.Properties.getLow_Luck(data)
2) what do i need to import, or what new method do i have to make inside MoveValidator, in order to be able to retrieve the boolean property?

please help me out,
thx,
veqryn
Please contribute to the TripleA 2013 donation drive:
http://tripleadev.1671093.n2.nabble.com/2013-TripleA-Donation-Drive-tp7583455.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to make Non-Combat Movement of Paratroopers a property, need help

Veqryn
Administrator
ok, I got it to work,

I created a new method in the MoveValidator like this:

    private static boolean IsParatroopersCanMoveDuringNonCombat(GameData data)
    {
        return games.strategy.triplea.Properties.getParatroopersCanMoveDuringNonCombat(data);
    }


And then used this to call it:
IsParatroopersCanMoveDuringNonCombat(data)



However, I would still like answers to my questions above, so that I may understand what is happening better.
thx,
veq
Please contribute to the TripleA 2013 donation drive:
http://tripleadev.1671093.n2.nabble.com/2013-TripleA-Donation-Drive-tp7583455.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to make Non-Combat Movement of Paratroopers a property, need help

ComradeKev
Administrator
In reply to this post by Veqryn
It's basically a matter if inheritance.  Some objects have a getData() method attached (or attatched ), while others don't.  This could be because of laziness or more likely, it would be a bit cumbersome to get to the gameData for a particular object.

In the case of validateMove(), the game data is passed in so it can be reused by all called methods.  Depending on the JVM and it's ability at tuning the Java, this may save processing/memory.  I tend to not trust the language tuners and prefer to ensure that we're only causing the gamedata to be stored in memory once in validateMove().  That's probably my due to experiences with seeing what COBOL compilers kick out in Assembler machine language- you wouldn't believe some of the stupid stuff they do.

Anyway, the way you ultimately coded it is my prefered way.  Now, if anyone else needs to use the game property, they need only call your IsParatroopersCanMoveDuringNonCombat() method.  Coding the call inline should work (I just think you didn't have access to the ActionPanel memoryspace), and is ok for a single use of the property, but the way you've done it is cleaner and easier to maintain.
If emailing me at ComradeKev at yahoo.com , please add TripleA to the subject line
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to make Non-Combat Movement of Paratroopers a property, need help

Veqryn
Administrator
This post was updated on .
so.....
I got everything to run,
you can now transport paratroopable ground units during your noncombat turn to a friendly territory (but only during non-combat move),
but I get this error when my mouse passes over a territory that I either conquered or I had previously transported some units from

any ideas?
i'll keep reading the code to see what i find.

edit: this only happens when trying to transport more than 1 aircraft full of guys.


java.lang.NullPointerException
        at games.strategy.triplea.delegate.MoveValidator.validateBasic(MoveValidator.java:1138)
        at games.strategy.triplea.delegate.MoveValidator.validateMove(MoveValidator.java:758)
        at games.strategy.triplea.ui.MovePanel.updateUnitsThatCanMoveOnRoute(MovePanel.java:798)
        at games.strategy.triplea.ui.MovePanel.access$23(MovePanel.java:763)
        at games.strategy.triplea.ui.MovePanel$5.mouseMoved(MovePanel.java:1824)
        at games.strategy.triplea.ui.MapPanel.notifyMouseMoved(MapPanel.java:354)
        at games.strategy.triplea.ui.MapPanel.access$15(MapPanel.java:346)
        at games.strategy.triplea.ui.MapPanel$2.mouseMoved(MapPanel.java:520)
        at java.awt.AWTEventMulticaster.mouseMoved(Unknown Source)
        at java.awt.Component.processMouseMotionEvent(Unknown Source)
        at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)




and i get this error when re-clicking on the air transport to try loading it again, only after previously getting the error above:
(i also get a message telling me that the units are not unique, it appears doing this causes units to become duplicated, because my bomber never unloads himself)

java.lang.NullPointerException
        at games.strategy.triplea.delegate.MoveValidator.isLoad(MoveValidator.java:416)
        at games.strategy.triplea.ui.MovePanel.updateUnitsThatCanMoveOnRoute(MovePanel.java:777)
        at games.strategy.triplea.ui.MovePanel.access$23(MovePanel.java:763)
        at games.strategy.triplea.ui.MovePanel$5.mouseMoved(MovePanel.java:1824)
        at games.strategy.triplea.ui.MapPanel.notifyMouseMoved(MapPanel.java:354)
        at games.strategy.triplea.ui.MapPanel.access$15(MapPanel.java:346)
        at games.strategy.triplea.ui.MapPanel$2.mouseMoved(MapPanel.java:520)
        at java.awt.AWTEventMulticaster.mouseMoved(Unknown Source)
        at java.awt.Component.processMouseMotionEvent(Unknown Source)
        at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Please contribute to the TripleA 2013 donation drive:
http://tripleadev.1671093.n2.nabble.com/2013-TripleA-Donation-Drive-tp7583455.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to make Non-Combat Movement of Paratroopers a property, need help

Veqryn
Administrator
ok,
if anyone wants to look at my code, it is here:

NonCombatParatroopers.patch

and the game i am using to play it is here:

test_of_non-combat_paratroopers.xml
(put it in your ww2v3 games folder)


basically I edited 4 files:

constants: added a new property
properties: added that property
MoveValidator: changed a couple if statements to allow you to move paratroopers during non-combat
MovePanel: changed a single if statement to allow you to move paratroopers during non-combat


This is LOW priority,
but anyone is welcome to tell me what the error means,
thx,
veqryn
Please contribute to the TripleA 2013 donation drive:
http://tripleadev.1671093.n2.nabble.com/2013-TripleA-Donation-Drive-tp7583455.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to make Non-Combat Movement of Paratroopers a property, need help

ComradeKev
Administrator
In reply to this post by Veqryn
Veqryn wrote
java.lang.NullPointerException
        at games.strategy.triplea.delegate.MoveValidator.validateBasic(MoveValidator.java:1138)

and

java.lang.NullPointerException
        at games.strategy.triplea.delegate.MoveValidator.isLoad(MoveValidator.java:416)
Those are the locations of your errors.  I'm not looking at the source and so I don't know exactly which fields are null, but that'll give you a headstart until I can look into it later.
If emailing me at ComradeKev at yahoo.com , please add TripleA to the subject line
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to make Non-Combat Movement of Paratroopers a property, need help

Seidelin
Hi Kevin,

It seems that your account was hacked by some scammers since I got this typical scam e-mail appearing to be from you:

Sorry for abusing the forums for this, but e-mail seems to be unusable. Feel free to delete this post.

---
Subject:
SAD NEWS (I NEED YOUR URGENT HELP)
From:
Kevin Comcowich <comradekev@yahoo.com>
Date:
Fri, 15 Oct 2010 05:08:15 -0700 (PDT)
To:
undisclosed recipients: ;

Hello
 
I'm sorry for this odd request because it might get to you too urgent but it's just the situation of things right now, I'm presently in London, England. I came down here on vacation in a resort newly opened. I was robbed, worse of it is that bags, cash and credit cards was stolen from me at GUN POINT.
 
It's such a crazy experience for me and I need settling my hotel bills and buying my return ticket back home, the authorities are not being 100% supportive but the good thing is I still have my passport but don't have enough money to get on a plane back home, please I need you to loan me some money till I get back home to refund it back.
 
Thanks
Kevin
---
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to make Non-Combat Movement of Paratroopers a property, need help

ComradeKev
Administrator
Yeah, I saw that this morning... My wife got an email that I was being held hostage in Italy... i told her to hurry and send cash!  I've since reclaimed my account and secured it.
If emailing me at ComradeKev at yahoo.com , please add TripleA to the subject line