private void checkDuplicateNamesDuringDelete(List<Integer> ids){
  ArrayList<Entity> myEntities=game.getPlayerEntities(game.getPlayer(localPlayerNumber),false);
  Hashtable<String,ArrayList<Integer>> rawNameToId=new Hashtable<String,ArrayList<Integer>>((int)(myEntities.size() * 1.26));
  for (  Entity e : myEntities) {
    String rawName=e.getShortNameRaw();
    ArrayList<Integer> namedIds=rawNameToId.get(rawName);
    if (namedIds == null) {
      namedIds=new ArrayList<Integer>();
    }
    namedIds.add(e.getId());
    rawNameToId.put(rawName,namedIds);
  }
  for (  int id : ids) {
    Entity removedEntity=game.getEntity(id);
    if (removedEntity == null) {
      continue;
    }
    String removedRawName=removedEntity.getShortNameRaw();
    Integer count=duplicateNameHash.get(removedEntity.getShortNameRaw());
    if ((count != null) && (count > 1)) {
      ArrayList<Integer> namedIds=rawNameToId.get(removedRawName);
      for (      Integer i : namedIds) {
        Entity e=game.getEntity(i);
        String eRawName=e.getShortNameRaw();
        if (eRawName.equals(removedRawName) && (e.duplicateMarker > removedEntity.duplicateMarker)) {
          e.duplicateMarker--;
          e.generateShortName();
          e.generateDisplayName();
          if (!ids.contains(e.getId())) {
            sendUpdateEntity(e);
          }
        }
      }
      duplicateNameHash.put(removedEntity.getShortNameRaw(),new Integer(count - 1));
    }
 else     if (count != null) {
      duplicateNameHash.remove(removedEntity.getShortNameRaw());
    }
  }
}

private void checkDuplicateNamesDuringDelete ( List < Integer > ids ) { ArrayList < Entity > myEntities = game . getPlayerEntities ( game . getPlayer ( localPlayerNumber ) , false ) ; Hashtable < String , ArrayList < Integer > > rawNameToId = new Hashtable < String , ArrayList < Integer > > ( ( int ) ( myEntities . size ( ) * 1.26 ) ) ; for ( Entity e : myEntities ) { String rawName = e . getShortNameRaw ( ) ; ArrayList < Integer > namedIds = rawNameToId . get ( rawName ) ; if ( namedIds == null ) { namedIds = new ArrayList < Integer > ( ) ; } namedIds . add ( e . getId ( ) ) ; rawNameToId . put ( rawName , namedIds ) ; } for ( int id : ids ) { Entity removedEntity = game . getEntity ( id ) ; if ( removedEntity == null ) { continue ; } String removedRawName = removedEntity . getShortNameRaw ( ) ; Integer count = duplicateNameHash . get ( removedEntity . getShortNameRaw ( ) ) ; if ( ( count != null ) && ( count > 1 ) ) { ArrayList < Integer > namedIds = rawNameToId . get ( removedRawName ) ; for ( Integer i : namedIds ) { Entity e = game . getEntity ( i ) ; String eRawName = e . getShortNameRaw ( ) ; if ( eRawName . equals ( removedRawName ) && ( e . duplicateMarker > removedEntity . duplicateMarker ) ) { e . duplicateMarker -- ; e . generateShortName ( ) ; e . generateDisplayName ( ) ; if ( ! ids . contains ( e . getId ( ) ) ) { sendUpdateEntity ( e ) ; } } } duplicateNameHash . put ( removedEntity . getShortNameRaw ( ) , new Integer ( count - 1 ) ) ; } else if ( count != null ) { duplicateNameHash . remove ( removedEntity . getShortNameRaw ( ) ) ; } } }
if we remove an entity , we may need to update the duplicate identifier .
