Added text link translators for OP_TaskDescription (RoF+ -- all clients current)

This commit is contained in:
Uleat 2015-01-12 14:35:38 -05:00
parent 51fe41bf51
commit d5b24543e8
8 changed files with 109 additions and 22 deletions

View File

@ -2,6 +2,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 01/12/2015 ==
Uleat: Fix for OP_FormattedMessage text link server crashes
Uleat: Added text link translators for OP_TaskDescription (RoF+ -- all clients current)
== 01/11/2015 ==
Uleat: Added text link translators for OP_TaskDescription (Ti thru UF..RoF+ in-work)

View File

@ -3249,16 +3249,55 @@ namespace RoF
EQApplicationPacket *in = *p;
*p = nullptr;
unsigned char *__emu_buffer = in->pBuffer;
char *InBuffer = (char *)in->pBuffer;
char *block_start = InBuffer;
InBuffer += sizeof(TaskDescriptionHeader_Struct);
uint32 title_size = strlen(InBuffer) + 1;
InBuffer += title_size;
TaskDescriptionData1_Struct *emu_tdd1 = (TaskDescriptionData1_Struct *)InBuffer;
emu_tdd1->StartTime = (time(nullptr) - emu_tdd1->StartTime); // RoF has elapsed time here rather than start time
InBuffer += sizeof(TaskDescriptionData1_Struct);
uint32 description_size = strlen(InBuffer) + 1;
InBuffer += description_size;
InBuffer += sizeof(TaskDescriptionData2_Struct);
std::string old_message = InBuffer; // start 'Reward' as string
std::string new_message;
ServerToRoFTextLink(new_message, old_message);
in->size = sizeof(TaskDescriptionHeader_Struct) + sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct) + sizeof(TaskDescriptionTrailer_Struct)+
title_size + description_size + new_message.length() + 1;
in->pBuffer = new unsigned char[in->size];
char *OutBuffer = (char *)in->pBuffer;
memcpy(OutBuffer, block_start, (InBuffer - block_start));
OutBuffer += (InBuffer - block_start);
VARSTRUCT_ENCODE_STRING(OutBuffer, new_message.c_str());
InBuffer += strlen(InBuffer) + 1;
memcpy(OutBuffer, InBuffer, sizeof(TaskDescriptionTrailer_Struct));
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
#if 0 // original code
EQApplicationPacket *in = *p;
*p = nullptr;
EQApplicationPacket *outapp = new EQApplicationPacket(OP_TaskDescription, in->size + 1);
// Set the Write pointer as we don't know what has been done with the packet before we get it.
in->SetReadPosition(0);
// Copy the header
//
// Server header struct is { uint32; uint32; uint32; uint32; uint8; }
// Yet, we're writing 5 uint32's... that's 17 vs 20 bytes...
// 3 Bytes difference..but, we only increase packet size by 1 byte..something wrong here? -U
// (Tying to add text link translators and can't figure out if '+1' size is a new RoF field or something else)
//
for (int i = 0; i < 5; ++i)
outapp->WriteUInt32(in->ReadUInt32());
@ -3278,6 +3317,7 @@ namespace RoF
delete in;
dest->FastQueuePacket(&outapp, ack_req);
#endif
}
ENCODE(OP_TaskHistoryReply)

View File

@ -3315,6 +3315,51 @@ namespace RoF2
EQApplicationPacket *in = *p;
*p = nullptr;
unsigned char *__emu_buffer = in->pBuffer;
char *InBuffer = (char *)in->pBuffer;
char *block_start = InBuffer;
InBuffer += sizeof(TaskDescriptionHeader_Struct);
uint32 title_size = strlen(InBuffer) + 1;
InBuffer += title_size;
TaskDescriptionData1_Struct *emu_tdd1 = (TaskDescriptionData1_Struct *)InBuffer;
emu_tdd1->StartTime = (time(nullptr) - emu_tdd1->StartTime); // RoF2 has elapsed time here rather than start time
InBuffer += sizeof(TaskDescriptionData1_Struct);
uint32 description_size = strlen(InBuffer) + 1;
InBuffer += description_size;
InBuffer += sizeof(TaskDescriptionData2_Struct);
std::string old_message = InBuffer; // start 'Reward' as string
std::string new_message;
ServerToRoF2TextLink(new_message, old_message);
in->size = sizeof(TaskDescriptionHeader_Struct) + sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct) + sizeof(TaskDescriptionTrailer_Struct)+
title_size + description_size + new_message.length() + 1;
in->pBuffer = new unsigned char[in->size];
char *OutBuffer = (char *)in->pBuffer;
memcpy(OutBuffer, block_start, (InBuffer - block_start));
OutBuffer += (InBuffer - block_start);
VARSTRUCT_ENCODE_STRING(OutBuffer, new_message.c_str());
InBuffer += strlen(InBuffer) + 1;
memcpy(OutBuffer, InBuffer, sizeof(TaskDescriptionTrailer_Struct));
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
#if 0 // original code
EQApplicationPacket *in = *p;
*p = nullptr;
EQApplicationPacket *outapp = new EQApplicationPacket(OP_TaskDescription, in->size + 1);
// Set the Write pointer as we don't know what has been done with the packet before we get it.
in->SetReadPosition(0);
@ -3338,6 +3383,7 @@ namespace RoF2
delete in;
dest->FastQueuePacket(&outapp, ack_req);
#endif
}
ENCODE(OP_TaskHistoryReply)

View File

@ -2201,15 +2201,15 @@ namespace SoD
std::string new_message;
ServerToSoDTextLink(new_message, old_message);
in->size = sizeof(TaskDescriptionHeader_Struct)+sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct)+sizeof(TaskDescriptionTrailer_Struct)+
in->size = sizeof(TaskDescriptionHeader_Struct) + sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct) + sizeof(TaskDescriptionTrailer_Struct)+
title_size + description_size + new_message.length() + 1;
in->pBuffer = new unsigned char[in->size];
char *OutBuffer = (char *)in->pBuffer;
memcpy(OutBuffer, (char *)__emu_buffer, (InBuffer - block_start));
memcpy(OutBuffer, block_start, (InBuffer - block_start));
OutBuffer += (InBuffer - block_start);
VARSTRUCT_ENCODE_STRING(OutBuffer, new_message.c_str());

View File

@ -1800,15 +1800,15 @@ namespace SoF
std::string new_message;
ServerToSoFTextLink(new_message, old_message);
in->size = sizeof(TaskDescriptionHeader_Struct)+sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct)+sizeof(TaskDescriptionTrailer_Struct)+
in->size = sizeof(TaskDescriptionHeader_Struct) + sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct) + sizeof(TaskDescriptionTrailer_Struct)+
title_size + description_size + new_message.length() + 1;
in->pBuffer = new unsigned char[in->size];
char *OutBuffer = (char *)in->pBuffer;
memcpy(OutBuffer, (char *)__emu_buffer, (InBuffer - block_start));
memcpy(OutBuffer, block_start, (InBuffer - block_start));
OutBuffer += (InBuffer - block_start);
VARSTRUCT_ENCODE_STRING(OutBuffer, new_message.c_str());

View File

@ -1258,7 +1258,7 @@ namespace Titanium
char *OutBuffer = (char *)in->pBuffer;
memcpy(OutBuffer, (char *)__emu_buffer, (InBuffer - block_start));
memcpy(OutBuffer, block_start, (InBuffer - block_start));
OutBuffer += (InBuffer - block_start);
VARSTRUCT_ENCODE_STRING(OutBuffer, new_message.c_str());

View File

@ -2467,15 +2467,15 @@ namespace Underfoot
std::string new_message;
ServerToUnderfootTextLink(new_message, old_message);
in->size = sizeof(TaskDescriptionHeader_Struct)+sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct)+sizeof(TaskDescriptionTrailer_Struct)+
in->size = sizeof(TaskDescriptionHeader_Struct) + sizeof(TaskDescriptionData1_Struct)+
sizeof(TaskDescriptionData2_Struct) + sizeof(TaskDescriptionTrailer_Struct)+
title_size + description_size + new_message.length() + 1;
in->pBuffer = new unsigned char[in->size];
char *OutBuffer = (char *)in->pBuffer;
memcpy(OutBuffer, (char *)__emu_buffer, (InBuffer - block_start));
memcpy(OutBuffer, block_start, (InBuffer - block_start));
OutBuffer += (InBuffer - block_start);
VARSTRUCT_ENCODE_STRING(OutBuffer, new_message.c_str());

View File

@ -2756,7 +2756,7 @@ void TaskManager::SendActiveTaskDescription(Client *c, int TaskID, int SequenceN
+ sizeof(TaskDescriptionData1_Struct) + strlen(Tasks[TaskID]->Description) + 1
+ sizeof(TaskDescriptionData2_Struct) + 1 + sizeof(TaskDescriptionTrailer_Struct);
std::string RewardText;
std::string reward_text;
int ItemID = NOT_USED;
// If there is an item make the Reward text into a link to the item (only the first item if a list
@ -2784,17 +2784,17 @@ void TaskManager::SendActiveTaskDescription(Client *c, int TaskID, int SequenceN
linker.SetProxyText(Tasks[TaskID]->Reward);
auto reward_link = linker.GenerateLink();
RewardText += reward_link.c_str();
reward_text.append(reward_link);
}
else {
RewardText += Tasks[TaskID]->Reward;
reward_text.append(Tasks[TaskID]->Reward);
}
}
else {
RewardText += Tasks[TaskID]->Reward;
reward_text.append(Tasks[TaskID]->Reward);
}
PacketLength += strlen(RewardText.c_str()) + 1;
PacketLength += reward_text.length() + 1;
char *Ptr;
TaskDescriptionHeader_Struct* tdh;
@ -2850,7 +2850,7 @@ void TaskManager::SendActiveTaskDescription(Client *c, int TaskID, int SequenceN
tdd2->unknown3 = 0x0000;
Ptr = (char *) tdd2 + sizeof(TaskDescriptionData2_Struct);
sprintf(Ptr, "%s", RewardText.c_str());
sprintf(Ptr, "%s", reward_text.c_str());
Ptr = Ptr + strlen(Ptr) + 1;
tdt = (TaskDescriptionTrailer_Struct*)Ptr;