mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 20:51:29 +00:00
GetStartZoneSoF converted to QueryDatabase
This commit is contained in:
parent
b3789c261b
commit
7f5f805c10
@ -359,7 +359,6 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct*
|
|||||||
|
|
||||||
bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc)
|
bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc)
|
||||||
{
|
{
|
||||||
|
|
||||||
// SoF doesn't send the player_choice field in character creation, it now sends the real zoneID instead.
|
// SoF doesn't send the player_choice field in character creation, it now sends the real zoneID instead.
|
||||||
//
|
//
|
||||||
// For SoF, search for an entry in start_zones with a matching zone_id, class, race and deity.
|
// For SoF, search for an entry in start_zones with a matching zone_id, class, race and deity.
|
||||||
@ -367,53 +366,25 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
|||||||
// For now, if no row matching row is found, send them to Crescent Reach, as that is probably the most likely
|
// For now, if no row matching row is found, send them to Crescent Reach, as that is probably the most likely
|
||||||
// reason for no match being found.
|
// reason for no match being found.
|
||||||
//
|
//
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row = 0;
|
|
||||||
int rows;
|
|
||||||
|
|
||||||
if(!in_pp || !in_cc)
|
if(!in_pp || !in_cc)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0;
|
in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0;
|
||||||
in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = 0;
|
in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = 0;
|
||||||
|
|
||||||
if(!RunQuery(query, MakeAnyLenString(&query, "SELECT x, y, z, heading, bind_id "
|
std::string query = StringFormat("SELECT x, y, z, heading, bind_id FROM start_zones WHERE zone_id = %i "
|
||||||
" FROM start_zones "
|
"AND player_class = %i AND player_deity = %i AND player_race = %i",
|
||||||
" WHERE zone_id = %i "
|
in_cc->start_zone, in_cc->class_, in_cc->deity, in_cc->race);
|
||||||
" AND player_class = %i "
|
auto results = QueryDatabase(query);
|
||||||
" AND player_deity = %i"
|
if(!results.Success()) {
|
||||||
" AND player_race = %i",
|
LogFile->write(EQEMuLog::Status, "SoF Start zone query failed: %s : %s\n", query.c_str(), results.ErrorMessage().c_str());
|
||||||
in_cc->start_zone,
|
|
||||||
in_cc->class_,
|
|
||||||
in_cc->deity,
|
|
||||||
in_cc->race), errbuf, &result))
|
|
||||||
{
|
|
||||||
LogFile->write(EQEMuLog::Status, "SoF Start zone query failed: %s : %s\n", query, errbuf);
|
|
||||||
safe_delete_array(query);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Status, "SoF Start zone query: %s\n", query);
|
LogFile->write(EQEMuLog::Status, "SoF Start zone query: %s\n", query.c_str());
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
if((rows = mysql_num_rows(result)) > 0)
|
if (results.RowCount() == 0) {
|
||||||
row = mysql_fetch_row(result);
|
printf("No start_zones entry in database, using defaults\n");
|
||||||
|
|
||||||
if(row)
|
|
||||||
{
|
|
||||||
LogFile->write(EQEMuLog::Status, "Found starting location in start_zones");
|
|
||||||
in_pp->x = atof(row[0]);
|
|
||||||
in_pp->y = atof(row[1]);
|
|
||||||
in_pp->z = atof(row[2]);
|
|
||||||
in_pp->heading = atof(row[3]);
|
|
||||||
in_pp->zone_id = in_cc->start_zone;
|
|
||||||
in_pp->binds[0].zoneId = atoi(row[4]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("No start_zones entry in database, using defaults\n");
|
|
||||||
|
|
||||||
if(in_cc->start_zone == RuleI(World, TutorialZoneID))
|
if(in_cc->start_zone == RuleI(World, TutorialZoneID))
|
||||||
in_pp->zone_id = in_cc->start_zone;
|
in_pp->zone_id = in_cc->start_zone;
|
||||||
@ -423,7 +394,16 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
|||||||
in_pp->z = in_pp->binds[0].z = 0.79;
|
in_pp->z = in_pp->binds[0].z = 0.79;
|
||||||
in_pp->zone_id = in_pp->binds[0].zoneId = 394; // Crescent Reach.
|
in_pp->zone_id = in_pp->binds[0].zoneId = 394; // Crescent Reach.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LogFile->write(EQEMuLog::Status, "Found starting location in start_zones");
|
||||||
|
auto row = results.begin();
|
||||||
|
in_pp->x = atof(row[0]);
|
||||||
|
in_pp->y = atof(row[1]);
|
||||||
|
in_pp->z = atof(row[2]);
|
||||||
|
in_pp->heading = atof(row[3]);
|
||||||
|
in_pp->zone_id = in_cc->start_zone;
|
||||||
|
in_pp->binds[0].zoneId = atoi(row[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_pp->x == 0 && in_pp->y == 0 && in_pp->z == 0)
|
if(in_pp->x == 0 && in_pp->y == 0 && in_pp->z == 0)
|
||||||
@ -431,8 +411,7 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
|||||||
|
|
||||||
if(in_pp->binds[0].x == 0 && in_pp->binds[0].y == 0 && in_pp->binds[0].z == 0)
|
if(in_pp->binds[0].x == 0 && in_pp->binds[0].y == 0 && in_pp->binds[0].z == 0)
|
||||||
database.GetSafePoints(in_pp->binds[0].zoneId, 0, &in_pp->binds[0].x, &in_pp->binds[0].y, &in_pp->binds[0].z);
|
database.GetSafePoints(in_pp->binds[0].zoneId, 0, &in_pp->binds[0].x, &in_pp->binds[0].y, &in_pp->binds[0].z);
|
||||||
if(result)
|
|
||||||
mysql_free_result(result);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user