Skip to content

Commit

Permalink
MYSQL objects cannot be copied in a well defined way, this removes th…
Browse files Browse the repository at this point in the history
…e copy and replaces it with another connection
  • Loading branch information
KimLS authored and KimLS committed Feb 5, 2023
1 parent ee6f6f6 commit 0b02b22
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 12 deletions.
11 changes: 10 additions & 1 deletion client_files/export/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,16 @@ int main(int argc, char **argv)
return 1;
}
} else {
content_db.SetMysql(database.getMySQL());
if (!content_db.Connect(
Config->DatabaseHost.c_str(),
Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort
)) {
LogError("Cannot continue without a content database connection");
return 1;
}
}

LogSys.SetDatabase(&database)
Expand Down
11 changes: 10 additions & 1 deletion client_files/import/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@ int main(int argc, char **argv) {
return 1;
}
} else {
content_db.SetMysql(database.getMySQL());
if (!content_db.Connect(
Config->DatabaseHost.c_str(),
Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort
)) {
LogError("Cannot continue without a content database connection");
return 1;
}
}

LogSys.SetDatabase(&database)
Expand Down
5 changes: 0 additions & 5 deletions common/dbcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,6 @@ bool DBcore::Open(uint32 *errnum, char *errbuf)
}
}

void DBcore::SetMysql(MYSQL *mysql)
{
DBcore::mysql = *mysql;
}

const std::string &DBcore::GetOriginHost() const
{
return origin_host;
Expand Down
2 changes: 0 additions & 2 deletions common/dbcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class DBcore {
void TransactionRollback();
uint32 DoEscapeString(char *tobuf, const char *frombuf, uint32 fromlen);
void ping();
MYSQL *getMySQL() { return &mysql; }
void SetMysql(MYSQL *mysql);

const std::string &GetOriginHost() const;
void SetOriginHost(const std::string &origin_host);
Expand Down
11 changes: 10 additions & 1 deletion shared_memory/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,16 @@ int main(int argc, char **argv)
return 1;
}
} else {
content_db.SetMysql(database.getMySQL());
if (!content_db.Connect(
Config->DatabaseHost.c_str(),
Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort
)) {
LogError("Cannot continue without a content database connection");
return 1;
}
}

LogSys.SetDatabase(&database)
Expand Down
12 changes: 11 additions & 1 deletion world/world_boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,17 @@ bool WorldBoot::LoadDatabaseConnections()
}
}
else {
content_db.SetMysql(database.getMySQL());
if (!content_db.Connect(
c->DatabaseHost.c_str(),
c->DatabaseUsername.c_str(),
c->DatabasePassword.c_str(),
c->DatabaseDB.c_str(),
c->DatabasePort,
"content"
)) {
LogError("Cannot continue without a content database connection");
return false;
}
}

return true;
Expand Down
12 changes: 11 additions & 1 deletion zone/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,17 @@ int main(int argc, char** argv) {
return 1;
}
} else {
content_db.SetMysql(database.getMySQL());
if (!content_db.Connect(
Config->DatabaseHost.c_str(),
Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort,
"content"
)) {
LogError("Cannot continue without a content database connection");
return 1;
}
}

/* Register Log System and Settings */
Expand Down

0 comments on commit 0b02b22

Please sign in to comment.