25-08-2010, 07:38 AM
|
#70 (permalink)
|
|
Membro - Coronel
Registrado em: Feb 2009
Localização: Em Casa
Posts: 191
Agradecido 193 Vezes em 70 Posts
Achei Ruim:
Acharam ruim Vezes em Posts
Meu Estado:
|
Para Corrigir o Duplicar Character Execute Essa Diff.
Spoiler
Index: D:/L2jSever/L2JStep_CORE/java/com/l2jstep/gameserver/network/clientpackets/CharacterCreate.java
================================================== =================
--- D:/L2jSever/L2JStep_CORE/java/com/l2jstep/gameserver/network/clientpackets/CharacterCreate.java (revision 72)
+++ D:/L2jSever/L2JStep_CORE/java/com/l2jstep/gameserver/network/clientpackets/CharacterCreate.java (revision 158)
@@ -23,4 +23,5 @@
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import java.util.concurrent.locks.ReentrantLock;
import com.l2jstep.Config;
@@ -91,21 +92,5 @@
protected void runImpl()
{
- if (CharNameTable.getInstance().accountCharNumber(get Client().getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT && Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0)
- {
- if (Config.DEBUG)
- _log.fine("Max number of characters reached. Creation failed.");
- CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHAR ACTERS);
- sendPacket(ccf);
- return;
- }
- else if (CharNameTable.getInstance().doesCharNameExist(_na me))
- {
- if (Config.DEBUG)
- _log.fine("charname: "+ _name + " already exists. creation failed.");
- CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_ EXISTS);
- sendPacket(ccf);
- return;
- }
- else if ((_name.length() < 3) || (_name.length() > 16) || !Util.isAlphaNumeric(_name) || !isValidName(_name))
+ if ((_name.length() < 3) || (_name.length() > 16) || !Util.isAlphaNumeric(_name) || !isValidName(_name))
{
if (Config.DEBUG)
@@ -116,18 +101,47 @@
}
- if (Config.DEBUG)
- _log.fine("charname: " + _name + " classId: " + _classId);
-
- L2PcTemplate template = CharTemplateTable.getInstance().getTemplate(_class Id);
- if(template == null || template.classBaseLevel > 1)
- {
- CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_CREATION_FAIL ED);
- sendPacket(ccf);
- return;
- }
-
- int objectId = IdFactory.getInstance().getNextId();
- L2PcInstance newChar = L2PcInstance.create(objectId, template, getClient().getAccountName(),
- _name, _hairStyle, _hairColor, _face, _sex!=0);
+ L2PcInstance newChar = null;
+ L2PcTemplate template = null;
+
+ /*
+ * Since checks for duplicate names are done using SQL,
+ * lock must be held until data is written to DB as well.
+ */
+ synchronized (CharNameTable.getInstance())
+ {
+ if (CharNameTable.getInstance().accountCharNumber(get Client().getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT
+ && Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0)
+ {
+ if (Config.DEBUG)
+ _log.fine("Max number of characters reached. Creation failed.");
+ CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHAR ACTERS);
+ sendPacket(ccf);
+ return;
+ }
+ else if (CharNameTable.getInstance().doesCharNameExist(_na me))
+ {
+ if (Config.DEBUG)
+ _log.fine("charname: " + _name + " already exists. creation failed.");
+ CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_ EXISTS);
+ sendPacket(ccf);
+ return;
+ }
+
+ template = CharTemplateTable.getInstance().getTemplate(_class Id);
+
+ if (Config.DEBUG)
+ _log.fine("charname: " + _name + " classId: " + _classId + " template: " + template);
+
+ if (template == null || template.classBaseLevel > 1)
+ {
+ CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_CREATION_FAIL ED);
+ sendPacket(ccf);
+ return;
+ }
+
+ int objectId = IdFactory.getInstance().getNextId();
+ newChar = L2PcInstance.create(objectId, template, getClient().getAccountName(), _name, _hairStyle, _hairColor, _face, _sex != 0);
+ }
+
newChar.setCurrentHp(template.baseHpMax);
newChar.setCurrentCp(template.baseCpMax);
|
|
|