If somebody want know and learn Java, explore lynda.comhe have a good video courses
If somebody want know and learn Java, explore lynda.comhe have a good video courses
Does anyone know how to use the RVEngine.sleep() function? I've tried it in the body of the main static method called by jCall, and also as a regular method in a class instantiated by the main static method called by jCall, but I get a "generic error in expression" error accompanied by a "suspending not allowed in this context" .rpt file message. I understand that when using .sqf this error applies when you try to execute a script with the call command instead of the spawn or execVM command. I'm assuming that jCall is equivalent to call which is why I'm getting the message. Is there a Java equivalent to execVM or spawn that I should be using (or another way to utilise RVEngine.sleep())?
In this context, wouldn't you do this with a Java statement instead of the exposed RVEngine functions? Never touched Java, but wouldn't this be something that could help you?
If you do it by java functions, you'll very probably halt the game engine for the duration. Can't remember actually trying it, (maybe I did) but the way it works otherwise is a strong indication that this is what will happen.
In pure sqf, you have two contexts - scheduled and nonscheduled. Non-scheduled will run until it finishes. Scheduled can be paused - by the code calling sleep or when the game engine finds it has run for long enough. We do not have a good specification on when. You can "jump into" scheduled with spawn, execvm, but you can't jump back. Using call just means the current function won't proceed until the called code is finished; with call it basically inherits the context of the caller.
Jcall, however, has nothing to do with that. The problem is that the game engine will halt until the jcalled function returns. It currently has to do this because unless you're in the time window between the jcallee starting and returning, RVEngine calls are race conditions usually ending in crashes. Try spawning a java thread to call the rvengine functions after the jcalled function returns; when I did, it always crashed. Sometimes took a while (up to 47 seconds), but always crashed. In theory it could be possible to make RVEngine.Sleep() suspend the sqf "thread" that called it, but that's going to be advanced and highly reliant on the jre; possibly relying on undocumented features. That's a question for java gurus; of which BIS has none on the payroll.
Short version: Java code has to do everything in one go, and return. This severely limits its usefulness.
If the race condition problem was fixed, you could work around this by spawning a new thread and using the java method.
I've been away for most of the summer and my Windows machine has died so I haven't been doing much with TOH. After being away for so long I was hoping to come back and find lots of new updates and more information on the Java API... but things don't seem to have progressed at all since I was last here...
Is the Java API going to get any love? Are there any patches or updates in the pipeline that address some of the issues that have been raised? Now that the summer is (almost) over and I have some spare time I was hoping to get back into TOH Java programming.
---------- Post added at 06:20 PM ---------- Previous post was at 05:46 PM ----------
I have not experienced this. I have spawned several threads that call RVEngine methods but I use Thread.sleep() to pause my thread. RVEngine.sleep() is likely just a left over from porting the SQF API to Java and should likely be avoided. Having said that, I have only been attempting relatively simple tasks with relatively long sleep periods and I haven't been testing to see if I can find race conditions.
All my Java code is on my dead Windows box, but basically I:
- jCall a Java method that starts a worker thread
- Call RVEngine methods from the thread.
- Use Thread.sleep() when I want to pause processing.
In theory there is no difference between theory and practice; but in practice there is.
Slapstick ,
will you be entering this world of Java again as it is or you need some fixes ? , i have some code i need to maybe convert to Java because its very hmmm Intense at the moment for normal Engine usages inSQF format , iam trying to get more mileage on FPS and hoping java will help.
Basicly i looked at this addon
http://www.armaholic.com/page.php?id...AMIC%2BTERRAIN
But i didnt make mission like they did, i placed them in Visitor so it not Lag so much , this make a little more Harder to track Tiles but still not so much really, However the code to Define what happens when someone fires and the consequence animations i feel could really utilize this Java maybe, what is your thoughts ?
The code i feel will benefit from Java ??
Spoiler:
i tried make Result video but cant see really.
Result
Last edited by Thromp; Sep 21 2012 at 22:31.
A chopper cup of Coffee in a chopper coffee pot
TOH Now with added Coffee
http://www.helpivanmartin.org/
Well, there isn't anything specific I want to do other than play around with the Java API and provide some feedback for BIS.
I am just here to play around, but there are definite areas that need improvement and I was hoping there would have been some progress over the last few months…
Actually, event handlers are one thing that needs work in the current Java API. There is an RVEngine.addEventHandler method, but the event handler has to be written in SQF (as far as I can determine), so you can't stay in pure Java Land. So, at this point I would say that want you want to do is best done in SQF.
However, the lack of progress or any new information has me concerned… If BIS wants to open a New York office I would be happy to apply for a job as a Java developer and help out! ;-)
That's a shame ,
I think they must be doing so much with Arma3 and Dayz and commander game ,I'm sure it's advanced but maybe not stable , unless dayz won't use java with TOH engine and its been dropped by arma3 ,
However from what I see of BIS , if you can put business case ,I'm sure they would hire you by proxy from home.
Java was pretty much an experiment and it has been confirmed in multiple places by multiple people that its not going to be developed any further, at least not in the near future.
As far as SQF and performance goes it is fine if you know how to use it. ACRE does roughly 500-3000+ operations PER FRAME depending on the load/circumstances with no appreciable performance loss, and that includes real time radio signal calculations covering huge distances in the game world.