|
@@ -57,7 +57,7 @@ public class Olympiad
|
|
|
|
|
|
private static final Map<Integer, StatsSet> _nobles = new FastMap<>();
|
|
|
protected static L2FastList<StatsSet> _heroesToBe;
|
|
|
- private static TIntIntHashMap _noblesRank;
|
|
|
+ private static final TIntIntHashMap _noblesRank = new TIntIntHashMap();
|
|
|
|
|
|
private static final String OLYMPIAD_DATA_FILE = "config/olympiad.properties";
|
|
|
public static final String OLYMPIAD_HTML_PATH = "data/html/olympiad/";
|
|
@@ -78,7 +78,41 @@ public class Olympiad
|
|
|
private static final String OLYMPIAD_MONTH_CREATE = "INSERT INTO olympiad_nobles_eom SELECT charId, class_id, olympiad_points, competitions_done, competitions_won, competitions_lost, competitions_drawn FROM olympiad_nobles";
|
|
|
private static final int[] HERO_IDS =
|
|
|
{
|
|
|
- 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 131, 132, 133, 134
|
|
|
+ 88,
|
|
|
+ 89,
|
|
|
+ 90,
|
|
|
+ 91,
|
|
|
+ 92,
|
|
|
+ 93,
|
|
|
+ 94,
|
|
|
+ 95,
|
|
|
+ 96,
|
|
|
+ 97,
|
|
|
+ 98,
|
|
|
+ 99,
|
|
|
+ 100,
|
|
|
+ 101,
|
|
|
+ 102,
|
|
|
+ 103,
|
|
|
+ 104,
|
|
|
+ 105,
|
|
|
+ 106,
|
|
|
+ 107,
|
|
|
+ 108,
|
|
|
+ 109,
|
|
|
+ 110,
|
|
|
+ 111,
|
|
|
+ 112,
|
|
|
+ 113,
|
|
|
+ 114,
|
|
|
+ 115,
|
|
|
+ 116,
|
|
|
+ 117,
|
|
|
+ 118,
|
|
|
+ 131,
|
|
|
+ 132,
|
|
|
+ 133,
|
|
|
+ 134
|
|
|
};
|
|
|
|
|
|
private static final int COMP_START = Config.ALT_OLY_START_TIME; // 6PM
|
|
@@ -244,13 +278,12 @@ public class Olympiad
|
|
|
try
|
|
|
{
|
|
|
con = L2DatabaseFactory.getInstance().getConnection();
|
|
|
- PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES);
|
|
|
- ResultSet rset = statement.executeQuery();
|
|
|
-
|
|
|
+ final PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES);
|
|
|
+ final ResultSet rset = statement.executeQuery();
|
|
|
+ StatsSet statData;
|
|
|
while (rset.next())
|
|
|
{
|
|
|
- StatsSet statData = new StatsSet();
|
|
|
- int charId = rset.getInt(CHAR_ID);
|
|
|
+ statData = new StatsSet();
|
|
|
statData.set(CLASS_ID, rset.getInt(CLASS_ID));
|
|
|
statData.set(CHAR_NAME, rset.getString(CHAR_NAME));
|
|
|
statData.set(POINTS, rset.getInt(POINTS));
|
|
@@ -264,7 +297,7 @@ public class Olympiad
|
|
|
statData.set(COMP_DONE_WEEK_TEAM, rset.getInt(COMP_DONE_WEEK_TEAM));
|
|
|
statData.set("to_save", false);
|
|
|
|
|
|
- _nobles.put(charId, statData);
|
|
|
+ addNobleStats(rset.getInt(CHAR_ID), statData);
|
|
|
}
|
|
|
|
|
|
rset.close();
|
|
@@ -301,13 +334,13 @@ public class Olympiad
|
|
|
milliToEnd = getMillisToValidationEnd();
|
|
|
}
|
|
|
|
|
|
- _log.info("Olympiad System: " + Math.round(milliToEnd / 60000) + " minutes until period ends");
|
|
|
+ _log.info("Olympiad System: " + (milliToEnd / 60000) + " minutes until period ends");
|
|
|
|
|
|
if (_period == 0)
|
|
|
{
|
|
|
milliToEnd = getMillisToWeekChange();
|
|
|
|
|
|
- _log.info("Olympiad System: Next weekly change is in " + Math.round(milliToEnd / 60000) + " minutes");
|
|
|
+ _log.info("Olympiad System: Next weekly change is in " + (milliToEnd / 60000) + " minutes");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -317,7 +350,7 @@ public class Olympiad
|
|
|
|
|
|
public void loadNoblesRank()
|
|
|
{
|
|
|
- _noblesRank = new TIntIntHashMap();
|
|
|
+ _noblesRank.clear();
|
|
|
TIntIntHashMap tmpPlace = new TIntIntHashMap();
|
|
|
|
|
|
Connection con = null;
|
|
@@ -460,12 +493,6 @@ public class Olympiad
|
|
|
return _nobles.get(playerId);
|
|
|
}
|
|
|
|
|
|
- protected static synchronized void updateNobleStats(int playerId, StatsSet stats)
|
|
|
- {
|
|
|
- _nobles.remove(playerId);
|
|
|
- _nobles.put(playerId, stats);
|
|
|
- }
|
|
|
-
|
|
|
private void updateCompStatus()
|
|
|
{
|
|
|
// _compStarted = false;
|
|
@@ -693,14 +720,12 @@ public class Olympiad
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
|
|
|
+ int currentPoints;
|
|
|
+ for (StatsSet nobleInfo : _nobles.values())
|
|
|
{
|
|
|
- final StatsSet nobleInfo = entry.getValue();
|
|
|
- int currentPoints = nobleInfo.getInteger(POINTS);
|
|
|
+ currentPoints = nobleInfo.getInteger(POINTS);
|
|
|
currentPoints += WEEKLY_POINTS;
|
|
|
nobleInfo.set(POINTS, currentPoints);
|
|
|
-
|
|
|
- updateNobleStats(entry.getKey(), nobleInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -714,15 +739,12 @@ public class Olympiad
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
|
|
|
+ for (StatsSet nobleInfo : _nobles.values())
|
|
|
{
|
|
|
- StatsSet nobleInfo = entry.getValue();
|
|
|
nobleInfo.set(COMP_DONE_WEEK, 0);
|
|
|
nobleInfo.set(COMP_DONE_WEEK_CLASSED, 0);
|
|
|
nobleInfo.set(COMP_DONE_WEEK_NON_CLASSED, 0);
|
|
|
nobleInfo.set(COMP_DONE_WEEK_TEAM, 0);
|
|
|
-
|
|
|
- updateNobleStats(entry.getKey(), nobleInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -789,8 +811,6 @@ public class Olympiad
|
|
|
statement.setInt(11, compDoneWeekTeam);
|
|
|
|
|
|
nobleInfo.set("to_save", false);
|
|
|
-
|
|
|
- updateNobleStats(charId, nobleInfo);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -909,10 +929,10 @@ public class Olympiad
|
|
|
if (_nobles != null)
|
|
|
{
|
|
|
_logResults.info("Noble,charid,classid,compDone,points");
|
|
|
-
|
|
|
+ StatsSet nobleInfo;
|
|
|
for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
|
|
|
{
|
|
|
- final StatsSet nobleInfo = entry.getValue();
|
|
|
+ nobleInfo = entry.getValue();
|
|
|
if (nobleInfo == null)
|
|
|
{
|
|
|
continue;
|
|
@@ -927,7 +947,10 @@ public class Olympiad
|
|
|
record = new LogRecord(Level.INFO, charName);
|
|
|
record.setParameters(new Object[]
|
|
|
{
|
|
|
- charId, classId, compDone, points
|
|
|
+ charId,
|
|
|
+ classId,
|
|
|
+ compDone,
|
|
|
+ points
|
|
|
});
|
|
|
_logResults.log(record);
|
|
|
}
|
|
@@ -967,7 +990,8 @@ public class Olympiad
|
|
|
record = new LogRecord(Level.INFO, "Hero " + hero.getString(CHAR_NAME));
|
|
|
record.setParameters(new Object[]
|
|
|
{
|
|
|
- hero.getInteger(CHAR_ID), hero.getInteger(CLASS_ID)
|
|
|
+ hero.getInteger(CHAR_ID),
|
|
|
+ hero.getInteger(CLASS_ID)
|
|
|
});
|
|
|
_logResults.log(record);
|
|
|
_heroesToBe.add(hero);
|
|
@@ -994,7 +1018,8 @@ public class Olympiad
|
|
|
record = new LogRecord(Level.INFO, "Hero " + hero.getString(CHAR_NAME));
|
|
|
record.setParameters(new Object[]
|
|
|
{
|
|
|
- hero.getInteger(CHAR_ID), hero.getInteger(CLASS_ID)
|
|
|
+ hero.getInteger(CHAR_ID),
|
|
|
+ hero.getInteger(CLASS_ID)
|
|
|
});
|
|
|
_logResults.log(record);
|
|
|
_heroesToBe.add(hero);
|
|
@@ -1051,7 +1076,8 @@ public class Olympiad
|
|
|
record = new LogRecord(Level.INFO, "Hero " + hero.getString(CHAR_NAME));
|
|
|
record.setParameters(new Object[]
|
|
|
{
|
|
|
- hero.getInteger(CHAR_ID), hero.getInteger(CLASS_ID)
|
|
|
+ hero.getInteger(CHAR_ID),
|
|
|
+ hero.getInteger(CLASS_ID)
|
|
|
});
|
|
|
_logResults.log(record);
|
|
|
_heroesToBe.add(hero);
|
|
@@ -1162,7 +1188,6 @@ public class Olympiad
|
|
|
if (clear)
|
|
|
{
|
|
|
noble.set(POINTS, 0);
|
|
|
- updateNobleStats(objId, noble);
|
|
|
}
|
|
|
points *= Config.ALT_OLY_GP_PER_POINT;
|
|
|
return points;
|
|
@@ -1361,6 +1386,16 @@ public class Olympiad
|
|
|
_nobles.clear();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param charId the noble object Id.
|
|
|
+ * @param data the stats set data to add.
|
|
|
+ * @return the old stats set if the noble is already present, null otherwise.
|
|
|
+ */
|
|
|
+ protected static StatsSet addNobleStats(int charId, StatsSet data)
|
|
|
+ {
|
|
|
+ return _nobles.put(Integer.valueOf(charId), data);
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressWarnings("synthetic-access")
|
|
|
private static class SingletonHolder
|
|
|
{
|