3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

Update TODO list, add pipeline cache

Dieser Commit ist enthalten in:
Myles 2016-03-23 14:00:48 +00:00
Ursprung 95ceabb495
Commit 0376602894
3 geänderte Dateien mit 20 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -3,16 +3,8 @@
This is an experimental branch, but soon to be live.
The things which stop this from going live:
Need to implement debug mode using deprecated PacketType for english
and then javadocs.
It would be nice to have a Pipeline cache so it doesn't have to figure it out all the time.
(and to ensure it uses the shortest pipeline)
(The only issues would be really really complex protocol pipelines...)
(But I don't see them happening any time soon)
License:
--------

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>0.6.8-SNAPSHOT</version>
<version>0.7.0-ALPHA</version>
<packaging>jar</packaging>
<name>ViaVersion</name>

Datei anzeigen

@ -10,6 +10,7 @@ public class ProtocolRegistry {
public static int SERVER_PROTOCOL = -1;
// Input Version -> Output Version & Protocol (Allows fast lookup)
private static Map<Integer, Map<Integer, Protocol>> registryMap = new HashMap<>();
private static Map<Pair<Integer, Integer>, List<Pair<Integer, Protocol>>> pathCache = new HashMap<>();
static {
// Register built in protocols
@ -25,6 +26,10 @@ public class ProtocolRegistry {
* @param output The output server version it converts to.
*/
public static void registerProtocol(Protocol protocol, List<Integer> supported, Integer output) {
// Clear cache as this may make new routes.
if (pathCache.size() > 0)
pathCache.clear();
for (Integer version : supported) {
if (!registryMap.containsKey(version)) {
registryMap.put(version, new HashMap<Integer, Protocol>());
@ -97,7 +102,17 @@ public class ProtocolRegistry {
* @return The path it generated, null if it failed.
*/
public static List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) {
// TODO: Cache
return getProtocolPath(new ArrayList<Pair<Integer, Protocol>>(), clientVersion, serverVersion);
Pair<Integer, Integer> protocolKey = new Pair<>(clientVersion, serverVersion);
// Check cache
if (pathCache.containsKey(protocolKey)) {
return pathCache.get(protocolKey);
}
// Generate path
List<Pair<Integer, Protocol>> outputPath = getProtocolPath(new ArrayList<Pair<Integer, Protocol>>(), clientVersion, serverVersion);
// If it found a path, cache it.
if (outputPath != null) {
pathCache.put(protocolKey, outputPath);
}
return outputPath;
}
}