mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-13 02:48:19 +00:00
script comp
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "CDScriptComponentTable.h"
|
||||
|
||||
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ScriptComponent");
|
||||
@@ -28,12 +27,8 @@ void CDScriptComponentTable::LoadValuesFromDatabase() {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
const CDScriptComponent& CDScriptComponentTable::GetByID(unsigned int id) {
|
||||
const std::optional<CDScriptComponent> CDScriptComponentTable::GetByID(unsigned int id) {
|
||||
std::map<unsigned int, CDScriptComponent>::iterator it = this->entries.find(id);
|
||||
if (it != this->entries.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return m_ToReturnWhenNoneFound;
|
||||
return (it != this->entries.end()) ? std::make_optional<CDScriptComponent>(it->second) : std::nullopt;
|
||||
}
|
||||
|
||||
|
@@ -5,18 +5,16 @@
|
||||
|
||||
struct CDScriptComponent {
|
||||
unsigned int id; //!< The component ID
|
||||
std::string script_name; //!< The script name
|
||||
std::string client_script_name; //!< The client script name
|
||||
std::string script_name; //!< The script name
|
||||
std::string client_script_name; //!< The client script name
|
||||
};
|
||||
|
||||
class CDScriptComponentTable : public CDTable<CDScriptComponentTable> {
|
||||
private:
|
||||
std::map<unsigned int, CDScriptComponent> entries;
|
||||
CDScriptComponent m_ToReturnWhenNoneFound;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
// Gets an entry by scriptID
|
||||
const CDScriptComponent& GetByID(unsigned int id);
|
||||
const std::optional<CDScriptComponent> GetByID(unsigned int id);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user