From 5cda797531393f9b5d4a0f6ab03afd59cf924e82 Mon Sep 17 00:00:00 2001 From: af4t Date: Tue, 7 May 2013 15:19:27 -0400 Subject: [PATCH 1/6] VS2010 compatibility --- zone/npc.cpp | 19 +++++++++++++++++-- zone/zone.cpp | 17 +++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/zone/npc.cpp b/zone/npc.cpp index cc1aa8603..cc28aeab4 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -2432,12 +2432,20 @@ int NPC::GetScore() if(lv < 46) { - minx = ceil( ((lv - (lv / 10)) - 1) ); +#if _MSC_VER==1600 + minx = ceil((float) ((lv - (lv / 10)) - 1) ); +#else + minx = ceil( ((lv - (lv / 10)) - 1) ); +#endif basehp = (lv * 10) + (lv * lv); } else { - minx = ceil( ((lv - (lv / 10)) - 1) - (( abs(45 - lv) ) / 2) ); +#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 basehp = (lv * 10) + ((lv * lv) * 4); } @@ -2463,10 +2471,17 @@ 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); } } +#endif final = minx + hpcontrib + dmgcontrib + spccontrib; final = max(1, final); diff --git a/zone/zone.cpp b/zone/zone.cpp index 17271058f..028c5ef00 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2676,7 +2676,9 @@ void Zone::LoadTickItems() char* query = 0; MYSQL_RES *result; MYSQL_ROW row; - +#if _MSC_VER==1600 + item_tick_struct ti_tmp; +#endif tick_items.clear(); //tick_globals.clear(); @@ -2689,9 +2691,20 @@ void Zone::LoadTickItems() //tick_globals[std::string(row[0])] = { 0, atoi(row[1]), atoi(row[2]), (int16)atoi(row[4]), std::string(row[3]) }; } else - { +#if _MSC_VER==1600 + { + ti_tmp.itemid = atoi(row[0]); + ti_tmp.chance = atoi(row[1]); + ti_tmp.level = atoi(row[2]); + ti_tmp.bagslot = (int16)atoi(row[4]); + ti_tmp.qglobal = std::string(row[3]); + tick_items[atoi(row[0])] = ti_tmp; + } +#else + { tick_items[atoi(row[0])] = { atoi(row[0]), atoi(row[1]), atoi(row[2]), (int16)atoi(row[4]), std::string(row[3]) }; } +#endif } mysql_free_result(result); safe_delete_array(query); From 0838d4507a2f423bde4f2ceffcc809694196bde8 Mon Sep 17 00:00:00 2001 From: Michael Cook Date: Tue, 7 May 2013 17:41:05 -0400 Subject: [PATCH 2/6] Fix NULL to nullptr for SQL queries --- zone/client_packet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index d389cfcac..9724dec22 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -6129,7 +6129,7 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) " LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id=tre.recipe_id " " LEFT JOIN (SELECT recipe_id, madecount FROM char_recipe_list WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " " WHERE tr.id IN (%s) " - " AND tr.must_learn & 0x20 <> 0x20 AND ((tr.must_learn & 0x3 <> 0 AND crl.madecount IS NOT nullptr) OR (tr.must_learn & 0x3 = 0)) " + " AND tr.must_learn & 0x20 <> 0x20 AND ((tr.must_learn & 0x3 <> 0 AND crl.madecount IS NOT NULL) OR (tr.must_learn & 0x3 = 0)) " " GROUP BY tr.id " " HAVING sum(if(tre.item_id %s AND tre.iscontainer > 0,1,0)) > 0 " " LIMIT 100 ", CharacterID(), buf, containers); @@ -6184,7 +6184,7 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app) " LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id=tre.recipe_id " " LEFT JOIN (SELECT recipe_id, madecount FROM char_recipe_list WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " " WHERE %s tr.trivial >= %u AND tr.trivial <= %u " - " AND tr.must_learn & 0x20 <> 0x20 AND((tr.must_learn & 0x3 <> 0 AND crl.madecount IS NOT nullptr) OR (tr.must_learn & 0x3 = 0)) " + " AND tr.must_learn & 0x20 <> 0x20 AND((tr.must_learn & 0x3 <> 0 AND crl.madecount IS NOT NULL) OR (tr.must_learn & 0x3 = 0)) " " GROUP BY tr.id " " HAVING sum(if(tre.item_id %s AND tre.iscontainer > 0,1,0)) > 0 " " LIMIT 200 " From 059ecdb50b6373b1def84827efb09d8d45e9c7a6 Mon Sep 17 00:00:00 2001 From: Michael Cook Date: Tue, 7 May 2013 18:20:09 -0400 Subject: [PATCH 3/6] Fix NULL to nullptr for SQL queries take 2 --- common/database.cpp | 8 ++++---- zone/mob.cpp | 4 ++-- zone/questmgr.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index c03ad97cf..8960a58e0 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -428,7 +428,7 @@ bool Database::ReserveName(uint32 account_id, char* name) char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=nullptr", account_id, name), errbuf)) { + if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) { cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl; safe_delete_array(query); return false; @@ -1196,9 +1196,9 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe { cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << endl; cerr << "If it errors, run the following querys:\n"; - cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT nullptr;\n"; - cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT nullptr;\n"; - cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT nullptr DEFAULT '';\n"; + cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; + cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; + cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n"; safe_delete_array(query); } diff --git a/zone/mob.cpp b/zone/mob.cpp index 6529a505a..6782a8826 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3784,12 +3784,12 @@ void Mob::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varna char *query = 0; char errbuf[MYSQL_ERRMSG_SIZE]; - // Make duration string either "unix_timestamp(now()) + xxx" or "nullptr" + // Make duration string either "unix_timestamp(now()) + xxx" or "NULL" stringstream duration_ss; if (duration == INT_MAX) { - duration_ss << "nullptr"; + duration_ss << "NULL"; } else { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index bc7ac3f75..d29e99e87 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1241,11 +1241,11 @@ int QuestManager::InsertQuestGlobal( char *query = 0; char errbuf[MYSQL_ERRMSG_SIZE]; - // Make duration string either "unix_timestamp(now()) + xxx" or "nullptr" + // Make duration string either "unix_timestamp(now()) + xxx" or "NULL" stringstream duration_ss; if (duration == INT_MAX) { - duration_ss << "nullptr"; + duration_ss << "NULL"; } else { From 21a9434f89e3e5a9856024c92be9bf730ffb7d45 Mon Sep 17 00:00:00 2001 From: Derision Date: Wed, 8 May 2013 20:02:55 +0100 Subject: [PATCH 4/6] 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 5/6] 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; } From 7a9396615858264f1f18538f7d520dc559128ddf Mon Sep 17 00:00:00 2001 From: KimLS Date: Wed, 8 May 2013 21:03:35 -0700 Subject: [PATCH 6/6] VS2012 fix + return 0 fix --- zone/zone.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 028c5ef00..146da03c6 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2676,23 +2676,15 @@ void Zone::LoadTickItems() char* query = 0; MYSQL_RES *result; MYSQL_ROW row; -#if _MSC_VER==1600 - item_tick_struct ti_tmp; -#endif tick_items.clear(); - //tick_globals.clear(); if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT it_itemid, it_chance, it_level, it_qglobal, it_bagslot FROM item_tick"), errbuf, &result)) { while((row = mysql_fetch_row(result))) { - if(atoi(row[0]) < 1) - { - //tick_globals[std::string(row[0])] = { 0, atoi(row[1]), atoi(row[2]), (int16)atoi(row[4]), std::string(row[3]) }; - } - else -#if _MSC_VER==1600 + if(atoi(row[0]) >= 1) { + item_tick_struct ti_tmp; ti_tmp.itemid = atoi(row[0]); ti_tmp.chance = atoi(row[1]); ti_tmp.level = atoi(row[2]); @@ -2700,11 +2692,6 @@ void Zone::LoadTickItems() ti_tmp.qglobal = std::string(row[3]); tick_items[atoi(row[0])] = ti_tmp; } -#else - { - tick_items[atoi(row[0])] = { atoi(row[0]), atoi(row[1]), atoi(row[2]), (int16)atoi(row[4]), std::string(row[3]) }; - } -#endif } mysql_free_result(result); safe_delete_array(query); @@ -2728,6 +2715,7 @@ uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) { } iterator.Advance(); } + return 0; } void Zone::UpdateHotzone()