[Defconapi] Extensive use of SendChatMessage 3
Jakub Gemrot
jakub.gemrot at gmail.com
Mon Oct 5 09:11:12 CDT 2009
Next iteration ...
I've ruled out the extra thread inside JVM filling Queue of messages.
Now I generate all messages inside update() method (which tooks 0ms
together with SendChatMessage() calls as reported by
System.currentTimeMillis() method).
And I've observed a strange behavior of DefCon:
1) firstly, update() method is called regularly every 100 ms
2) ... then something goes wrong inside DefCon ... and update() is
called in 150ms, next in 50ms, next in 150 ms, 50ms, 150ms, and so on
3) then DefCon switches to the behavior observed in previous scenario,
the update() period gets longer and longer ...
Code included...
I'm wondering - how does DefCon decide - how long the game tick is?
According to the manual the update() method is called every game tick,
that means the tick is sometime 50ms long, sometime 150 and finally is
degrading.
Jakub
P.S.: my Java code:
static boolean first = true;
static long start;
static long lastRun = 0;
public static boolean update()
{
long updateStart = System.currentTimeMillis();
if (first) {
start = System.currentTimeMillis();
first = false;
} else {
SendChatMessage("Sync message, update called after " +
(System.currentTimeMillis()-lastRun) + " ms", CHATCHANNEL_PUBLIC);
int count = (int) ((System.currentTimeMillis()-lastRun) / 31);
for (int i = 0; i < count; ++i) {
SendChatMessage("Queue message at " +
(System.currentTimeMillis()-start) + " ms", CHATCHANNEL_PUBLIC);
}
}
lastRun = System.currentTimeMillis();
SendChatMessage("Update() took " + (System.currentTimeMillis() -
updateStart) + " ms", CHATCHANNEL_PUBLIC);
return true;
}
public static boolean initialise(String[][] _commandLineOptions)
{
SendChatMessage("Initialised...", CHATCHANNEL_PUBLIC);
return true;
}
public static void addEvent(int _eventType, int _causeObjectId,
int _targetObjectId,
int _unitType, float _longitude, float _latitude)
{
}
More information about the Defconapi
mailing list