11/***********************************************************************************
2- * Copyright (c) 2024 /// Project SWG /// www.projectswg.com *
2+ * Copyright (c) 2025 /// Project SWG /// www.projectswg.com *
33 * *
4- * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
4+ * ProjectSWG is an emulation project for Star Wars Galaxies founded on *
55 * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
6- * Our goal is to create an emulator which will provide a server for players to *
7- * continue playing a game similar to the one they used to play. We are basing *
8- * it on the final publish of the game prior to end-game events. *
6+ * Our goal is to create one or more emulators which will provide servers for *
7+ * players to continue playing a game similar to the one they used to play. *
98 * *
109 * This file is part of Holocore. *
1110 * *
@@ -182,13 +181,17 @@ public void decode(ByteBuffer data, StringType keyType, Class<V> vType) {
182181 NetBuffer buffer = NetBuffer .wrap (data );
183182 try {
184183 for (int i = 0 ; i < size ; i ++) {
185- buffer .getByte ();
184+ byte updateType = buffer .getByte ();
186185 String key = buffer .getString (keyType );
187186 Object value = buffer .getGeneric (vType );
188- if (value != null && vType .isAssignableFrom (value .getClass ()))
189- put ((K ) key , (V ) value );
190- else
191- Log .e ("Unable to parse: key=%s value=%s" , key , value );
187+ if (updateType == 0 || updateType == 2 ) {
188+ if (value != null && vType .isAssignableFrom (value .getClass ()))
189+ put ((K ) key , (V ) value );
190+ else
191+ Log .e ("Unable to parse: key=%s value=%s" , key , value );
192+ } else if (updateType == 1 ) {
193+ remove (key );
194+ }
192195 }
193196 } catch (ClassCastException e ) {
194197 Log .e (e );
@@ -204,7 +207,7 @@ public void decode(ByteBuffer data, Class<K> kType, Class<V> vType) {
204207
205208 NetBuffer buffer = NetBuffer .wrap (data );
206209 for (int i = 0 ; i < size ; i ++) {
207- buffer .getByte ();
210+ byte updateType = buffer .getByte ();
208211 Object key = buffer .getGeneric (kType );
209212 if (key == null ) {
210213 Log .e ("Failed to decode: " + kType .getSimpleName ());
@@ -215,10 +218,14 @@ public void decode(ByteBuffer data, Class<K> kType, Class<V> vType) {
215218 Log .e ("Failed to decode: " + vType .getSimpleName ());
216219 break ;
217220 }
218- if (kType .isAssignableFrom (key .getClass ()) && vType .isAssignableFrom (value .getClass ()))
219- put ((K ) key , (V ) value );
220- else
221- Log .e ("Failed to insert key=" + key + " value=" + value );
221+ if (updateType == 0 || updateType == 2 ) {
222+ if (kType .isAssignableFrom (key .getClass ()) && vType .isAssignableFrom (value .getClass ()))
223+ put ((K ) key , (V ) value );
224+ else
225+ Log .e ("Failed to insert key=" + key + " value=" + value );
226+ } else if (updateType == 1 ) {
227+ remove (key );
228+ }
222229 }
223230 clearDeltaQueue ();
224231 }
0 commit comments