Code Directions
Add Zoneobject.cpp and ZoneObject.h to your project.
Add the following line to Client::Process() inside the if (Connected()) block:
zone->CheckZoneObjects();
Modify the case CLIENT_CONNECTING4: { in client_process.cpp block to look like the following:
if (app->opcode == 0x0a20)
{
cout << "Login packet 4" << endl;
APPLAYER* outapp;
ZoneObject_Struct *zos;
ZoneObject_Struct *dzos;
int numzoneobjects,deflatedsize;
numzoneobjects=zone->GetZoneObjects(zos);
if(numzoneobjects>0)
{
dzos=new ZoneObject_Struct[numzoneobjects];
deflatedsize=DeflatePacket((unsigned char*)(zos), sizeof(ZoneObject_Struct)*numzoneobjects, (unsigned char*)(dzos), sizeof(ZoneObject_Struct)*numzoneobjects);
delete zos;
outapp = new APPLAYER;
outapp->pBuffer = new uchar[deflatedsize+2];
outapp->opcode = 0xf721;
*(int16 *)(outapp->pBuffer)=numzoneobjects;
memcpy((outapp->pBuffer)+2, dzos, deflatedsize);
outapp->size = deflatedsize+2;
packet_manager.MakeEQPacket(outapp);
delete outapp;
delete dzos;
}
outapp = new APPLAYER;
outapp->opcode = 0xd820; // Unknown
outapp->size = 0;
QueuePacket(outapp);
delete outapp;
client_state = CLIENT_CONNECTING5;
break;
}
}
Add the following case to the switch(app->opcode) block that is within the case CLIENT_CONNECTED in client_process.cpp
case OP_ZoneObjectOpenRequest: {
APPLAYER *outapp;
ZoneObjectOpen_Struct *zoos = (ZoneObjectOpen_Struct *)app->pBuffer;
ZoneObject *zo=zone->GetZoneObject(zoos->zoneobject_id);
cout << "zoneobjectid=" << int(zo->GetZoneObjectID()) << " initialstate=" << int(zo->zoneobjectstruct.initialstate) << " item=" << uint32(zoos->item_nr) << endl;
if(zo && zo->zoneobjectstruct.initialstate) // check if open
{
cout << "closing zone object" << endl;
outapp = new APPLAYER;
outapp->opcode=OP_ZoneObjectOpen;
outapp->size=2;
outapp->pBuffer=new uchar[outapp->size];
outapp->pBuffer[0]=zoos->zoneobject_id;
outapp->pBuffer[1]=0x03; // seems to say 'close'
entity_list.QueueCloseClients(this,outapp,true); // tell other clients
packet_manager.MakeEQPacket(outapp); // tell client who closed the object
delete outapp;
zo->zoneobjectstruct.initialstate=0;
zone->CloseZoneObject(zoos->zoneobject_id);
}
else if(zo && (zoos->item_nr==0xffff || zo->GetKeyNumber()==zoos->item_nr || zoos->item_nr==0x0000))
{
cout << "opening zone object" << endl;
outapp = new APPLAYER;
outapp->opcode=OP_ZoneObjectOpen;
outapp->size=2;
outapp->pBuffer=new uchar[outapp->size];
outapp->pBuffer[0]=zoos->zoneobject_id;
outapp->pBuffer[1]=0x02; // seems to say 'open'
if(zoos->item_nr==0x0000)
{
cout << "auto close request?" << endl;
outapp->pBuffer[1]=0x03;
}
entity_list.QueueCloseClients(this,outapp,true); // tell other clients
packet_manager.MakeEQPacket(outapp); // tell client who opened the door
delete outapp;
zo->zoneobjectstruct.initialstate=1;
zone->AddOpenedZoneObject(zoos->zoneobject_id, zo->opentimer);
}
else if(zo)
{
Message(13, "It's locked and you're not holding the key.");
break;
}
if(zo)
{
uint32 triggerid=zo->trigger_id;
if(triggerid!=65535)
{
ZoneObject *tzo=zone->GetZoneObject(triggerid);
if(tzo && tzo->zoneobjectstruct.initialstate && !zone->GetZoneObjectStatus(triggerid)) // check if open
{
cout << "closing triggered object:" << triggerid << endl;
outapp = new APPLAYER;
outapp->opcode=OP_ZoneObjectOpen;
outapp->size=2;
outapp->pBuffer=new uchar[outapp->size];
outapp->pBuffer[0]=triggerid;
outapp->pBuffer[1]=0x03; // seems to say 'close'
entity_list.QueueCloseClients(this,outapp,true); // tell other clients
packet_manager.MakeEQPacket(outapp); // tell client who closed the object
delete outapp;
tzo->zoneobjectstruct.initialstate=0;
zone->AddOpenedZoneObject(triggerid, tzo->opentimer);
}
else if(tzo && !zone->GetZoneObjectStatus(triggerid))
{
cout << "opening triggered object:" << triggerid << endl;
outapp = new APPLAYER;
outapp->opcode=OP_ZoneObjectOpen;
outapp->size=2;
outapp->pBuffer=new uchar[outapp->size];
outapp->pBuffer[0]=triggerid;
outapp->pBuffer[1]=0x02; // seems to say 'open'
entity_list.QueueCloseClients(this,outapp,true); // tell other clients
packet_manager.MakeEQPacket(outapp); // tell client who opened the door
delete outapp;
tzo->zoneobjectstruct.initialstate=1;
zone->AddOpenedZoneObject(triggerid, tzo->opentimer);
}
}
}
break;
}
|