From a544c681c77077432df2b41f85d0486472670af6 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 12 Feb 2015 22:09:17 -0600 Subject: [PATCH] Implement zone based gravity, required SQL DB change - To test `zone` table `gravity` values, change the value and use #zheader to test --- changelog.txt | 4 + common/version.h | 2 +- utils/sql/db_update_manifest.txt | 1 + zone/doors.cpp | 2 + zone/zone.cpp | 1 + zone/zonedb.cpp | 184 ++++++++++++++++++++----------- 6 files changed, 126 insertions(+), 68 deletions(-) diff --git a/changelog.txt b/changelog.txt index af5018313..f1ff71c90 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,9 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 02/12/2015 == +Akkadius: Implement zone based gravity, required SQL DB change + - To test `zone` table `gravity` values, change the value and use #zheader to test + == 02/11/2015 == Trevius: (RoF+) Bandolier no longer displays a Treasure Chest Icon when no Bandoliers are set. diff --git a/common/version.h b/common/version.h index 85dd86b46..7b8cfd78c 100644 --- a/common/version.h +++ b/common/version.h @@ -30,7 +30,7 @@ Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9076 +#define CURRENT_BINARY_DATABASE_VERSION 9077 #define COMPILE_DATE __DATE__ #define COMPILE_TIME __TIME__ #ifndef WIN32 diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index f23638a07..2ad0b647c 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -330,6 +330,7 @@ 9074|2015_02_01_logsys_packet_logs.sql|SELECT * FROM `logsys_categories` WHERE `log_category_description` LIKE 'Packet: Server -> Client'|empty| 9075|2015_02_02_logsys_packet_logs_with_dump.sql|SELECT * FROM `logsys_categories` WHERE `log_category_description` LIKE 'Packet: Server -> Client With Dump'|empty| 9076|2015_02_04_average_coin.sql|SHOW COLUMNS FROM `loottable` WHERE Field = 'avgcoin'|contains|smallint +9077|2015_02_12_zone_gravity.sql|SHOW COLUMNS FROM `zone` LIKE 'gravity'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/zone/doors.cpp b/zone/doors.cpp index cf08c509d..4bf2edbe3 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -655,6 +655,8 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name into[rowIndex].db_id = atoi(row[0]); into[rowIndex].door_id = atoi(row[1]); + Log.Out(Logs::Detail, Logs::Doors, "Door Load: db id: %u, door_id %u", into[rowIndex].db_id, into[rowIndex].door_id); + strn0cpy(into[rowIndex].zone_name,row[2],32); strn0cpy(into[rowIndex].door_name,row[3],32); diff --git a/zone/zone.cpp b/zone/zone.cpp index b8fb3c752..6cd81929f 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -735,6 +735,7 @@ void Zone::LoadZoneDoors(const char* zone, int16 version) for(r = 0; r < count; r++, d++) { Doors* newdoor = new Doors(d); entity_list.AddDoor(newdoor); + Log.Out(Logs::Detail, Logs::Doors, "Door Add to Entity List, index: %u db id: %u, door_id %u", r, dlist[r].db_id, dlist[r].door_id); } delete[] dlist; } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 4d815b192..b99024c5c 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -97,90 +97,140 @@ bool ZoneDatabase::GetZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct *map_filename = new char[100]; zone_data->zone_id = zoneid; - std::string query = StringFormat("SELECT ztype, fog_red, fog_green, fog_blue, fog_minclip, fog_maxclip, " // 5 - "fog_red2, fog_green2, fog_blue2, fog_minclip2, fog_maxclip2, " // 5 - "fog_red3, fog_green3, fog_blue3, fog_minclip3, fog_maxclip3, " // 5 - "fog_red4, fog_green4, fog_blue4, fog_minclip4, fog_maxclip4, " // 5 - "fog_density, sky, zone_exp_multiplier, safe_x, safe_y, safe_z, underworld, " // 7 - "minclip, maxclip, time_type, canbind, cancombat, canlevitate, " // 6 - "castoutdoor, hotzone, ruleset, suspendbuffs, map_file_name, short_name, " // 6 - "rain_chance1, rain_chance2, rain_chance3, rain_chance4, " // 4 - "rain_duration1, rain_duration2, rain_duration3, rain_duration4, " // 4 - "snow_chance1, snow_chance2, snow_chance3, snow_chance4, " // 4 - "snow_duration1, snow_duration2, snow_duration3, snow_duration4 " // 4 - "FROM zone WHERE zoneidnumber = %i AND version = %i", zoneid, instance_id); - auto results = QueryDatabase(query); - if (!results.Success()) { - strcpy(*map_filename, "default"); + std::string query = StringFormat( + "SELECT " + "ztype, " // 0 + "fog_red, " // 1 + "fog_green, " // 2 + "fog_blue, " // 3 + "fog_minclip, " // 4 + "fog_maxclip, " // 5 + "fog_red2, " // 6 + "fog_green2, " // 7 + "fog_blue2, " // 8 + "fog_minclip2, " // 9 + "fog_maxclip2, " // 10 + "fog_red3, " // 11 + "fog_green3, " // 12 + "fog_blue3, " // 13 + "fog_minclip3, " // 14 + "fog_maxclip3, " // 15 + "fog_red4, " // 16 + "fog_green4, " // 17 + "fog_blue4, " // 18 + "fog_minclip4, " // 19 + "fog_maxclip4, " // 20 + "fog_density, " // 21 + "sky, " // 22 + "zone_exp_multiplier, " // 23 + "safe_x, " // 24 + "safe_y, " // 25 + "safe_z, " // 26 + "underworld, " // 27 + "minclip, " // 28 + "maxclip, " // 29 + "time_type, " // 30 + "canbind, " // 31 + "cancombat, " // 32 + "canlevitate, " // 33 + "castoutdoor, " // 34 + "hotzone, " // 35 + "ruleset, " // 36 + "suspendbuffs, " // 37 + "map_file_name, " // 38 + "short_name, " // 39 + "rain_chance1, " // 40 + "rain_chance2, " // 41 + "rain_chance3, " // 42 + "rain_chance4, " // 43 + "rain_duration1, " // 44 + "rain_duration2, " // 45 + "rain_duration3, " // 46 + "rain_duration4, " // 47 + "snow_chance1, " // 48 + "snow_chance2, " // 49 + "snow_chance3, " // 50 + "snow_chance4, " // 51 + "snow_duration1, " // 52 + "snow_duration2, " // 53 + "snow_duration3, " // 54 + "snow_duration4, " // 55 + "gravity " // 56 + "FROM zone WHERE zoneidnumber = %i AND version = %i", + zoneid, instance_id); + auto results = QueryDatabase(query); + if (!results.Success()) { + strcpy(*map_filename, "default"); return false; - } + } if (results.RowCount() == 0) { - strcpy(*map_filename, "default"); - return false; - } + strcpy(*map_filename, "default"); + return false; + } - auto row = results.begin(); + auto row = results.begin(); - memset(zone_data, 0, sizeof(NewZone_Struct)); - zone_data->ztype = atoi(row[0]); - zone_type = zone_data->ztype; + memset(zone_data, 0, sizeof(NewZone_Struct)); + zone_data->ztype = atoi(row[0]); + zone_type = zone_data->ztype; - int index; - for(index = 0; index < 4; index++) { - zone_data->fog_red[index]=atoi(row[1 + index * 5]); - zone_data->fog_green[index]=atoi(row[2 + index * 5]); - zone_data->fog_blue[index]=atoi(row[3 + index * 5]); - zone_data->fog_minclip[index]=atof(row[4 + index * 5]); - zone_data->fog_maxclip[index]=atof(row[5 + index * 5]); - } + int index; + for (index = 0; index < 4; index++) { + zone_data->fog_red[index] = atoi(row[1 + index * 5]); + zone_data->fog_green[index] = atoi(row[2 + index * 5]); + zone_data->fog_blue[index] = atoi(row[3 + index * 5]); + zone_data->fog_minclip[index] = atof(row[4 + index * 5]); + zone_data->fog_maxclip[index] = atof(row[5 + index * 5]); + } - zone_data->fog_density = atof(row[21]); - zone_data->sky=atoi(row[22]); - zone_data->zone_exp_multiplier=atof(row[23]); - zone_data->safe_x=atof(row[24]); - zone_data->safe_y=atof(row[25]); - zone_data->safe_z=atof(row[26]); - zone_data->underworld=atof(row[27]); - zone_data->minclip=atof(row[28]); - zone_data->maxclip=atof(row[29]); - zone_data->time_type=atoi(row[30]); + zone_data->fog_density = atof(row[21]); + zone_data->sky = atoi(row[22]); + zone_data->zone_exp_multiplier = atof(row[23]); + zone_data->safe_x = atof(row[24]); + zone_data->safe_y = atof(row[25]); + zone_data->safe_z = atof(row[26]); + zone_data->underworld = atof(row[27]); + zone_data->minclip = atof(row[28]); + zone_data->maxclip = atof(row[29]); + zone_data->time_type = atoi(row[30]); - //not in the DB yet: - zone_data->gravity = 0.4; - allow_mercs = true; + //not in the DB yet: + zone_data->gravity = atof(row[56]); + Log.Out(Logs::General, Logs::Debug, "Zone Gravity is %f", zone_data->gravity); + allow_mercs = true; - int bindable = 0; - bindable = atoi(row[31]); + int bindable = 0; + bindable = atoi(row[31]); - can_bind = bindable == 0? false: true; - is_city = bindable == 2? true: false; - can_combat = atoi(row[32]) == 0? false: true; - can_levitate = atoi(row[33]) == 0? false: true; - can_castoutdoor = atoi(row[34]) == 0? false: true; - is_hotzone = atoi(row[35]) == 0? false: true; + can_bind = bindable == 0 ? false : true; + is_city = bindable == 2 ? true : false; + can_combat = atoi(row[32]) == 0 ? false : true; + can_levitate = atoi(row[33]) == 0 ? false : true; + can_castoutdoor = atoi(row[34]) == 0 ? false : true; + is_hotzone = atoi(row[35]) == 0 ? false : true; - ruleset = atoi(row[36]); - zone_data->SuspendBuffs = atoi(row[37]); + ruleset = atoi(row[36]); + zone_data->SuspendBuffs = atoi(row[37]); - char *file = row[38]; - if(file) - strcpy(*map_filename, file); - else - strcpy(*map_filename, row[39]); + char *file = row[38]; + if (file) + strcpy(*map_filename, file); + else + strcpy(*map_filename, row[39]); - for(index = 0; index < 4; index++) - zone_data->rain_chance[index]=atoi(row[40 + index]); + for (index = 0; index < 4; index++) + zone_data->rain_chance[index] = atoi(row[40 + index]); - for(index = 0; index < 4; index++) - zone_data->rain_duration[index]=atoi(row[44 + index]); + for (index = 0; index < 4; index++) + zone_data->rain_duration[index] = atoi(row[44 + index]); - for(index = 0; index < 4; index++) - zone_data->snow_chance[index]=atoi(row[48 + index]); + for (index = 0; index < 4; index++) + zone_data->snow_chance[index] = atoi(row[48 + index]); - for(index = 0; index < 4; index++) - zone_data->snow_duration[index]=atof(row[52 + index]); + for (index = 0; index < 4; index++) + zone_data->snow_duration[index] = atof(row[52 + index]); return true; }