Addition of separate IdFactoryType enum.
This commit is contained in:
parent
5c96ef2dd0
commit
7be20ca5c0
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -791,12 +792,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;
|
||||
|
||||
@ -1827,7 +1822,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -799,12 +800,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;
|
||||
|
||||
@ -1851,7 +1846,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -786,12 +787,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;
|
||||
|
||||
@ -1831,7 +1826,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -782,12 +783,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;
|
||||
|
||||
@ -1907,7 +1902,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -782,12 +783,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;
|
||||
|
||||
@ -1907,7 +1902,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -783,12 +784,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;
|
||||
|
||||
@ -1937,7 +1932,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))
|
||||
{
|
||||
|
9
L2J_Mobius_C6_Interlude/dist/game/config/olympiad.cfg
vendored
Normal file
9
L2J_Mobius_C6_Interlude/dist/game/config/olympiad.cfg
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
#Olympiad Properties
|
||||
#Tue Aug 20 13:40:12 EEST 2019
|
||||
NextWeeklyChange_DateFormat=27 \u0391\u03C5\u03B3 2019, 1\:35\:34 \u03BC.\u03BC.
|
||||
ValdationEnd=0
|
||||
NextWeeklyChange=1566902134230
|
||||
Period=0
|
||||
CurrentCycle=1
|
||||
OlympiadEnd=1567328400230
|
||||
OlympiadEnd_DateFormat=1 \u03A3\u03B5\u03C0 2019, 12\:00\:00 \u03BC.\u03BC.
|
@ -1,9 +1,8 @@
|
||||
# Tell server which IDFactory Class to use
|
||||
# Options are:
|
||||
# Compaction (Original method),
|
||||
# BitSet (One non compaction method - default),
|
||||
# Stack (Another non compaction method)
|
||||
IDFactory = BitSet
|
||||
# BITSET (One non compaction method - default),
|
||||
# STACK (Another non compaction method)
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up
|
||||
# Much faster load time without it, but may cause problems
|
||||
|
@ -39,6 +39,7 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.commons.util.ClassMasterSettings;
|
||||
import org.l2jmobius.commons.util.L2Properties;
|
||||
import org.l2jmobius.commons.util.StringUtil;
|
||||
import org.l2jmobius.gameserver.enums.IdFactoryType;
|
||||
import org.l2jmobius.gameserver.model.entity.olympiad.OlympiadPeriod;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
|
||||
import org.l2jmobius.loginserver.LoginController;
|
||||
@ -1310,7 +1311,7 @@ public class Config
|
||||
idSettings.load(is);
|
||||
is.close();
|
||||
|
||||
IDFACTORY_TYPE = IdFactoryType.valueOf(idSettings.getProperty("IDFactory", "Compaction"));
|
||||
IDFACTORY_TYPE = IdFactoryType.valueOf(idSettings.getProperty("IDFactory", "BITSET"));
|
||||
BAD_ID_CHECKING = Boolean.valueOf(idSettings.getProperty("BadIdChecking", "true"));
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -3706,14 +3707,6 @@ public class Config
|
||||
}
|
||||
}
|
||||
|
||||
/** Enumeration for type of ID Factory */
|
||||
public enum IdFactoryType
|
||||
{
|
||||
Compaction,
|
||||
BitSet,
|
||||
Stack
|
||||
}
|
||||
|
||||
public static void saveHexid(int serverId, String string)
|
||||
{
|
||||
saveHexid(serverId, string, HEXID_FILE);
|
||||
|
@ -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
|
||||
}
|
@ -18,32 +18,31 @@ package org.l2jmobius.gameserver.idfactory;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.util.PrimeFinder;
|
||||
import org.l2jmobius.gameserver.util.PrimeFinder;
|
||||
|
||||
/**
|
||||
* This class ..
|
||||
* @author Olympic
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
public class BitSetIDFactory extends IdFactory
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(BitSetIDFactory.class.getName());
|
||||
|
||||
private BitSet _freeIds;
|
||||
private AtomicInteger _freeIdCount;
|
||||
private AtomicInteger _nextFreeId;
|
||||
|
||||
public class BitSetCapacityCheck implements Runnable
|
||||
protected class BitSetCapacityCheck implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (reachingBitSetCapacity())
|
||||
synchronized (BitSetIDFactory.this)
|
||||
{
|
||||
increaseBitSetCapacity();
|
||||
if (reachingBitSetCapacity())
|
||||
{
|
||||
increaseBitSetCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,12 +50,16 @@ public class BitSetIDFactory extends IdFactory
|
||||
protected BitSetIDFactory()
|
||||
{
|
||||
super();
|
||||
ThreadPool.scheduleAtFixedRate(new BitSetCapacityCheck(), 30000, 30000);
|
||||
initialize();
|
||||
LOGGER.info("IDFactory: " + _freeIds.size() + " id's available.");
|
||||
|
||||
synchronized (BitSetIDFactory.class)
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(new BitSetCapacityCheck(), 30000, 30000);
|
||||
initialize();
|
||||
}
|
||||
LOGGER.info(getClass().getSimpleName() + ": " + _freeIds.size() + " id's available.");
|
||||
}
|
||||
|
||||
public synchronized void initialize()
|
||||
public void initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -69,6 +72,7 @@ public class BitSetIDFactory extends IdFactory
|
||||
final int objectID = usedObjectId - FIRST_OID;
|
||||
if (objectID < 0)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Object ID " + usedObjectId + " in DB is less than minimum ID of " + FIRST_OID);
|
||||
continue;
|
||||
}
|
||||
_freeIds.set(usedObjectId - FIRST_OID);
|
||||
@ -81,8 +85,7 @@ public class BitSetIDFactory extends IdFactory
|
||||
catch (Exception e)
|
||||
{
|
||||
_initialized = false;
|
||||
LOGGER.warning("BitSet ID Factory could not be initialized correctly " + e);
|
||||
e.printStackTrace();
|
||||
LOGGER.severe(getClass().getSimpleName() + ": Could not be initialized properly: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +99,7 @@ public class BitSetIDFactory extends IdFactory
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warning("BitSet ID Factory: release objectID " + objectID + " failed (< " + FIRST_OID + ")");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Release objectID " + objectID + " failed (< " + FIRST_OID + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,22 +110,15 @@ public class BitSetIDFactory extends IdFactory
|
||||
_freeIds.set(newID);
|
||||
_freeIdCount.decrementAndGet();
|
||||
|
||||
int nextFree = _freeIds.nextClearBit(newID);
|
||||
final int nextFree = _freeIds.nextClearBit(newID) < 0 ? _freeIds.nextClearBit(0) : _freeIds.nextClearBit(newID);
|
||||
|
||||
if (nextFree < 0)
|
||||
{
|
||||
nextFree = _freeIds.nextClearBit(0);
|
||||
}
|
||||
if (nextFree < 0)
|
||||
{
|
||||
if (_freeIds.size() < FREE_OBJECT_ID_SIZE)
|
||||
{
|
||||
increaseBitSetCapacity();
|
||||
}
|
||||
else
|
||||
if (_freeIds.size() >= FREE_OBJECT_ID_SIZE)
|
||||
{
|
||||
throw new NullPointerException("Ran out of valid Id's.");
|
||||
}
|
||||
increaseBitSetCapacity();
|
||||
}
|
||||
|
||||
_nextFreeId.set(nextFree);
|
||||
@ -138,7 +134,7 @@ public class BitSetIDFactory extends IdFactory
|
||||
|
||||
protected synchronized int usedIdCount()
|
||||
{
|
||||
return (_freeIdCount.get() - FIRST_OID);
|
||||
return _freeIdCount.get() - FIRST_OID;
|
||||
}
|
||||
|
||||
protected synchronized boolean reachingBitSetCapacity()
|
||||
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* 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.idfactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
|
||||
/**
|
||||
* @author Olympic
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
public class CompactionIDFactory extends IdFactory
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(CompactionIDFactory.class.getName());
|
||||
private int _curOID;
|
||||
private final int _freeSize;
|
||||
|
||||
protected CompactionIDFactory()
|
||||
{
|
||||
super();
|
||||
_curOID = FIRST_OID;
|
||||
_freeSize = 0;
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
final int[] tmp_obj_ids = extractUsedObjectIDTable();
|
||||
|
||||
int N = tmp_obj_ids.length;
|
||||
for (int idx = 0; idx < N; idx++)
|
||||
{
|
||||
N = insertUntil(tmp_obj_ids, idx, N, con);
|
||||
}
|
||||
_curOID++;
|
||||
LOGGER.info("IdFactory: Next usable Object ID is: " + _curOID);
|
||||
_initialized = true;
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("ID Factory could not be initialized correctly " + e1);
|
||||
}
|
||||
}
|
||||
|
||||
private int insertUntil(int[] tmp_obj_ids, int idx, int N, Connection con) throws SQLException
|
||||
{
|
||||
int id = tmp_obj_ids[idx];
|
||||
if (id == _curOID)
|
||||
{
|
||||
_curOID++;
|
||||
return N;
|
||||
}
|
||||
// check these IDs not present in DB
|
||||
if (Config.BAD_ID_CHECKING)
|
||||
{
|
||||
for (String check : ID_CHECKS)
|
||||
{
|
||||
final PreparedStatement ps = con.prepareStatement(check);
|
||||
ps.setInt(1, _curOID);
|
||||
ps.setInt(2, id);
|
||||
final ResultSet rs = ps.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
final int badId = rs.getInt(1);
|
||||
LOGGER.warning("Bad ID " + badId + " in DB found by: " + check);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
}
|
||||
|
||||
int hole = id - _curOID;
|
||||
if (hole > (N - idx))
|
||||
{
|
||||
hole = N - idx;
|
||||
}
|
||||
for (int i = 1; i <= hole; i++)
|
||||
{
|
||||
id = tmp_obj_ids[N - i];
|
||||
LOGGER.info("Compacting DB object ID=" + id + " into " + (_curOID));
|
||||
for (String update : ID_UPDATES)
|
||||
{
|
||||
final PreparedStatement ps = con.prepareStatement(update);
|
||||
ps.setInt(1, _curOID);
|
||||
ps.setInt(2, id);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
_curOID++;
|
||||
}
|
||||
if (hole < (N - idx))
|
||||
{
|
||||
_curOID++;
|
||||
}
|
||||
return N - hole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int getNextId()
|
||||
{
|
||||
return _curOID++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void releaseId(int id)
|
||||
{
|
||||
// dont release ids until we are sure it isnt messing up
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return (_freeSize + LAST_OID) - FIRST_OID;
|
||||
}
|
||||
}
|
@ -20,47 +20,18 @@ import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
|
||||
/**
|
||||
* @author Olympic
|
||||
* @version $Revision: 1.3.2.1.2.7 $ $Date: 2005/04/11 10:06:12 $
|
||||
*/
|
||||
public abstract class IdFactory
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(IdFactory.class.getName());
|
||||
|
||||
protected static final String[] ID_UPDATES =
|
||||
{
|
||||
"UPDATE items SET owner_id = ? WHERE owner_id = ?",
|
||||
"UPDATE items SET object_id = ? WHERE object_id = ?",
|
||||
"UPDATE character_quests SET char_id = ? WHERE char_id = ?",
|
||||
"UPDATE character_friends SET char_id = ? WHERE char_id = ?",
|
||||
"UPDATE character_friends SET friend_id = ? WHERE friend_id = ?",
|
||||
"UPDATE character_hennas SET char_obj_id = ? WHERE char_obj_id = ?",
|
||||
"UPDATE character_recipebook SET char_id = ? WHERE char_id = ?",
|
||||
"UPDATE character_shortcuts SET char_obj_id = ? WHERE char_obj_id = ?",
|
||||
"UPDATE character_shortcuts SET shortcut_id = ? WHERE shortcut_id = ? AND type = 1", // items
|
||||
"UPDATE character_macroses SET char_obj_id = ? WHERE char_obj_id = ?",
|
||||
"UPDATE character_skills SET char_obj_id = ? WHERE char_obj_id = ?",
|
||||
"UPDATE character_skills_save SET char_obj_id = ? WHERE char_obj_id = ?",
|
||||
"UPDATE character_subclasses SET char_obj_id = ? WHERE char_obj_id = ?",
|
||||
"UPDATE characters SET obj_Id = ? WHERE obj_Id = ?",
|
||||
"UPDATE characters SET clanid = ? WHERE clanid = ?",
|
||||
"UPDATE clan_data SET clan_id = ? WHERE clan_id = ?",
|
||||
"UPDATE siege_clans SET clan_id = ? WHERE clan_id = ?",
|
||||
"UPDATE clan_data SET ally_id = ? WHERE ally_id = ?",
|
||||
"UPDATE clan_data SET leader_id = ? WHERE leader_id = ?",
|
||||
"UPDATE pets SET item_obj_id = ? WHERE item_obj_id = ?",
|
||||
"UPDATE character_hennas SET char_obj_id = ? WHERE char_obj_id = ?",
|
||||
"UPDATE itemsonground SET object_id = ? WHERE object_id = ?",
|
||||
"UPDATE auction_bid SET bidderId = ? WHERE bidderId = ?",
|
||||
"UPDATE auction_watch SET charObjId = ? WHERE charObjId = ?",
|
||||
"UPDATE clanhall SET ownerId = ? WHERE ownerId = ?"
|
||||
};
|
||||
protected final Logger LOGGER = Logger.getLogger(getClass().getName());
|
||||
|
||||
protected static final String[] ID_CHECKS =
|
||||
{
|
||||
@ -92,7 +63,7 @@ public abstract class IdFactory
|
||||
public static final int LAST_OID = 0x7FFFFFFF;
|
||||
public static final int FREE_OBJECT_ID_SIZE = LAST_OID - FIRST_OID;
|
||||
|
||||
protected static IdFactory _instance = null;
|
||||
protected static final IdFactory _instance;
|
||||
|
||||
protected IdFactory()
|
||||
{
|
||||
@ -104,21 +75,21 @@ public abstract class IdFactory
|
||||
{
|
||||
switch (Config.IDFACTORY_TYPE)
|
||||
{
|
||||
case Compaction:
|
||||
{
|
||||
_instance = new CompactionIDFactory();
|
||||
break;
|
||||
}
|
||||
case BitSet:
|
||||
case BITSET:
|
||||
{
|
||||
_instance = new BitSetIDFactory();
|
||||
break;
|
||||
}
|
||||
case Stack:
|
||||
case STACK:
|
||||
{
|
||||
_instance = new StackIDFactory();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_instance = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,16 +98,15 @@ public abstract class IdFactory
|
||||
*/
|
||||
private void setAllCharacterOffline()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement())
|
||||
{
|
||||
final Statement s2 = con.createStatement();
|
||||
s2.executeUpdate("update characters set online=0");
|
||||
s.executeUpdate("UPDATE characters SET online = 0");
|
||||
LOGGER.info("Updated characters online status.");
|
||||
|
||||
s2.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Could not update characters online status: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,19 +21,15 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
|
||||
/**
|
||||
* @author Olympic
|
||||
* @version $Revision: 1.3.2.1.2.7 $ $Date: 2005/04/11 10:06:12 $
|
||||
*/
|
||||
public class StackIDFactory extends IdFactory
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(IdFactory.class.getName());
|
||||
|
||||
private int _curOID;
|
||||
private int _tempOID;
|
||||
|
||||
@ -47,6 +43,8 @@ public class StackIDFactory extends IdFactory
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// con.createStatement().execute("drop table if exists tmp_obj_id");
|
||||
|
||||
final int[] tmp_obj_ids = extractUsedObjectIDTable();
|
||||
if (tmp_obj_ids.length > 0)
|
||||
{
|
||||
@ -64,9 +62,9 @@ public class StackIDFactory extends IdFactory
|
||||
LOGGER.info("IdFactory: Next usable Object ID is: " + _curOID);
|
||||
_initialized = true;
|
||||
}
|
||||
catch (Exception e1)
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("ID Factory could not be initialized correctly " + e1);
|
||||
LOGGER.severe(getClass().getSimpleName() + ": Could not be initialized properly:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,26 +81,26 @@ public class StackIDFactory extends IdFactory
|
||||
{
|
||||
for (String check : ID_CHECKS)
|
||||
{
|
||||
final PreparedStatement ps = con.prepareStatement(check);
|
||||
ps.setInt(1, _tempOID);
|
||||
ps.setInt(2, id);
|
||||
final ResultSet rs = ps.executeQuery();
|
||||
while (rs.next())
|
||||
try (PreparedStatement ps = con.prepareStatement(check))
|
||||
{
|
||||
final int badId = rs.getInt(1);
|
||||
LOGGER.warning("Bad ID " + badId + " in DB found by: " + check);
|
||||
throw new RuntimeException();
|
||||
ps.setInt(1, _tempOID);
|
||||
// ps.setInt(1, _curOID);
|
||||
ps.setInt(2, id);
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
if (rs.next())
|
||||
{
|
||||
final int badId = rs.getInt(1);
|
||||
LOGGER.severe("Bad ID " + badId + " in DB found by: " + check);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
}
|
||||
|
||||
int hole = id - _tempOID;
|
||||
if (hole > (N - idx))
|
||||
{
|
||||
hole = N - idx;
|
||||
}
|
||||
// int hole = id - _curOID;
|
||||
final int hole = (id - _tempOID) > (N - idx) ? N - idx : id - _tempOID;
|
||||
for (int i = 1; i <= hole; i++)
|
||||
{
|
||||
_freeOIDStack.push(_tempOID);
|
||||
|
@ -0,0 +1,353 @@
|
||||
/*
|
||||
* Copyright (c) 1999 CERN - European Organization for Nuclear Research.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear in
|
||||
* supporting documentation. CERN makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without expressed or implied warranty.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <b>Modified for Trove to use the java.util.Arrays sort/search<br>
|
||||
* algorithms instead of those provided with colt.</b><br>
|
||||
* Used to keep hash table capacities prime numbers.<br>
|
||||
* Not of interest for users; only for implementors of hashtables.<br>
|
||||
* <p>
|
||||
* Choosing prime numbers as hash table capacities is a good idea<br>
|
||||
* to keep them working fast, particularly under hash table expansions.<br>
|
||||
* <p>
|
||||
* However, JDK 1.2, JGL 3.1 and many other toolkits do nothing to keep capacities prime.<br>
|
||||
* This class provides efficient means to choose prime capacities.
|
||||
* <p>
|
||||
* Choosing a prime is <tt>O(log 300)</tt> (binary search in a list of 300 ints).<br>
|
||||
* Memory requirements: 1 KB static memory.<br>
|
||||
* @author wolfgang.hoschek@cern.ch
|
||||
* @version 1.0, 09/24/99
|
||||
*/
|
||||
public class PrimeFinder
|
||||
{
|
||||
/**
|
||||
* The largest prime this class can generate; currently equal to <tt>Integer.MAX_VALUE</tt>.
|
||||
*/
|
||||
public static final int LARGEST_PRIME = Integer.MAX_VALUE; // yes, it is prime.
|
||||
|
||||
/**
|
||||
* The prime number list consists of 11 chunks.<br>
|
||||
* Each chunk contains prime numbers.<br>
|
||||
* A chunk starts with a prime P1.<br>
|
||||
* The next element is a prime P2.<br>
|
||||
* P2 is the smallest prime for which holds: P2 >= 2*P1.<br>
|
||||
* The next element is P3, for which the same holds with respect to P2, and so on. Chunks are chosen such that for any desired capacity >= 1000<br>
|
||||
* the list includes a prime number <= desired capacity * 1.11.<br>
|
||||
* Therefore, primes can be retrieved which are quite close to any<br>
|
||||
* desired capacity, which in turn avoids wasting memory.<br>
|
||||
* For example, the list includes<br>
|
||||
* 1039,1117,1201,1277,1361,1439,1523,1597,1759,1907,2081.<br>
|
||||
* So if you need a prime >= 1040, you will find a prime <= 1040*1.11=1154.<br> Chunks are chosen such that they are optimized for a hashtable growthfactor of 2.0;<br>
|
||||
* If your hashtable has such a growthfactor then, after initially<br>
|
||||
* "rounding to a prime" upon hashtable construction, it will<br>
|
||||
* later expand to prime capacities such that there exist no better primes.<br>
|
||||
* In total these are about 32*10=320 numbers -> 1 KB of static memory needed.<br>
|
||||
* If you are stingy, then delete every second or fourth chunk.
|
||||
*/
|
||||
|
||||
private static final int[] PRIME_CAPACITIES =
|
||||
{
|
||||
// chunk #0
|
||||
LARGEST_PRIME,
|
||||
|
||||
// chunk #1
|
||||
5,
|
||||
11,
|
||||
23,
|
||||
47,
|
||||
97,
|
||||
197,
|
||||
397,
|
||||
797,
|
||||
1597,
|
||||
3203,
|
||||
6421,
|
||||
12853,
|
||||
25717,
|
||||
51437,
|
||||
102877,
|
||||
205759,
|
||||
411527,
|
||||
823117,
|
||||
1646237,
|
||||
3292489,
|
||||
6584983,
|
||||
13169977,
|
||||
26339969,
|
||||
52679969,
|
||||
105359939,
|
||||
210719881,
|
||||
421439783,
|
||||
842879579,
|
||||
1685759167,
|
||||
|
||||
// chunk #2
|
||||
433,
|
||||
877,
|
||||
1759,
|
||||
3527,
|
||||
7057,
|
||||
14143,
|
||||
28289,
|
||||
56591,
|
||||
113189,
|
||||
226379,
|
||||
452759,
|
||||
905551,
|
||||
1811107,
|
||||
3622219,
|
||||
7244441,
|
||||
14488931,
|
||||
28977863,
|
||||
57955739,
|
||||
115911563,
|
||||
231823147,
|
||||
463646329,
|
||||
927292699,
|
||||
1854585413,
|
||||
|
||||
// chunk #3
|
||||
953,
|
||||
1907,
|
||||
3821,
|
||||
7643,
|
||||
15287,
|
||||
30577,
|
||||
61169,
|
||||
122347,
|
||||
244703,
|
||||
489407,
|
||||
978821,
|
||||
1957651,
|
||||
3915341,
|
||||
7830701,
|
||||
15661423,
|
||||
31322867,
|
||||
62645741,
|
||||
125291483,
|
||||
250582987,
|
||||
501165979,
|
||||
1002331963,
|
||||
2004663929,
|
||||
|
||||
// chunk #4
|
||||
1039,
|
||||
2081,
|
||||
4177,
|
||||
8363,
|
||||
16729,
|
||||
33461,
|
||||
66923,
|
||||
133853,
|
||||
267713,
|
||||
535481,
|
||||
1070981,
|
||||
2141977,
|
||||
4283963,
|
||||
8567929,
|
||||
17135863,
|
||||
34271747,
|
||||
68543509,
|
||||
137087021,
|
||||
274174111,
|
||||
548348231,
|
||||
1096696463,
|
||||
|
||||
// chunk #5
|
||||
31,
|
||||
67,
|
||||
137,
|
||||
277,
|
||||
557,
|
||||
1117,
|
||||
2237,
|
||||
4481,
|
||||
8963,
|
||||
17929,
|
||||
35863,
|
||||
71741,
|
||||
143483,
|
||||
286973,
|
||||
573953,
|
||||
1147921,
|
||||
2295859,
|
||||
4591721,
|
||||
9183457,
|
||||
18366923,
|
||||
36733847,
|
||||
73467739,
|
||||
146935499,
|
||||
293871013,
|
||||
587742049,
|
||||
1175484103,
|
||||
|
||||
// chunk #6
|
||||
599,
|
||||
1201,
|
||||
2411,
|
||||
4831,
|
||||
9677,
|
||||
19373,
|
||||
38747,
|
||||
77509,
|
||||
155027,
|
||||
310081,
|
||||
620171,
|
||||
1240361,
|
||||
2480729,
|
||||
4961459,
|
||||
9922933,
|
||||
19845871,
|
||||
39691759,
|
||||
79383533,
|
||||
158767069,
|
||||
317534141,
|
||||
635068283,
|
||||
1270136683,
|
||||
|
||||
// chunk #7
|
||||
311,
|
||||
631,
|
||||
1277,
|
||||
2557,
|
||||
5119,
|
||||
10243,
|
||||
20507,
|
||||
41017,
|
||||
82037,
|
||||
164089,
|
||||
328213,
|
||||
656429,
|
||||
1312867,
|
||||
2625761,
|
||||
5251529,
|
||||
10503061,
|
||||
21006137,
|
||||
42012281,
|
||||
84024581,
|
||||
168049163,
|
||||
336098327,
|
||||
672196673,
|
||||
1344393353,
|
||||
|
||||
// chunk #8
|
||||
3,
|
||||
7,
|
||||
17,
|
||||
37,
|
||||
79,
|
||||
163,
|
||||
331,
|
||||
673,
|
||||
1361,
|
||||
2729,
|
||||
5471,
|
||||
10949,
|
||||
21911,
|
||||
43853,
|
||||
87719,
|
||||
175447,
|
||||
350899,
|
||||
701819,
|
||||
1403641,
|
||||
2807303,
|
||||
5614657,
|
||||
11229331,
|
||||
22458671,
|
||||
44917381,
|
||||
89834777,
|
||||
179669557,
|
||||
359339171,
|
||||
718678369,
|
||||
1437356741,
|
||||
|
||||
// chunk #9
|
||||
43,
|
||||
89,
|
||||
179,
|
||||
359,
|
||||
719,
|
||||
1439,
|
||||
2879,
|
||||
5779,
|
||||
11579,
|
||||
23159,
|
||||
46327,
|
||||
92657,
|
||||
185323,
|
||||
370661,
|
||||
741337,
|
||||
1482707,
|
||||
2965421,
|
||||
5930887,
|
||||
11861791,
|
||||
23723597,
|
||||
47447201,
|
||||
94894427,
|
||||
189788857,
|
||||
379577741,
|
||||
759155483,
|
||||
1518310967,
|
||||
|
||||
// chunk #10
|
||||
379,
|
||||
761,
|
||||
1523,
|
||||
3049,
|
||||
6101,
|
||||
12203,
|
||||
24407,
|
||||
48817,
|
||||
97649,
|
||||
195311,
|
||||
390647,
|
||||
781301,
|
||||
1562611,
|
||||
3125257,
|
||||
6250537,
|
||||
12501169,
|
||||
25002389,
|
||||
50004791,
|
||||
100009607,
|
||||
200019221,
|
||||
400038451,
|
||||
800076929,
|
||||
1600153859
|
||||
};
|
||||
static
|
||||
{ // initializer
|
||||
// The above prime numbers are formatted for human readability.
|
||||
// To find numbers fast, we sort them once and for all.
|
||||
|
||||
Arrays.sort(PRIME_CAPACITIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a prime number which is <code>>= desiredCapacity</code> and very close to <code>desiredCapacity</code> (within 11% if <code>desiredCapacity >= 1000</code>).
|
||||
* @param desiredCapacity the capacity desired by the user.
|
||||
* @return the capacity which should be used for a hashtable.
|
||||
*/
|
||||
public static int nextPrime(int desiredCapacity)
|
||||
{
|
||||
int i = Arrays.binarySearch(PRIME_CAPACITIES, desiredCapacity);
|
||||
if (i < 0)
|
||||
{
|
||||
// desired capacity not found, choose next prime greater
|
||||
// than desired capacity
|
||||
i = -i - 1; // remember the semantics of binarySearch...
|
||||
}
|
||||
return PRIME_CAPACITIES[i];
|
||||
}
|
||||
}
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -57,6 +57,7 @@ import org.w3c.dom.Node;
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.commons.util.PropertiesParser;
|
||||
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.holders.ItemHolder;
|
||||
@ -926,12 +927,6 @@ public class Config
|
||||
public static int PVP_NORMAL_TIME;
|
||||
public static int PVP_PVP_TIME;
|
||||
|
||||
public enum IdFactoryType
|
||||
{
|
||||
BitSet,
|
||||
Stack
|
||||
}
|
||||
|
||||
public static IdFactoryType IDFACTORY_TYPE;
|
||||
public static boolean BAD_ID_CHECKING;
|
||||
|
||||
@ -1994,7 +1989,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();
|
||||
|
@ -109,12 +109,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -778,12 +779,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;
|
||||
|
||||
@ -1750,7 +1745,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -778,12 +779,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;
|
||||
|
||||
@ -1754,7 +1749,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -778,12 +779,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;
|
||||
|
||||
@ -1754,7 +1749,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -778,12 +779,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;
|
||||
|
||||
@ -1754,7 +1749,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -778,12 +779,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;
|
||||
|
||||
@ -1754,7 +1749,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))
|
||||
{
|
||||
|
@ -9,11 +9,10 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Tell server which IDFactory Class to use:
|
||||
# Compaction = Original method
|
||||
# BitSet = One non compaction method
|
||||
# Stack = Another non compaction method
|
||||
# Default: BitSet
|
||||
IDFactory = BitSet
|
||||
# BITSET = One non compaction method
|
||||
# STACK = Another non compaction method
|
||||
# Default: BITSET
|
||||
IDFactory = BITSET
|
||||
|
||||
# Check for bad ids in the database on server boot up.
|
||||
# Much faster load time without it, but may cause problems.
|
||||
|
@ -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;
|
||||
@ -778,12 +779,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;
|
||||
|
||||
@ -1754,7 +1749,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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user