-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1586 from DarkflameUniverse/property_behavior_saving
feat: Property Behavior Saving
- Loading branch information
Showing
22 changed files
with
328 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef IBEHAVIORS_H | ||
#define IBEHAVIORS_H | ||
|
||
#include <cstdint> | ||
|
||
#include "dCommonVars.h" | ||
|
||
class IBehaviors { | ||
public: | ||
struct Info { | ||
int32_t behaviorId{}; | ||
uint32_t characterId{}; | ||
std::string behaviorInfo; | ||
}; | ||
|
||
// This Add also takes care of updating if it exists. | ||
virtual void AddBehavior(const Info& info) = 0; | ||
virtual std::string GetBehavior(const int32_t behaviorId) = 0; | ||
virtual void RemoveBehavior(const int32_t behaviorId) = 0; | ||
}; | ||
|
||
#endif //!IBEHAVIORS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "IBehaviors.h" | ||
|
||
#include "MySQLDatabase.h" | ||
|
||
void MySQLDatabase::AddBehavior(const IBehaviors::Info& info) { | ||
ExecuteInsert( | ||
"INSERT INTO behaviors (behavior_info, character_id, behavior_id) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE behavior_info = ?", | ||
info.behaviorInfo, info.characterId, info.behaviorId, info.behaviorInfo | ||
); | ||
} | ||
|
||
void MySQLDatabase::RemoveBehavior(const int32_t behaviorId) { | ||
ExecuteDelete("DELETE FROM behaviors WHERE behavior_id = ?", behaviorId); | ||
} | ||
|
||
std::string MySQLDatabase::GetBehavior(const int32_t behaviorId) { | ||
auto result = ExecuteSelect("SELECT behavior_info FROM behaviors WHERE behavior_id = ?", behaviorId); | ||
return result->next() ? result->getString("behavior_info").c_str() : ""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.