mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-12 02:13:48 -04:00
Started work on groups, fixed trading
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
if actor and target:
|
||||
core.groupService.handleGroupInvite(actor, target)
|
||||
return
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.group;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
|
||||
public class GroupMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
public GroupMessageBuilder(GroupObject groupObject) {
|
||||
setObject(groupObject);
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline3() {
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putShort((short) 4); // Obj Operand Count
|
||||
buffer.putFloat(1); // Complexity
|
||||
|
||||
buffer.put(getAsciiString("string_id_table"));
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putShort((short) 0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.put((byte) 0);
|
||||
|
||||
int size = buffer.position();
|
||||
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("GRUP", (byte) 3, buffer, size);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline6() {
|
||||
|
||||
GroupObject group = (GroupObject) object;
|
||||
IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putShort((short) 0x0B); // Obj Operand Count
|
||||
buffer.putInt(0x45);
|
||||
|
||||
buffer.put(getAsciiString("string_id_table"));
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putShort((short) 0);
|
||||
|
||||
buffer.putInt(group.getMemberList().size());
|
||||
buffer.putInt(group.getMemberListUpdateCounter());
|
||||
|
||||
synchronized(group.getMemberList().getMutex()) {
|
||||
for(SWGObject obj : group.getMemberList().get()) {
|
||||
buffer.putLong(obj.getObjectID());
|
||||
buffer.put(getAsciiString(obj.getCustomName()));
|
||||
}
|
||||
}
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(1);
|
||||
buffer.putShort((short) 0);
|
||||
buffer.putShort((short) 0x5A);
|
||||
buffer.putInt(0);
|
||||
buffer.putLong(group.getGroupLeader().getObjectID());
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
|
||||
int size = buffer.position();
|
||||
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("GRUP", (byte) 6, buffer, size);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildAddMemberDelta(SWGObject member) {
|
||||
|
||||
GroupObject group = (GroupObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(group.getMemberListUpdateCounter());
|
||||
|
||||
buffer.put((byte) 1);
|
||||
buffer.putShort((short) group.getMemberList().indexOf(member));
|
||||
buffer.putLong(member.getObjectID());
|
||||
buffer.put(getAsciiString(member.getCustomName()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
return buffer = createDelta("GRUP", (byte) 6, (short) 1, (short) 2, buffer, size + 4);
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildRemoveMemberDelta(SWGObject member) {
|
||||
|
||||
GroupObject group = (GroupObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(group.getMemberListUpdateCounter());
|
||||
|
||||
buffer.put((byte) 0);
|
||||
buffer.putShort((short) group.getMemberList().indexOf(member));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
return buffer = createDelta("GRUP", (byte) 6, (short) 1, (short) 2, buffer, size + 4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,8 +21,9 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.group;
|
||||
|
||||
import java.util.Vector;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.objects.SWGList;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -31,18 +32,20 @@ import engine.resources.scene.Quaternion;
|
||||
|
||||
public class GroupObject extends SWGObject {
|
||||
|
||||
private Vector<SWGObject> memberList = new Vector<SWGObject>();
|
||||
private SWGList<SWGObject> memberList = new SWGList<SWGObject>();
|
||||
private int memberListUpdateCounter;
|
||||
private SWGObject groupLeader;
|
||||
private SWGObject lootMaster;
|
||||
private short groupLevel;
|
||||
private int lootMode;
|
||||
private GroupMessageBuilder messageBuilder;
|
||||
|
||||
public GroupObject(long objectId) {
|
||||
super(objectId, null, new Point3D(0, 0, 0), new Quaternion(0, 0, 0, 1), "object/group/shared_group_object.iff");
|
||||
messageBuilder = new GroupMessageBuilder(this);
|
||||
}
|
||||
|
||||
public Vector<SWGObject> getMemberList() {
|
||||
public SWGList<SWGObject> getMemberList() {
|
||||
return memberList;
|
||||
}
|
||||
|
||||
@@ -105,10 +108,52 @@ public class GroupObject extends SWGObject {
|
||||
this.lootMode = lootMode;
|
||||
}
|
||||
}
|
||||
|
||||
public void addMember(SWGObject member) {
|
||||
|
||||
if(memberList.size() >= 8 || member.getClient() == null)
|
||||
return;
|
||||
|
||||
memberList.add(member);
|
||||
|
||||
setMemberListUpdateCounter(getMemberListUpdateCounter() + 1);
|
||||
IoBuffer packet = messageBuilder.buildAddMemberDelta(member);
|
||||
synchronized(memberList.getMutex()) {
|
||||
for(SWGObject obj : memberList.get()) {
|
||||
obj.getClient().getSession().write(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeMember(SWGObject member) {
|
||||
|
||||
if(memberList.size() <= 0 || member.getClient() == null)
|
||||
return;
|
||||
|
||||
setMemberListUpdateCounter(getMemberListUpdateCounter() + 1);
|
||||
IoBuffer packet = messageBuilder.buildRemoveMemberDelta(member);
|
||||
synchronized(memberList.getMutex()) {
|
||||
for(SWGObject obj : memberList.get()) {
|
||||
obj.getClient().getSession().write(packet);
|
||||
}
|
||||
}
|
||||
|
||||
memberList.remove(member);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client client) {
|
||||
// TODO Auto-generated method stub
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
if(destination == null || destination.getSession() == null) {
|
||||
System.out.println("NULL session");
|
||||
return;
|
||||
}
|
||||
|
||||
destination.getSession().write(messageBuilder.buildBaseline3());
|
||||
destination.getSession().write(messageBuilder.buildBaseline6());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package services;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
public class GroupService implements INetworkDispatch {
|
||||
|
||||
private NGECore core;
|
||||
|
||||
public GroupService(NGECore core) {
|
||||
this.core = core;
|
||||
core.commandService.registerCommand("invite");
|
||||
core.commandService.registerCommand("join");
|
||||
core.commandService.registerCommand("disband");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> swgOpcodes, Map<Integer, INetworkRemoteEvent> objControllerOpcodes) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
}
|
||||
|
||||
public void handleGroupInvite(CreatureObject inviter, CreatureObject invited) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -370,7 +370,12 @@ public class TradeService implements INetworkDispatch{
|
||||
{
|
||||
cleanTradeSession(client, tradePartner.getClient());
|
||||
}
|
||||
actingTraderInventory.transferTo(tradePartner, tradePartnerInventory, tradeObject);
|
||||
//actingTraderInventory.transferTo(tradePartner, tradePartnerInventory, tradeObject);
|
||||
|
||||
actingTraderInventory._remove(tradeObject);
|
||||
actingTrader.makeUnaware(tradeObject);
|
||||
tradePartnerInventory.add(tradeObject);
|
||||
|
||||
itr.remove();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user