Addition of separate IdFactoryType enum.
This commit is contained in:
@ -59,6 +59,7 @@ import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.commons.util.PropertiesParser;
|
||||
import org.l2jmobius.commons.util.StringUtil;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.enums.IdFactoryType;
|
||||
import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.base.ClassId;
|
||||
@ -798,12 +799,6 @@ public class Config
|
||||
public static int MAX_REPUTATION;
|
||||
public static int REPUTATION_INCREASE;
|
||||
|
||||
public enum IdFactoryType
|
||||
{
|
||||
BitSet,
|
||||
Stack
|
||||
}
|
||||
|
||||
public static IdFactoryType IDFACTORY_TYPE;
|
||||
public static boolean BAD_ID_CHECKING;
|
||||
|
||||
@ -1843,7 +1838,7 @@ public class Config
|
||||
// Load IdFactory config file (if exists)
|
||||
final PropertiesParser IdFactory = new PropertiesParser(IDFACTORY_CONFIG_FILE);
|
||||
|
||||
IDFACTORY_TYPE = IdFactory.getEnum("IDFactory", IdFactoryType.class, IdFactoryType.BitSet);
|
||||
IDFACTORY_TYPE = IdFactory.getEnum("IDFactory", IdFactoryType.class, IdFactoryType.BITSET);
|
||||
BAD_ID_CHECKING = IdFactory.getBoolean("BadIdChecking", true);
|
||||
|
||||
// Load General config file (if exists)
|
||||
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.enums;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public enum IdFactoryType
|
||||
{
|
||||
BITSET,
|
||||
STACK
|
||||
}
|
@ -132,17 +132,11 @@ public class BitSetIDFactory extends IdFactory
|
||||
return _freeIdCount.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
protected synchronized int usedIdCount()
|
||||
{
|
||||
return _freeIdCount.get() - FIRST_OID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
protected synchronized boolean reachingBitSetCapacity()
|
||||
{
|
||||
return PrimeFinder.nextPrime((usedIdCount() * 11) / 10) > _freeIds.size();
|
||||
|
@ -104,12 +104,12 @@ public abstract class IdFactory
|
||||
{
|
||||
switch (Config.IDFACTORY_TYPE)
|
||||
{
|
||||
case BitSet:
|
||||
case BITSET:
|
||||
{
|
||||
_instance = new BitSetIDFactory();
|
||||
break;
|
||||
}
|
||||
case Stack:
|
||||
case STACK:
|
||||
{
|
||||
_instance = new StackIDFactory();
|
||||
break;
|
||||
|
@ -103,10 +103,8 @@ public class StackIDFactory extends IdFactory
|
||||
final int hole = (id - _tempOID) > (N - idx) ? N - idx : id - _tempOID;
|
||||
for (int i = 1; i <= hole; i++)
|
||||
{
|
||||
// log.info("Free ID added " + (_tempOID));
|
||||
_freeOIDStack.push(_tempOID);
|
||||
_tempOID++;
|
||||
// _curOID++;
|
||||
}
|
||||
if (hole < (N - idx))
|
||||
{
|
||||
|
Reference in New Issue
Block a user