From 21a9434f89e3e5a9856024c92be9bf730ffb7d45 Mon Sep 17 00:00:00 2001 From: Derision Date: Wed, 8 May 2013 20:02:55 +0100 Subject: [PATCH 1/2] Changed dummy strings written into the TaskSelector packet from nullptr to ABCD since the packet size calculation was based on the strings being 4 characters long. --- zone/tasks.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/tasks.cpp b/zone/tasks.cpp index dcd3aad57..34b64c1db 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -1158,7 +1158,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task if(Tasks[TaskList[i]] != nullptr) break; } - // FIXME: The 10 and 5 values in this calculation are to account for the string "nullptr" we are putting in 3 times. + // FIXME: The 10 and 5 values in this calculation are to account for the string "ABCD" we are putting in 3 times. // // Calculate how big the packet needs to be pased on the number of tasks and the // size of the variable length strings. @@ -1236,9 +1236,9 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task // FIXME: In live packets, these two strings appear to be the same as the Text1 and Text2 // strings from the first activity in the task, however the task chooser/selector // does not appear to make use of them. - sprintf(Ptr, "nullptr"); + sprintf(Ptr, "ABCD"); Ptr = Ptr + strlen(Ptr) + 1; - sprintf(Ptr, "nullptr"); + sprintf(Ptr, "ABCD"); Ptr = Ptr + strlen(Ptr) + 1; AvailableTaskTrailer = (AvailableTaskTrailer_Struct*)Ptr; @@ -1253,7 +1253,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task // In some packets, this next string looks like a short task summary, however it doesn't // appear anywhere in the client window. - sprintf(Ptr, "nullptr"); + sprintf(Ptr, "ABCD"); Ptr = Ptr + strlen(Ptr) + 1; } From f6100ed83406dcef6ea2c6166acef1654883e9a8 Mon Sep 17 00:00:00 2001 From: mackal Date: Wed, 8 May 2013 17:07:49 -0400 Subject: [PATCH 2/2] Fixed NPC::GetScore and XS_NPC_GetScore --- zone/npc.cpp | 29 ++++++++--------------------- zone/perl_npc.cpp | 2 +- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/zone/npc.cpp b/zone/npc.cpp index cc28aeab4..afba99199 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -2432,31 +2432,23 @@ int NPC::GetScore() if(lv < 46) { -#if _MSC_VER==1600 - minx = ceil((float) ((lv - (lv / 10)) - 1) ); -#else - minx = ceil( ((lv - (lv / 10)) - 1) ); -#endif + minx = static_cast (ceil( ((lv - (lv / 10.0)) - 1.0) )); basehp = (lv * 10) + (lv * lv); } else { -#if _MSC_VER==1600 - minx = ceil((float) ((lv - (lv / 10)) - 1) - (( abs(45 - lv) ) / 2) ); -#else - minx = ceil( ((lv - (lv / 10)) - 1) - (( abs(45 - lv) ) / 2) ); -#endif + minx = static_cast (ceil( ((lv - (lv / 10.0)) - 1.0) - (( lv - 45.0 ) / 2.0) )); basehp = (lv * 10) + ((lv * lv) * 4); } if(hp > basehp) { - hpcontrib = (int)( (float)((float)hp / (float)basehp) * 1.5); + hpcontrib = static_cast (((hp / static_cast (basehp)) * 1.5)); if(hpcontrib > 5) { hpcontrib = 5; } if(maxdmg > basedmg) { - dmgcontrib = ceil( ((maxdmg / basedmg) * 1.5) ); + dmgcontrib = static_cast (ceil( ((maxdmg / basedmg) * 1.5) )); } if(HasNPCSpecialAtk("E")) { spccontrib++; } //Enrage @@ -2471,17 +2463,12 @@ int NPC::GetScore() } if(npc_spells_id > 12) -#if _MSC_VER==1600 - { - if(lv < 16) { spccontrib++; } - else { spccontrib += (int)floor((float) lv/15); } - } -#else { - if(lv < 16) { spccontrib++; } - else { spccontrib += (int)floor(lv/15); } + if(lv < 16) + spccontrib++; + else + spccontrib += static_cast (floor(lv/15.0)); } -#endif final = minx + hpcontrib + dmgcontrib + spccontrib; final = max(1, final); diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index b0eb0ce1a..3888c05ea 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -2236,7 +2236,7 @@ XS(boot_NPC) newXSproto(strcpy(buf, "GetAttackSpeed"), XS_NPC_GetSlowMitigation, file, "$"); newXSproto(strcpy(buf, "GetAccuracyRating"), XS_NPC_GetAccuracyRating, file, "$"); newXSproto(strcpy(buf, "GetSpawnKillCount"), XS_NPC_GetSpawnKillCount, file, "$"); - newXSproto(strcpy(buf, "GetScore"), XS_NPC_GetSpawnKillCount, file, "$"); + newXSproto(strcpy(buf, "GetScore"), XS_NPC_GetScore, file, "$"); XSRETURN_YES; }