1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Fixed issue at character creation and OrientDB selectIDs query issue

This commit is contained in:
2011-12-26 14:03:21 -02:00
parent b017ba5e71
commit d72a28f616
15 changed files with 29 additions and 17 deletions

View File

@@ -72,7 +72,7 @@ public class BitSetIDAllocator implements IDAllocator {
@Override @Override
public void allocate(int id) { public void allocate(int id) {
if (ids.get(id - FIRST_ID)) if (ids.get(id - FIRST_ID))
throw new IDAllocatorException("ID not allocated"); throw new IDAllocatorException("ID already allocated");
log.debug("Allocating ID {}", id); log.debug("Allocating ID {}", id);
lock.lock(); lock.lock();
try { try {

View File

@@ -63,6 +63,7 @@ import com.mysema.query.sql.RelationalPathBase;
import com.mysema.query.types.Path; import com.mysema.query.types.Path;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert;
import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OClass.INDEX_TYPE; import com.orientechnologies.orient.core.metadata.schema.OClass.INDEX_TYPE;
import com.orientechnologies.orient.core.metadata.schema.OProperty; import com.orientechnologies.orient.core.metadata.schema.OProperty;
@@ -214,7 +215,6 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
database = new ODatabaseDocumentTx(config.getUrl()); database = new ODatabaseDocumentTx(config.getUrl());
if (!database.exists()) { if (!database.exists()) {
database.create(); database.create();
} }
} }
// database.getStorage().addUser(); // database.getStorage().addUser();
@@ -260,6 +260,7 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
final ODatabaseDocumentTx database = ODatabaseDocumentPool.global() final ODatabaseDocumentTx database = ODatabaseDocumentPool.global()
.acquire(config.getUrl(), config.getUsername(), .acquire(config.getUrl(), config.getUsername(),
config.getPassword()); config.getPassword());
database.declareIntent(new OIntentMassiveInsert());
transaction.set(database); transaction.set(database);
try { try {
database.begin(OTransaction.TXTYPE.OPTIMISTIC); database.begin(OTransaction.TXTYPE.OPTIMISTIC);
@@ -274,6 +275,7 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
throw new DatabaseException(e); throw new DatabaseException(e);
} finally { } finally {
transaction.set(null); transaction.set(null);
database.declareIntent(null);
database.close(); database.close();
} }
} }

View File

@@ -152,8 +152,9 @@ public class CM_CHAR_CREATE extends AbstractClientPacket {
@Override @Override
public void process(final Lineage2Client conn) { public void process(final Lineage2Client conn) {
try { try {
final L2Character character = characterService.create(name, sex, final L2Character character = characterService.create(name, conn
characterClass, hairStyle, hairColor, face); .getSession().getAccountID(), sex, characterClass,
hairStyle, hairColor, face);
if (character != null) if (character != null)
conn.write(SM_CHAR_CREATE_OK.INSTANCE); conn.write(SM_CHAR_CREATE_OK.INSTANCE);

View File

@@ -62,6 +62,6 @@ public class CM_GOTO_LOBBY extends AbstractClientPacket {
final List<L2Character> chars = characterDao.selectByAccount(conn final List<L2Character> chars = characterDao.selectByAccount(conn
.getSession().getAccountID()); .getSession().getAccountID());
conn.write(SM_CHAR_LIST.fromL2Session(conn.getSession(), conn.write(SM_CHAR_LIST.fromL2Session(conn.getSession(),
chars.toArray(new L2Character[0]))); chars.toArray(new L2Character[chars.size()])));
} }
} }

View File

@@ -169,7 +169,10 @@ public class CharacterTemplate extends ActorTemplate<L2Character> {
@Override @Override
protected L2Character createInstance() { protected L2Character createInstance() {
return new L2Character(id); final L2Character character = new L2Character(id);
character.setCharacterClass(getCharacterClass());
character.setRace(getRace());
return character;
// character.setPosition(null); // TODO spawn location // character.setPosition(null); // TODO spawn location
// return null; // return null;
} }

View File

@@ -126,7 +126,7 @@ public class OrientDBCharacterDAO extends
@Override @Override
protected OQueryContextNative query( protected OQueryContextNative query(
OQueryContextNative record, QCharacter e) { OQueryContextNative record, QCharacter e) {
return record; return null;
} }
}); });
} }

View File

@@ -101,7 +101,7 @@ public class OrientDBCharacterFriendDAO extends
@Override @Override
protected OQueryContextNative query( protected OQueryContextNative query(
OQueryContextNative record, QCharacterFriend e) { OQueryContextNative record, QCharacterFriend e) {
return record; return null;
} }
}); });
} }

View File

@@ -95,7 +95,7 @@ public class OrientDBCharacterShortcutDAO extends
@Override @Override
protected OQueryContextNative query( protected OQueryContextNative query(
OQueryContextNative record, QCharacterShortcut e) { OQueryContextNative record, QCharacterShortcut e) {
return record; return null;
} }
}); });
} }

View File

@@ -78,7 +78,7 @@ public class OrientDBChatMessageDAO extends
@Override @Override
protected OQueryContextNative query( protected OQueryContextNative query(
OQueryContextNative record, QLogChat e) { OQueryContextNative record, QLogChat e) {
return record; return null;
} }
}); });
} }

View File

@@ -76,7 +76,7 @@ public class OrientDBClanDAO extends AbstractOrientDBDAO<Clan, ClanID> implement
@Override @Override
protected OQueryContextNative query( protected OQueryContextNative query(
OQueryContextNative record, QClan e) { OQueryContextNative record, QClan e) {
return record; return null;
} }
}); });
} }

View File

@@ -107,7 +107,7 @@ public class OrientDBItemDAO extends AbstractOrientDBDAO<Item, ItemID>
@Override @Override
protected OQueryContextNative query( protected OQueryContextNative query(
OQueryContextNative record, QItem e) { OQueryContextNative record, QItem e) {
return record; return null;
} }
}); });
} }

View File

@@ -102,7 +102,7 @@ public class OrientDBNPCDAO extends AbstractOrientDBDAO<NPC, NPCID> implements
@Override @Override
protected OQueryContextNative query(OQueryContextNative record, protected OQueryContextNative query(OQueryContextNative record,
QNPC e) { QNPC e) {
return record; return null;
} }
}); });
} }

View File

@@ -17,6 +17,7 @@
package com.l2jserver.service.game.character; package com.l2jserver.service.game.character;
import com.l2jserver.model.game.CharacterFriend; import com.l2jserver.model.game.CharacterFriend;
import com.l2jserver.model.id.AccountID;
import com.l2jserver.model.template.actor.ActorSex; import com.l2jserver.model.template.actor.ActorSex;
import com.l2jserver.model.template.character.CharacterClass; import com.l2jserver.model.template.character.CharacterClass;
import com.l2jserver.model.world.Actor; import com.l2jserver.model.world.Actor;
@@ -49,6 +50,8 @@ public interface CharacterService extends Service {
* *
* @param name * @param name
* The name of the new character * The name of the new character
* @param accountID
* the account ID to be used
* @param sex * @param sex
* The sex of the new character * The sex of the new character
* @param characterClass * @param characterClass
@@ -68,7 +71,7 @@ public interface CharacterService extends Service {
* @throws CharacterNameAlreadyExistsException * @throws CharacterNameAlreadyExistsException
* the character name is already being used * the character name is already being used
*/ */
L2Character create(String name, ActorSex sex, L2Character create(String name, AccountID accountID, ActorSex sex,
CharacterClass characterClass, CharacterHairStyle hairStyle, CharacterClass characterClass, CharacterHairStyle hairStyle,
CharacterHairColor hairColor, CharacterFace face) CharacterHairColor hairColor, CharacterFace face)
throws CharacterInvalidNameException, throws CharacterInvalidNameException,

View File

@@ -24,6 +24,7 @@ import com.google.inject.Inject;
import com.l2jserver.model.dao.CharacterDAO; import com.l2jserver.model.dao.CharacterDAO;
import com.l2jserver.model.dao.CharacterShortcutDAO; import com.l2jserver.model.dao.CharacterShortcutDAO;
import com.l2jserver.model.dao.ItemDAO; import com.l2jserver.model.dao.ItemDAO;
import com.l2jserver.model.id.AccountID;
import com.l2jserver.model.id.object.CharacterID; import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider; import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.template.CharacterTemplateID; import com.l2jserver.model.id.template.CharacterTemplateID;
@@ -169,7 +170,7 @@ public class CharacterServiceImpl extends AbstractService implements
} }
@Override @Override
public L2Character create(String name, ActorSex sex, public L2Character create(String name, AccountID accountID, ActorSex sex,
CharacterClass characterClass, CharacterHairStyle hairStyle, CharacterClass characterClass, CharacterHairStyle hairStyle,
CharacterHairColor hairColor, CharacterFace face) CharacterHairColor hairColor, CharacterFace face)
throws CharacterInvalidNameException, throws CharacterInvalidNameException,
@@ -212,8 +213,10 @@ public class CharacterServiceImpl extends AbstractService implements
// set parameters // set parameters
character.setID(id); character.setID(id);
character.setName(name); character.setName(name);
character.setAccountID(accountID);
character.setSex(sex); character.setSex(sex);
character.setPoint(Point3D.fromXYZA(146783, 25808, -2008, 0));
character.getAppearance().setHairStyle(hairStyle); character.getAppearance().setHairStyle(hairStyle);
character.getAppearance().setHairColor(hairColor); character.getAppearance().setHairColor(hairColor);

View File

@@ -122,7 +122,7 @@ public class CachedWorldIDService extends AbstractService implements
load(itemDao.selectIDs()); load(itemDao.selectIDs());
load(npcDao.selectIDs()); load(npcDao.selectIDs());
log.debug("IDs loaded from database"); log.info("{} IDs loaded from database");
loaded = true; loaded = true;
} }
@@ -140,7 +140,7 @@ public class CachedWorldIDService extends AbstractService implements
*/ */
private void load(Collection<? extends ObjectID<?>> ids) { private void load(Collection<? extends ObjectID<?>> ids) {
Preconditions.checkNotNull(ids, "ids"); Preconditions.checkNotNull(ids, "ids");
log.debug("Loading {} IDs", ids.size()); log.info("Loading {} IDs", ids.size());
for (final ObjectID<?> id : ids) { for (final ObjectID<?> id : ids) {
log.debug("Loading {}", id); log.debug("Loading {}", id);
allocator.allocate(id.getID()); allocator.allocate(id.getID());