Compare commits

...

26 Commits

Author SHA1 Message Date
Alex King 7c982df0e3 [Release] 22.43.3 (#4034)
### API

* Add lock_status method to world API ([#4028](https://github.com/EQEmu/Server/pull/4028)) @Akkadius 2024-01-29

### Alternate Currency

* Convert Load of Alternate Currencies to Repositories ([#3993](https://github.com/EQEmu/Server/pull/3993)) @Kinglykrab 2024-01-29

### Beacon

* Cleanup Beacons Code ([#4024](https://github.com/EQEmu/Server/pull/4024)) @Kinglykrab 2024-01-29

### Bots

* Convert Bot Database Methods to Repositories ([#4023](https://github.com/EQEmu/Server/pull/4023)) @Kinglykrab 2024-01-29
* Missing boolean returns on DeletePetStats and SaveInspectMessage ([#4031](https://github.com/EQEmu/Server/pull/4031)) @joligario 2024-01-30

### Code

* Add Raid Loot Type Constants ([#4022](https://github.com/EQEmu/Server/pull/4022)) @Kinglykrab 2024-01-29
* Cleanup cross-zone/world-wide OPCode handling ([#4003](https://github.com/EQEmu/Server/pull/4003)) @Kinglykrab 2024-01-29

### Commands

* Cleanup #petitems Command ([#4005](https://github.com/EQEmu/Server/pull/4005)) @Kinglykrab 2024-01-29

### Crash Fix

* Fix Possible Crash in HateList::Find ([#4027](https://github.com/EQEmu/Server/pull/4027)) @Kinglykrab 2024-01-28

### Fixes

* Fix NPC After Death Emotes ([#4021](https://github.com/EQEmu/Server/pull/4021)) @Kinglykrab 2024-01-29
* Fix database loading routines ([#4030](https://github.com/EQEmu/Server/pull/4030)) @Akkadius 2024-01-29
* Fix issue in character_corpses Repository Query ([#4029](https://github.com/EQEmu/Server/pull/4029)) @Kinglykrab 2024-01-29
* Limit Pet Taunt Distance ([#4018](https://github.com/EQEmu/Server/pull/4018)) @fryguy503 2024-01-26
* Limit Player Taunt Distance ([#4019](https://github.com/EQEmu/Server/pull/4019)) @fryguy503 2024-01-26
* Patch for recent change to DEATH ([#4032](https://github.com/EQEmu/Server/pull/4032)) @noudess 2024-01-30
* spawn_conditions map was being emptied by mistake ([#4033](https://github.com/EQEmu/Server/pull/4033)) @noudess 2024-01-30

### Grids

* Convert Grid/Grid Entries to Repositories ([#4011](https://github.com/EQEmu/Server/pull/4011)) @Kinglykrab 2024-01-29

### Mercenaries

* Add expansion settings update to Mercs:Enable ([#4001](https://github.com/EQEmu/Server/pull/4001)) @Kinglykrab 2024-01-29

### Merchants

* Convert Merchant Load to Repositories ([#4007](https://github.com/EQEmu/Server/pull/4007)) @Kinglykrab 2024-01-29

### Pets

* Convert Load of Pets Beastlord Data to Repositories ([#3995](https://github.com/EQEmu/Server/pull/3995)) @Kinglykrab 2024-01-29

### Quests

* Use separate variable for quest idle override. ([#4026](https://github.com/EQEmu/Server/pull/4026)) @noudess 2024-01-27

### Rules

* Add rules for cross-zone/world-wide casts to affect Bots/Mercenaries/Pets ([#4002](https://github.com/EQEmu/Server/pull/4002)) @Kinglykrab 2024-01-29

### Spawn2

* Convert Spawn2 Methods to Repositories ([#4014](https://github.com/EQEmu/Server/pull/4014)) @Kinglykrab 2024-01-29

### Traps

* Convert Load/Set of Traps to Repositories ([#3994](https://github.com/EQEmu/Server/pull/3994)) @Kinglykrab 2024-01-29

### Zone

* Convert Fishing/Foraging to Repositories ([#4008](https://github.com/EQEmu/Server/pull/4008)) @Kinglykrab 2024-01-30
2024-01-30 19:26:50 -05:00
Paul Coene fa783c3c6b [Bug Fix] spawn_conditions map was being emptied by mistake (#4033) 2024-01-30 18:48:28 -05:00
Paul Coene 5377bb3f49 [Bug Fix] Patch for recent change to DEATH (#4032) 2024-01-30 17:10:45 -05:00
JJ f98c79fdba [Bots] Missing boolean returns on DeletePetStats and SaveInspectMessage (#4031) 2024-01-30 12:07:02 -05:00
Alex King ae79022e06 [Zone] Convert Fishing/Foraging to Repositories (#4008)
* [Zone] Convert Fishing/Foraging to Repositories

# Notes
- Convert `LoadFishing()` and `LoadForage()` to repositories.

* Update forage.cpp

* Cleanup
2024-01-30 05:55:09 -05:00
Chris Miles bc59882a65 [Hotfix] Fix database loading routines (#4030) 2024-01-29 00:14:33 -06:00
Alex King 2e0ed82986 [Grids] Convert Grid/Grid Entries to Repositories (#4011)
* [Grids] Convert Grid/Grid Entries to Repositories

- Convert `AddWaypoint()`, `AddWaypointForSpawn()`, `DeleteWaypoint()`, `GetHighestWaypoint()`, `GetRandomWaypointFromGrid()`, `GridExistsInZone()`, and `ModifyGrid()` to repositories.

* Update grid.cpp

* Update questmgr.cpp

* Update waypoints.cpp

* Update waypoints.cpp
2024-01-28 23:37:34 -06:00
Alex King 8e3218aaf7 [Cleanup] Cleanup cross-zone/world-wide OPCode handling (#4003)
* [Cleanup] Cleanup cross-zone/world-wide OPCode handling

# Notes
- Cleans up the logic greatly for cross-zone/world-wide methods since we were doing extraneous status checks and needlessly allocating memory for variables.

* Update worldserver.cpp
2024-01-28 23:07:27 -06:00
Alex King 9276966418 [Rules] Add rules for cross-zone/world-wide casts to affect Bots/Mercenaries/Pets (#4002)
* [Rules] Add rules for cross-zone/world-wide casts to affect bots/mercenaries/pets

# Notes
- These rules allow operators to have cross-zone/world-wide casts/removals of spells affect bots, mercenaries, and/or pets.
- Adds `World:AllowWorldWideSpellsOnBots`.
- Adds `World:AllowWorldWideSpellsOnMercs`.
- Adds `World:AllowWorldWideSpellsOnPets`.
- Adds `Zone:AllowCrossZoneSpellsOnBots`.
- Adds `Zone:AllowCrossZoneSpellsOnMercs`.
- Adds `Zone:AllowCrossZoneSpellsOnPets`.

* Consolidate to 3 rules
2024-01-28 23:06:21 -06:00
Alex King b89772ca91 [Pets] Convert Load of Pets Beastlord Data to Repositories (#3995)
* [Pets] Convert Load of Pets Beastlord Data to Repositories

# Notes
- Convert `GetBeastlordPetData()` to repositories.
- Add support for `unsigned` versions of `float`, `double`, and `decimal`, without this we defaulted to `std::string`, such as with `pets_beastlord_data`.

* Update repository-generator.pl

---------

Co-authored-by: Chris Miles <akkadius1@gmail.com>
2024-01-28 23:05:43 -06:00
Alex King a1f2a21c99 [Bug Fix] Fix NPC After Death Emotes (#4021)
* [Bug Fix] Fix NPC After Death Emotes

- `DoNPCEmote` was being called on the corpse, not the NPC, so it wasn't working for some reason despite it working for years.
- Cleaned up some other logic and variable names in `NPC::Death` while I was in there.

* Update attack.cpp

* Update npc.cpp

* Update attack.cpp

* Update attack.cpp
2024-01-29 00:03:34 -05:00
Alex King 1cb72642ac [Traps] Convert Load/Set of Traps to Repositories (#3994)
# Notes
- Convert `LoadTraps()` and `SetTrapData()` to repositories.
2024-01-28 22:38:21 -06:00
Alex King a38fd8f986 [Alternate Currency] Convert Load of Alternate Currencies to Repositories (#3993)
# Notes
- Convert `LoadAlternateCurrencies()` to repositories.
2024-01-28 22:36:26 -06:00
Alex King 337b6f38e0 [Mercenaries] Add expansion settings update to Mercs:Enable (#4001)
# Notes
- Adds an expansion settings update to the `Mercs:Enable` command, only updates if the expansion setting isn't already `-1` or doesn't already contain the bitmask for Seeds of Destruction (16384).
- This will enable Mercenary Liaisons spawning properly in Plane of Knowledge for the hiring of mercenaries.
2024-01-28 21:58:58 -06:00
Alex King b4414d3052 [Merchants] Convert Merchant Load to Repositories (#4007)
* [Merchants] Convert Merchant Load to Repositories

# Notes
- Convert `GetMerchantDataForZoneLoad()` to repositories.

# Images
## Load

* Change to LoadMerchants()
2024-01-28 21:55:59 -06:00
Alex King bfeeb0ce05 [Commands] Cleanup #petitems Command (#4005)
- Adds support to `#petitems` to allow you to target bot's pets to view their items, defaults to your pet if you have one.
- If you have no pet or no bot pet targeted it won't function.
2024-01-28 21:55:35 -06:00
Alex King e640e3cad3 [Cleanup] Add Raid Loot Type Constants (#4022)
* [Cleanup] Add Raid Loot Type Constants

# Notes
- Add constants for Raid loot types.

* [Cleanup] Add Raid Loot Type Constants

# Notes
- Add constants for Raid loot types.
2024-01-28 21:45:32 -06:00
Alex King c09a3a5bba [Spawn2] Convert Spawn2 Methods to Repositories (#4014)
* [Spawn2] Convert Spawn2 Methods to Repositories

# Notes
- Convert `CreateSpawn2()`, `GetCondition()`, `LoadSpawnConditions()`, `LoadSpawnEvent()`, `UpdateSpawnCondition()`, and `UpdateSpawnEvent()` to repositories.

# Images

* Update spawn2.cpp
2024-01-28 20:24:33 -06:00
Alex King ce907c9519 [Bots] Convert Bot Database Methods to Repositories (#4023)
* [Bots] Convert Bot Database Methods to Repositories

* Final push.

* Cleanup.

* Cleanup.

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp
2024-01-28 20:23:31 -06:00
Alex King 7a770e0e08 [Beacon] Cleanup Beacons Code (#4024)
# Notes
- Use constants where possible.
- Change `resist_adjust` parameter in `Beacon::AELocationSpell` from `resist_adjust` to `in_resist_adjust` so we're not possibly causing parameter shadowing.
2024-01-28 20:20:09 -06:00
Chris Miles 97c3205657 [API] Add lock_status method to world API (#4028) 2024-01-28 20:18:32 -06:00
Alex King ff2e56abc7 [Bug Fix] Fix issue in character_corpses Repository Query (#4029)
* [Bug Fix] Fix issue in character_corpses Repository Query

# Notes
- Query had an extra ` inside of it, causing it to fail.

* Update character_corpses_repository.h
2024-01-28 20:18:24 -06:00
Alex King 9ee16f8bf7 [Crash Fix] Fix Possible Crash in HateList::Find (#4027)
# Notes
- We were not doing any pointer validation, so we were causing crashes in some cases.
- Example: http://spire.akkadius.com/dev/release/22.43.2?id=19163
2024-01-28 02:44:04 -06:00
Paul Coene 5b43bf4a5e [Quests] Use separate variable for quest idle override. (#4026)
* [Quests] Use separate variable for quest idle override.

* Fix missing zone->
2024-01-27 14:09:00 -05:00
Fryguy 4c769c46b3 [Bug Fix] Limit Player Taunt Distance (#4019)
* [Bug Fix] Player Taunt Distance

Previously this was not regulated on the server side and allowed players to exploit situations where the client did not enforce Z distance checks.

Rule Name: MaximumTauntDistance
Rule Default: 150

Calculation is Rule Squared

* remove `this`
2024-01-26 15:44:05 -05:00
Fryguy 8a87e00b66 [Bug Fix] Limit Pet Taunt Distance (#4018)
* [Bug Fix] Limit pet taunt distance

Previously this was not regulated and allowed players to exploit unlimited taunt distance.

Rule Name: PetTauntRange
Rule Default: 150

Calculation is Rule Squared.

* Remove `this`
2024-01-26 15:43:20 -05:00
70 changed files with 5880 additions and 4467 deletions
+78
View File
@@ -1,3 +1,81 @@
## [22.43.3] - 1/30/2024
### API
* Add lock_status method to world API ([#4028](https://github.com/EQEmu/Server/pull/4028)) @Akkadius 2024-01-29
### Alternate Currency
* Convert Load of Alternate Currencies to Repositories ([#3993](https://github.com/EQEmu/Server/pull/3993)) @Kinglykrab 2024-01-29
### Beacon
* Cleanup Beacons Code ([#4024](https://github.com/EQEmu/Server/pull/4024)) @Kinglykrab 2024-01-29
### Bots
* Convert Bot Database Methods to Repositories ([#4023](https://github.com/EQEmu/Server/pull/4023)) @Kinglykrab 2024-01-29
* Missing boolean returns on DeletePetStats and SaveInspectMessage ([#4031](https://github.com/EQEmu/Server/pull/4031)) @joligario 2024-01-30
### Code
* Add Raid Loot Type Constants ([#4022](https://github.com/EQEmu/Server/pull/4022)) @Kinglykrab 2024-01-29
* Cleanup cross-zone/world-wide OPCode handling ([#4003](https://github.com/EQEmu/Server/pull/4003)) @Kinglykrab 2024-01-29
### Commands
* Cleanup #petitems Command ([#4005](https://github.com/EQEmu/Server/pull/4005)) @Kinglykrab 2024-01-29
### Crash Fix
* Fix Possible Crash in HateList::Find ([#4027](https://github.com/EQEmu/Server/pull/4027)) @Kinglykrab 2024-01-28
### Fixes
* Fix NPC After Death Emotes ([#4021](https://github.com/EQEmu/Server/pull/4021)) @Kinglykrab 2024-01-29
* Fix database loading routines ([#4030](https://github.com/EQEmu/Server/pull/4030)) @Akkadius 2024-01-29
* Fix issue in character_corpses Repository Query ([#4029](https://github.com/EQEmu/Server/pull/4029)) @Kinglykrab 2024-01-29
* Limit Pet Taunt Distance ([#4018](https://github.com/EQEmu/Server/pull/4018)) @fryguy503 2024-01-26
* Limit Player Taunt Distance ([#4019](https://github.com/EQEmu/Server/pull/4019)) @fryguy503 2024-01-26
* Patch for recent change to DEATH ([#4032](https://github.com/EQEmu/Server/pull/4032)) @noudess 2024-01-30
* spawn_conditions map was being emptied by mistake ([#4033](https://github.com/EQEmu/Server/pull/4033)) @noudess 2024-01-30
### Grids
* Convert Grid/Grid Entries to Repositories ([#4011](https://github.com/EQEmu/Server/pull/4011)) @Kinglykrab 2024-01-29
### Mercenaries
* Add expansion settings update to Mercs:Enable ([#4001](https://github.com/EQEmu/Server/pull/4001)) @Kinglykrab 2024-01-29
### Merchants
* Convert Merchant Load to Repositories ([#4007](https://github.com/EQEmu/Server/pull/4007)) @Kinglykrab 2024-01-29
### Pets
* Convert Load of Pets Beastlord Data to Repositories ([#3995](https://github.com/EQEmu/Server/pull/3995)) @Kinglykrab 2024-01-29
### Quests
* Use separate variable for quest idle override. ([#4026](https://github.com/EQEmu/Server/pull/4026)) @noudess 2024-01-27
### Rules
* Add rules for cross-zone/world-wide casts to affect Bots/Mercenaries/Pets ([#4002](https://github.com/EQEmu/Server/pull/4002)) @Kinglykrab 2024-01-29
### Spawn2
* Convert Spawn2 Methods to Repositories ([#4014](https://github.com/EQEmu/Server/pull/4014)) @Kinglykrab 2024-01-29
### Traps
* Convert Load/Set of Traps to Repositories ([#3994](https://github.com/EQEmu/Server/pull/3994)) @Kinglykrab 2024-01-29
### Zone
* Convert Fishing/Foraging to Repositories ([#4008](https://github.com/EQEmu/Server/pull/4008)) @Kinglykrab 2024-01-30
## [22.43.2] - 1/25/2024
### Bots
@@ -104,6 +104,25 @@ ALTER TABLE `bot_timers`
DROP PRIMARY KEY;
ALTER TABLE `bot_timers`
ADD PRIMARY KEY (`bot_id`, `timer_id`, `spell_id`, `item_id`);
)"
},
ManifestEntry{
.version = 9042,
.description = "2024_01_27_delete_bot_foreign_keys.sql",
.check = "SHOW CREATE TABLE `bot_stances`",
.condition = "contains",
.match = "FOREIGN",
.sql = R"(
ALTER TABLE `bot_buffs` DROP FOREIGN KEY `FK_bot_buffs_1`;
ALTER TABLE `bot_heal_rotations` DROP FOREIGN KEY `FK_bot_heal_rotations`;
ALTER TABLE `bot_heal_rotation_members` DROP FOREIGN KEY `FK_bot_heal_rotation_members_1`;
ALTER TABLE `bot_heal_rotation_members` DROP FOREIGN KEY `FK_bot_heal_rotation_members_2`;
ALTER TABLE `bot_heal_rotation_targets` DROP FOREIGN KEY `FK_bot_heal_rotation_targets`;
ALTER TABLE `bot_inventories` DROP FOREIGN KEY `FK_bot_inventories_1`;
ALTER TABLE `bot_pets` DROP FOREIGN KEY `FK_bot_pets_1`;
ALTER TABLE `bot_pet_buffs` DROP FOREIGN KEY `FK_bot_pet_buffs_1`;
ALTER TABLE `bot_pet_inventories` DROP FOREIGN KEY `FK_bot_pet_inventories_1`;
ALTER TABLE `bot_stances` DROP FOREIGN KEY `FK_bot_stances_1`;
)"
}
// -- template; copy/paste this when you need to create a new entry
+7
View File
@@ -1120,4 +1120,11 @@ enum MoneySubtypes
SharedBank // Platinum Only
};
namespace RaidLootType {
constexpr uint32 LeaderOnly = 1;
constexpr uint32 LeaderAndGroupLeadersOnly = 2;
constexpr uint32 LeaderSelected = 3;
constexpr uint32 EntireRaid = 4;
}
#endif /*COMMON_EQ_CONSTANTS_H*/
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_BUFFS_REPOSITORY_H
@@ -180,8 +180,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_buffs_id
)
);
@@ -190,26 +191,26 @@ public:
if (results.RowCount() == 1) {
BotBuffs e{};
e.buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.caster_level = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.duration_formula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.tics_remaining = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.poison_counters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.disease_counters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.curse_counters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.corruption_counters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.numhits = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.melee_rune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.magic_rune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.dot_rune = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.persistent = static_cast<int8_t>(atoi(row[14]));
e.caston_x = static_cast<int32_t>(atoi(row[15]));
e.caston_y = static_cast<int32_t>(atoi(row[16]));
e.caston_z = static_cast<int32_t>(atoi(row[17]));
e.extra_di_chance = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
e.instrument_mod = static_cast<int32_t>(atoi(row[19]));
e.buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration_formula = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.tics_remaining = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.poison_counters = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.disease_counters = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
e.curse_counters = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.corruption_counters = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.numhits = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
e.melee_rune = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.magic_rune = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.dot_rune = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.persistent = row[14] ? static_cast<int8_t>(atoi(row[14])) : 0;
e.caston_x = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
e.caston_y = row[16] ? static_cast<int32_t>(atoi(row[16])) : 0;
e.caston_z = row[17] ? static_cast<int32_t>(atoi(row[17])) : 0;
e.extra_di_chance = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
e.instrument_mod = row[19] ? static_cast<int32_t>(atoi(row[19])) : 10;
return e;
}
@@ -385,26 +386,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotBuffs e{};
e.buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.caster_level = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.duration_formula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.tics_remaining = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.poison_counters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.disease_counters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.curse_counters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.corruption_counters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.numhits = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.melee_rune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.magic_rune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.dot_rune = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.persistent = static_cast<int8_t>(atoi(row[14]));
e.caston_x = static_cast<int32_t>(atoi(row[15]));
e.caston_y = static_cast<int32_t>(atoi(row[16]));
e.caston_z = static_cast<int32_t>(atoi(row[17]));
e.extra_di_chance = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
e.instrument_mod = static_cast<int32_t>(atoi(row[19]));
e.buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration_formula = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.tics_remaining = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.poison_counters = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.disease_counters = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
e.curse_counters = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.corruption_counters = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.numhits = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
e.melee_rune = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.magic_rune = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.dot_rune = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.persistent = row[14] ? static_cast<int8_t>(atoi(row[14])) : 0;
e.caston_x = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
e.caston_y = row[16] ? static_cast<int32_t>(atoi(row[16])) : 0;
e.caston_z = row[17] ? static_cast<int32_t>(atoi(row[17])) : 0;
e.extra_di_chance = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
e.instrument_mod = row[19] ? static_cast<int32_t>(atoi(row[19])) : 10;
all_entries.push_back(e);
}
@@ -429,26 +430,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotBuffs e{};
e.buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.caster_level = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.duration_formula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.tics_remaining = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.poison_counters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.disease_counters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.curse_counters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.corruption_counters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.numhits = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.melee_rune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.magic_rune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.dot_rune = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.persistent = static_cast<int8_t>(atoi(row[14]));
e.caston_x = static_cast<int32_t>(atoi(row[15]));
e.caston_y = static_cast<int32_t>(atoi(row[16]));
e.caston_z = static_cast<int32_t>(atoi(row[17]));
e.extra_di_chance = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
e.instrument_mod = static_cast<int32_t>(atoi(row[19]));
e.buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration_formula = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.tics_remaining = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.poison_counters = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.disease_counters = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
e.curse_counters = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.corruption_counters = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.numhits = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
e.melee_rune = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.magic_rune = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.dot_rune = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.persistent = row[14] ? static_cast<int8_t>(atoi(row[14])) : 0;
e.caston_x = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
e.caston_y = row[16] ? static_cast<int32_t>(atoi(row[16])) : 0;
e.caston_z = row[17] ? static_cast<int32_t>(atoi(row[17])) : 0;
e.extra_di_chance = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
e.instrument_mod = row[19] ? static_cast<int32_t>(atoi(row[19])) : 10;
all_entries.push_back(e);
}
@@ -507,6 +508,100 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotBuffs &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.buffs_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration_formula));
v.push_back(std::to_string(e.tics_remaining));
v.push_back(std::to_string(e.poison_counters));
v.push_back(std::to_string(e.disease_counters));
v.push_back(std::to_string(e.curse_counters));
v.push_back(std::to_string(e.corruption_counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.melee_rune));
v.push_back(std::to_string(e.magic_rune));
v.push_back(std::to_string(e.dot_rune));
v.push_back(std::to_string(e.persistent));
v.push_back(std::to_string(e.caston_x));
v.push_back(std::to_string(e.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.extra_di_chance));
v.push_back(std::to_string(e.instrument_mod));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotBuffs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.buffs_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration_formula));
v.push_back(std::to_string(e.tics_remaining));
v.push_back(std::to_string(e.poison_counters));
v.push_back(std::to_string(e.disease_counters));
v.push_back(std::to_string(e.curse_counters));
v.push_back(std::to_string(e.corruption_counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.melee_rune));
v.push_back(std::to_string(e.magic_rune));
v.push_back(std::to_string(e.dot_rune));
v.push_back(std::to_string(e.persistent));
v.push_back(std::to_string(e.caston_x));
v.push_back(std::to_string(e.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.extra_di_chance));
v.push_back(std::to_string(e.instrument_mod));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_BUFFS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_CREATE_COMBINATIONS_REPOSITORY_H
@@ -108,8 +108,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_create_combinations_id
)
);
@@ -118,8 +119,8 @@ public:
if (results.RowCount() == 1) {
BotCreateCombinations e{};
e.race = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.classes = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.race = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.classes = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
return e;
}
@@ -242,8 +243,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotCreateCombinations e{};
e.race = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.classes = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.race = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.classes = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -268,8 +269,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotCreateCombinations e{};
e.race = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.classes = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.race = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.classes = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -328,6 +329,64 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotCreateCombinations &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.classes));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotCreateCombinations> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.classes));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_CREATE_COMBINATIONS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_DATA_REPOSITORY_H
@@ -278,7 +278,7 @@ public:
e.expansion_bitmask = -1;
e.enforce_spell_settings = 0;
e.archery_setting = 0;
e.caster_range = 0;
e.caster_range = 300;
return e;
}
@@ -315,57 +315,57 @@ public:
if (results.RowCount() == 1) {
BotData e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.owner_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spells_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.owner_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spells_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : "";
e.last_name = row[4] ? row[4] : "";
e.title = row[5] ? row[5] : "";
e.suffix = row[6] ? row[6] : "";
e.zone_id = static_cast<int16_t>(atoi(row[7]));
e.gender = static_cast<int8_t>(atoi(row[8]));
e.race = static_cast<int16_t>(atoi(row[9]));
e.class_ = static_cast<int8_t>(atoi(row[10]));
e.level = static_cast<uint8_t>(strtoul(row[11], nullptr, 10));
e.deity = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.creation_day = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.last_spawn = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.time_spawned = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.size = strtof(row[16], nullptr);
e.face = static_cast<int32_t>(atoi(row[17]));
e.hair_color = static_cast<int32_t>(atoi(row[18]));
e.hair_style = static_cast<int32_t>(atoi(row[19]));
e.beard = static_cast<int32_t>(atoi(row[20]));
e.beard_color = static_cast<int32_t>(atoi(row[21]));
e.eye_color_1 = static_cast<int32_t>(atoi(row[22]));
e.eye_color_2 = static_cast<int32_t>(atoi(row[23]));
e.drakkin_heritage = static_cast<int32_t>(atoi(row[24]));
e.drakkin_tattoo = static_cast<int32_t>(atoi(row[25]));
e.drakkin_details = static_cast<int32_t>(atoi(row[26]));
e.ac = static_cast<int16_t>(atoi(row[27]));
e.atk = static_cast<int32_t>(atoi(row[28]));
e.hp = static_cast<int32_t>(atoi(row[29]));
e.mana = static_cast<int32_t>(atoi(row[30]));
e.str = static_cast<int32_t>(atoi(row[31]));
e.sta = static_cast<int32_t>(atoi(row[32]));
e.cha = static_cast<int32_t>(atoi(row[33]));
e.dex = static_cast<int32_t>(atoi(row[34]));
e.int_ = static_cast<int32_t>(atoi(row[35]));
e.agi = static_cast<int32_t>(atoi(row[36]));
e.wis = static_cast<int32_t>(atoi(row[37]));
e.fire = static_cast<int16_t>(atoi(row[38]));
e.cold = static_cast<int16_t>(atoi(row[39]));
e.magic = static_cast<int16_t>(atoi(row[40]));
e.poison = static_cast<int16_t>(atoi(row[41]));
e.disease = static_cast<int16_t>(atoi(row[42]));
e.corruption = static_cast<int16_t>(atoi(row[43]));
e.show_helm = static_cast<uint32_t>(strtoul(row[44], nullptr, 10));
e.follow_distance = static_cast<uint32_t>(strtoul(row[45], nullptr, 10));
e.stop_melee_level = static_cast<uint8_t>(strtoul(row[46], nullptr, 10));
e.expansion_bitmask = static_cast<int32_t>(atoi(row[47]));
e.enforce_spell_settings = static_cast<uint8_t>(strtoul(row[48], nullptr, 10));
e.archery_setting = static_cast<uint8_t>(strtoul(row[49], nullptr, 10));
e.caster_range = static_cast<uint32_t>(strtoul(row[50], nullptr, 10));
e.zone_id = row[7] ? static_cast<int16_t>(atoi(row[7])) : 0;
e.gender = row[8] ? static_cast<int8_t>(atoi(row[8])) : 0;
e.race = row[9] ? static_cast<int16_t>(atoi(row[9])) : 0;
e.class_ = row[10] ? static_cast<int8_t>(atoi(row[10])) : 0;
e.level = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.deity = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.creation_day = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.last_spawn = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.time_spawned = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.size = row[16] ? strtof(row[16], nullptr) : 0;
e.face = row[17] ? static_cast<int32_t>(atoi(row[17])) : 1;
e.hair_color = row[18] ? static_cast<int32_t>(atoi(row[18])) : 1;
e.hair_style = row[19] ? static_cast<int32_t>(atoi(row[19])) : 1;
e.beard = row[20] ? static_cast<int32_t>(atoi(row[20])) : 0;
e.beard_color = row[21] ? static_cast<int32_t>(atoi(row[21])) : 1;
e.eye_color_1 = row[22] ? static_cast<int32_t>(atoi(row[22])) : 1;
e.eye_color_2 = row[23] ? static_cast<int32_t>(atoi(row[23])) : 1;
e.drakkin_heritage = row[24] ? static_cast<int32_t>(atoi(row[24])) : 0;
e.drakkin_tattoo = row[25] ? static_cast<int32_t>(atoi(row[25])) : 0;
e.drakkin_details = row[26] ? static_cast<int32_t>(atoi(row[26])) : 0;
e.ac = row[27] ? static_cast<int16_t>(atoi(row[27])) : 0;
e.atk = row[28] ? static_cast<int32_t>(atoi(row[28])) : 0;
e.hp = row[29] ? static_cast<int32_t>(atoi(row[29])) : 0;
e.mana = row[30] ? static_cast<int32_t>(atoi(row[30])) : 0;
e.str = row[31] ? static_cast<int32_t>(atoi(row[31])) : 75;
e.sta = row[32] ? static_cast<int32_t>(atoi(row[32])) : 75;
e.cha = row[33] ? static_cast<int32_t>(atoi(row[33])) : 75;
e.dex = row[34] ? static_cast<int32_t>(atoi(row[34])) : 75;
e.int_ = row[35] ? static_cast<int32_t>(atoi(row[35])) : 75;
e.agi = row[36] ? static_cast<int32_t>(atoi(row[36])) : 75;
e.wis = row[37] ? static_cast<int32_t>(atoi(row[37])) : 75;
e.fire = row[38] ? static_cast<int16_t>(atoi(row[38])) : 0;
e.cold = row[39] ? static_cast<int16_t>(atoi(row[39])) : 0;
e.magic = row[40] ? static_cast<int16_t>(atoi(row[40])) : 0;
e.poison = row[41] ? static_cast<int16_t>(atoi(row[41])) : 0;
e.disease = row[42] ? static_cast<int16_t>(atoi(row[42])) : 0;
e.corruption = row[43] ? static_cast<int16_t>(atoi(row[43])) : 0;
e.show_helm = row[44] ? static_cast<uint32_t>(strtoul(row[44], nullptr, 10)) : 0;
e.follow_distance = row[45] ? static_cast<uint32_t>(strtoul(row[45], nullptr, 10)) : 200;
e.stop_melee_level = row[46] ? static_cast<uint8_t>(strtoul(row[46], nullptr, 10)) : 255;
e.expansion_bitmask = row[47] ? static_cast<int32_t>(atoi(row[47])) : -1;
e.enforce_spell_settings = row[48] ? static_cast<uint8_t>(strtoul(row[48], nullptr, 10)) : 0;
e.archery_setting = row[49] ? static_cast<uint8_t>(strtoul(row[49], nullptr, 10)) : 0;
e.caster_range = row[50] ? static_cast<uint32_t>(strtoul(row[50], nullptr, 10)) : 300;
return e;
}
@@ -634,57 +634,57 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotData e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.owner_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spells_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.owner_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spells_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : "";
e.last_name = row[4] ? row[4] : "";
e.title = row[5] ? row[5] : "";
e.suffix = row[6] ? row[6] : "";
e.zone_id = static_cast<int16_t>(atoi(row[7]));
e.gender = static_cast<int8_t>(atoi(row[8]));
e.race = static_cast<int16_t>(atoi(row[9]));
e.class_ = static_cast<int8_t>(atoi(row[10]));
e.level = static_cast<uint8_t>(strtoul(row[11], nullptr, 10));
e.deity = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.creation_day = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.last_spawn = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.time_spawned = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.size = strtof(row[16], nullptr);
e.face = static_cast<int32_t>(atoi(row[17]));
e.hair_color = static_cast<int32_t>(atoi(row[18]));
e.hair_style = static_cast<int32_t>(atoi(row[19]));
e.beard = static_cast<int32_t>(atoi(row[20]));
e.beard_color = static_cast<int32_t>(atoi(row[21]));
e.eye_color_1 = static_cast<int32_t>(atoi(row[22]));
e.eye_color_2 = static_cast<int32_t>(atoi(row[23]));
e.drakkin_heritage = static_cast<int32_t>(atoi(row[24]));
e.drakkin_tattoo = static_cast<int32_t>(atoi(row[25]));
e.drakkin_details = static_cast<int32_t>(atoi(row[26]));
e.ac = static_cast<int16_t>(atoi(row[27]));
e.atk = static_cast<int32_t>(atoi(row[28]));
e.hp = static_cast<int32_t>(atoi(row[29]));
e.mana = static_cast<int32_t>(atoi(row[30]));
e.str = static_cast<int32_t>(atoi(row[31]));
e.sta = static_cast<int32_t>(atoi(row[32]));
e.cha = static_cast<int32_t>(atoi(row[33]));
e.dex = static_cast<int32_t>(atoi(row[34]));
e.int_ = static_cast<int32_t>(atoi(row[35]));
e.agi = static_cast<int32_t>(atoi(row[36]));
e.wis = static_cast<int32_t>(atoi(row[37]));
e.fire = static_cast<int16_t>(atoi(row[38]));
e.cold = static_cast<int16_t>(atoi(row[39]));
e.magic = static_cast<int16_t>(atoi(row[40]));
e.poison = static_cast<int16_t>(atoi(row[41]));
e.disease = static_cast<int16_t>(atoi(row[42]));
e.corruption = static_cast<int16_t>(atoi(row[43]));
e.show_helm = static_cast<uint32_t>(strtoul(row[44], nullptr, 10));
e.follow_distance = static_cast<uint32_t>(strtoul(row[45], nullptr, 10));
e.stop_melee_level = static_cast<uint8_t>(strtoul(row[46], nullptr, 10));
e.expansion_bitmask = static_cast<int32_t>(atoi(row[47]));
e.enforce_spell_settings = static_cast<uint8_t>(strtoul(row[48], nullptr, 10));
e.archery_setting = static_cast<uint8_t>(strtoul(row[49], nullptr, 10));
e.caster_range = static_cast<uint32_t>(strtoul(row[50], nullptr, 10));
e.zone_id = row[7] ? static_cast<int16_t>(atoi(row[7])) : 0;
e.gender = row[8] ? static_cast<int8_t>(atoi(row[8])) : 0;
e.race = row[9] ? static_cast<int16_t>(atoi(row[9])) : 0;
e.class_ = row[10] ? static_cast<int8_t>(atoi(row[10])) : 0;
e.level = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.deity = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.creation_day = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.last_spawn = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.time_spawned = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.size = row[16] ? strtof(row[16], nullptr) : 0;
e.face = row[17] ? static_cast<int32_t>(atoi(row[17])) : 1;
e.hair_color = row[18] ? static_cast<int32_t>(atoi(row[18])) : 1;
e.hair_style = row[19] ? static_cast<int32_t>(atoi(row[19])) : 1;
e.beard = row[20] ? static_cast<int32_t>(atoi(row[20])) : 0;
e.beard_color = row[21] ? static_cast<int32_t>(atoi(row[21])) : 1;
e.eye_color_1 = row[22] ? static_cast<int32_t>(atoi(row[22])) : 1;
e.eye_color_2 = row[23] ? static_cast<int32_t>(atoi(row[23])) : 1;
e.drakkin_heritage = row[24] ? static_cast<int32_t>(atoi(row[24])) : 0;
e.drakkin_tattoo = row[25] ? static_cast<int32_t>(atoi(row[25])) : 0;
e.drakkin_details = row[26] ? static_cast<int32_t>(atoi(row[26])) : 0;
e.ac = row[27] ? static_cast<int16_t>(atoi(row[27])) : 0;
e.atk = row[28] ? static_cast<int32_t>(atoi(row[28])) : 0;
e.hp = row[29] ? static_cast<int32_t>(atoi(row[29])) : 0;
e.mana = row[30] ? static_cast<int32_t>(atoi(row[30])) : 0;
e.str = row[31] ? static_cast<int32_t>(atoi(row[31])) : 75;
e.sta = row[32] ? static_cast<int32_t>(atoi(row[32])) : 75;
e.cha = row[33] ? static_cast<int32_t>(atoi(row[33])) : 75;
e.dex = row[34] ? static_cast<int32_t>(atoi(row[34])) : 75;
e.int_ = row[35] ? static_cast<int32_t>(atoi(row[35])) : 75;
e.agi = row[36] ? static_cast<int32_t>(atoi(row[36])) : 75;
e.wis = row[37] ? static_cast<int32_t>(atoi(row[37])) : 75;
e.fire = row[38] ? static_cast<int16_t>(atoi(row[38])) : 0;
e.cold = row[39] ? static_cast<int16_t>(atoi(row[39])) : 0;
e.magic = row[40] ? static_cast<int16_t>(atoi(row[40])) : 0;
e.poison = row[41] ? static_cast<int16_t>(atoi(row[41])) : 0;
e.disease = row[42] ? static_cast<int16_t>(atoi(row[42])) : 0;
e.corruption = row[43] ? static_cast<int16_t>(atoi(row[43])) : 0;
e.show_helm = row[44] ? static_cast<uint32_t>(strtoul(row[44], nullptr, 10)) : 0;
e.follow_distance = row[45] ? static_cast<uint32_t>(strtoul(row[45], nullptr, 10)) : 200;
e.stop_melee_level = row[46] ? static_cast<uint8_t>(strtoul(row[46], nullptr, 10)) : 255;
e.expansion_bitmask = row[47] ? static_cast<int32_t>(atoi(row[47])) : -1;
e.enforce_spell_settings = row[48] ? static_cast<uint8_t>(strtoul(row[48], nullptr, 10)) : 0;
e.archery_setting = row[49] ? static_cast<uint8_t>(strtoul(row[49], nullptr, 10)) : 0;
e.caster_range = row[50] ? static_cast<uint32_t>(strtoul(row[50], nullptr, 10)) : 300;
all_entries.push_back(e);
}
@@ -709,57 +709,57 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotData e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.owner_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spells_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.owner_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spells_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : "";
e.last_name = row[4] ? row[4] : "";
e.title = row[5] ? row[5] : "";
e.suffix = row[6] ? row[6] : "";
e.zone_id = static_cast<int16_t>(atoi(row[7]));
e.gender = static_cast<int8_t>(atoi(row[8]));
e.race = static_cast<int16_t>(atoi(row[9]));
e.class_ = static_cast<int8_t>(atoi(row[10]));
e.level = static_cast<uint8_t>(strtoul(row[11], nullptr, 10));
e.deity = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.creation_day = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.last_spawn = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.time_spawned = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.size = strtof(row[16], nullptr);
e.face = static_cast<int32_t>(atoi(row[17]));
e.hair_color = static_cast<int32_t>(atoi(row[18]));
e.hair_style = static_cast<int32_t>(atoi(row[19]));
e.beard = static_cast<int32_t>(atoi(row[20]));
e.beard_color = static_cast<int32_t>(atoi(row[21]));
e.eye_color_1 = static_cast<int32_t>(atoi(row[22]));
e.eye_color_2 = static_cast<int32_t>(atoi(row[23]));
e.drakkin_heritage = static_cast<int32_t>(atoi(row[24]));
e.drakkin_tattoo = static_cast<int32_t>(atoi(row[25]));
e.drakkin_details = static_cast<int32_t>(atoi(row[26]));
e.ac = static_cast<int16_t>(atoi(row[27]));
e.atk = static_cast<int32_t>(atoi(row[28]));
e.hp = static_cast<int32_t>(atoi(row[29]));
e.mana = static_cast<int32_t>(atoi(row[30]));
e.str = static_cast<int32_t>(atoi(row[31]));
e.sta = static_cast<int32_t>(atoi(row[32]));
e.cha = static_cast<int32_t>(atoi(row[33]));
e.dex = static_cast<int32_t>(atoi(row[34]));
e.int_ = static_cast<int32_t>(atoi(row[35]));
e.agi = static_cast<int32_t>(atoi(row[36]));
e.wis = static_cast<int32_t>(atoi(row[37]));
e.fire = static_cast<int16_t>(atoi(row[38]));
e.cold = static_cast<int16_t>(atoi(row[39]));
e.magic = static_cast<int16_t>(atoi(row[40]));
e.poison = static_cast<int16_t>(atoi(row[41]));
e.disease = static_cast<int16_t>(atoi(row[42]));
e.corruption = static_cast<int16_t>(atoi(row[43]));
e.show_helm = static_cast<uint32_t>(strtoul(row[44], nullptr, 10));
e.follow_distance = static_cast<uint32_t>(strtoul(row[45], nullptr, 10));
e.stop_melee_level = static_cast<uint8_t>(strtoul(row[46], nullptr, 10));
e.expansion_bitmask = static_cast<int32_t>(atoi(row[47]));
e.enforce_spell_settings = static_cast<uint8_t>(strtoul(row[48], nullptr, 10));
e.archery_setting = static_cast<uint8_t>(strtoul(row[49], nullptr, 10));
e.caster_range = static_cast<uint32_t>(strtoul(row[50], nullptr, 10));
e.zone_id = row[7] ? static_cast<int16_t>(atoi(row[7])) : 0;
e.gender = row[8] ? static_cast<int8_t>(atoi(row[8])) : 0;
e.race = row[9] ? static_cast<int16_t>(atoi(row[9])) : 0;
e.class_ = row[10] ? static_cast<int8_t>(atoi(row[10])) : 0;
e.level = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.deity = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.creation_day = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.last_spawn = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.time_spawned = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.size = row[16] ? strtof(row[16], nullptr) : 0;
e.face = row[17] ? static_cast<int32_t>(atoi(row[17])) : 1;
e.hair_color = row[18] ? static_cast<int32_t>(atoi(row[18])) : 1;
e.hair_style = row[19] ? static_cast<int32_t>(atoi(row[19])) : 1;
e.beard = row[20] ? static_cast<int32_t>(atoi(row[20])) : 0;
e.beard_color = row[21] ? static_cast<int32_t>(atoi(row[21])) : 1;
e.eye_color_1 = row[22] ? static_cast<int32_t>(atoi(row[22])) : 1;
e.eye_color_2 = row[23] ? static_cast<int32_t>(atoi(row[23])) : 1;
e.drakkin_heritage = row[24] ? static_cast<int32_t>(atoi(row[24])) : 0;
e.drakkin_tattoo = row[25] ? static_cast<int32_t>(atoi(row[25])) : 0;
e.drakkin_details = row[26] ? static_cast<int32_t>(atoi(row[26])) : 0;
e.ac = row[27] ? static_cast<int16_t>(atoi(row[27])) : 0;
e.atk = row[28] ? static_cast<int32_t>(atoi(row[28])) : 0;
e.hp = row[29] ? static_cast<int32_t>(atoi(row[29])) : 0;
e.mana = row[30] ? static_cast<int32_t>(atoi(row[30])) : 0;
e.str = row[31] ? static_cast<int32_t>(atoi(row[31])) : 75;
e.sta = row[32] ? static_cast<int32_t>(atoi(row[32])) : 75;
e.cha = row[33] ? static_cast<int32_t>(atoi(row[33])) : 75;
e.dex = row[34] ? static_cast<int32_t>(atoi(row[34])) : 75;
e.int_ = row[35] ? static_cast<int32_t>(atoi(row[35])) : 75;
e.agi = row[36] ? static_cast<int32_t>(atoi(row[36])) : 75;
e.wis = row[37] ? static_cast<int32_t>(atoi(row[37])) : 75;
e.fire = row[38] ? static_cast<int16_t>(atoi(row[38])) : 0;
e.cold = row[39] ? static_cast<int16_t>(atoi(row[39])) : 0;
e.magic = row[40] ? static_cast<int16_t>(atoi(row[40])) : 0;
e.poison = row[41] ? static_cast<int16_t>(atoi(row[41])) : 0;
e.disease = row[42] ? static_cast<int16_t>(atoi(row[42])) : 0;
e.corruption = row[43] ? static_cast<int16_t>(atoi(row[43])) : 0;
e.show_helm = row[44] ? static_cast<uint32_t>(strtoul(row[44], nullptr, 10)) : 0;
e.follow_distance = row[45] ? static_cast<uint32_t>(strtoul(row[45], nullptr, 10)) : 200;
e.stop_melee_level = row[46] ? static_cast<uint8_t>(strtoul(row[46], nullptr, 10)) : 255;
e.expansion_bitmask = row[47] ? static_cast<int32_t>(atoi(row[47])) : -1;
e.enforce_spell_settings = row[48] ? static_cast<uint8_t>(strtoul(row[48], nullptr, 10)) : 0;
e.archery_setting = row[49] ? static_cast<uint8_t>(strtoul(row[49], nullptr, 10)) : 0;
e.caster_range = row[50] ? static_cast<uint32_t>(strtoul(row[50], nullptr, 10)) : 300;
all_entries.push_back(e);
}
@@ -818,6 +818,162 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotData &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.spells_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.last_name) + "'");
v.push_back("'" + Strings::Escape(e.title) + "'");
v.push_back("'" + Strings::Escape(e.suffix) + "'");
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.gender));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.creation_day));
v.push_back(std::to_string(e.last_spawn));
v.push_back(std::to_string(e.time_spawned));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.face));
v.push_back(std::to_string(e.hair_color));
v.push_back(std::to_string(e.hair_style));
v.push_back(std::to_string(e.beard));
v.push_back(std::to_string(e.beard_color));
v.push_back(std::to_string(e.eye_color_1));
v.push_back(std::to_string(e.eye_color_2));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.drakkin_tattoo));
v.push_back(std::to_string(e.drakkin_details));
v.push_back(std::to_string(e.ac));
v.push_back(std::to_string(e.atk));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.str));
v.push_back(std::to_string(e.sta));
v.push_back(std::to_string(e.cha));
v.push_back(std::to_string(e.dex));
v.push_back(std::to_string(e.int_));
v.push_back(std::to_string(e.agi));
v.push_back(std::to_string(e.wis));
v.push_back(std::to_string(e.fire));
v.push_back(std::to_string(e.cold));
v.push_back(std::to_string(e.magic));
v.push_back(std::to_string(e.poison));
v.push_back(std::to_string(e.disease));
v.push_back(std::to_string(e.corruption));
v.push_back(std::to_string(e.show_helm));
v.push_back(std::to_string(e.follow_distance));
v.push_back(std::to_string(e.stop_melee_level));
v.push_back(std::to_string(e.expansion_bitmask));
v.push_back(std::to_string(e.enforce_spell_settings));
v.push_back(std::to_string(e.archery_setting));
v.push_back(std::to_string(e.caster_range));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotData> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.spells_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.last_name) + "'");
v.push_back("'" + Strings::Escape(e.title) + "'");
v.push_back("'" + Strings::Escape(e.suffix) + "'");
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.gender));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.creation_day));
v.push_back(std::to_string(e.last_spawn));
v.push_back(std::to_string(e.time_spawned));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.face));
v.push_back(std::to_string(e.hair_color));
v.push_back(std::to_string(e.hair_style));
v.push_back(std::to_string(e.beard));
v.push_back(std::to_string(e.beard_color));
v.push_back(std::to_string(e.eye_color_1));
v.push_back(std::to_string(e.eye_color_2));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.drakkin_tattoo));
v.push_back(std::to_string(e.drakkin_details));
v.push_back(std::to_string(e.ac));
v.push_back(std::to_string(e.atk));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.str));
v.push_back(std::to_string(e.sta));
v.push_back(std::to_string(e.cha));
v.push_back(std::to_string(e.dex));
v.push_back(std::to_string(e.int_));
v.push_back(std::to_string(e.agi));
v.push_back(std::to_string(e.wis));
v.push_back(std::to_string(e.fire));
v.push_back(std::to_string(e.cold));
v.push_back(std::to_string(e.magic));
v.push_back(std::to_string(e.poison));
v.push_back(std::to_string(e.disease));
v.push_back(std::to_string(e.corruption));
v.push_back(std::to_string(e.show_helm));
v.push_back(std::to_string(e.follow_distance));
v.push_back(std::to_string(e.stop_melee_level));
v.push_back(std::to_string(e.expansion_bitmask));
v.push_back(std::to_string(e.enforce_spell_settings));
v.push_back(std::to_string(e.archery_setting));
v.push_back(std::to_string(e.caster_range));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_DATA_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_HEAL_ROTATION_MEMBERS_REPOSITORY_H
@@ -112,8 +112,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_heal_rotation_members_id
)
);
@@ -122,9 +123,9 @@ public:
if (results.RowCount() == 1) {
BotHealRotationMembers e{};
e.member_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.member_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
return e;
}
@@ -249,9 +250,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationMembers e{};
e.member_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.member_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -276,9 +277,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationMembers e{};
e.member_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.member_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -337,6 +338,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotHealRotationMembers &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.member_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotHealRotationMembers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.member_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_HEAL_ROTATION_MEMBERS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_HEAL_ROTATION_TARGETS_REPOSITORY_H
@@ -112,8 +112,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_heal_rotation_targets_id
)
);
@@ -122,8 +123,8 @@ public:
if (results.RowCount() == 1) {
BotHealRotationTargets e{};
e.target_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.target_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.target_name = row[2] ? row[2] : "";
return e;
@@ -249,8 +250,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationTargets e{};
e.target_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.target_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.target_name = row[2] ? row[2] : "";
all_entries.push_back(e);
@@ -276,8 +277,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationTargets e{};
e.target_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.target_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.target_name = row[2] ? row[2] : "";
all_entries.push_back(e);
@@ -337,6 +338,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotHealRotationTargets &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.target_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back("'" + Strings::Escape(e.target_name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotHealRotationTargets> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.target_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back("'" + Strings::Escape(e.target_name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_HEAL_ROTATION_TARGETS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_HEAL_ROTATIONS_REPOSITORY_H
@@ -19,22 +19,22 @@
class BaseBotHealRotationsRepository {
public:
struct BotHealRotations {
uint32_t heal_rotation_index;
uint32_t bot_id;
uint32_t interval;
uint32_t fast_heals;
uint32_t adaptive_targeting;
uint32_t casting_override;
std::string safe_hp_base;
std::string safe_hp_cloth;
std::string safe_hp_leather;
std::string safe_hp_chain;
std::string safe_hp_plate;
std::string critical_hp_base;
std::string critical_hp_cloth;
std::string critical_hp_leather;
std::string critical_hp_chain;
std::string critical_hp_plate;
uint32_t heal_rotation_index;
uint32_t bot_id;
uint32_t interval_;
uint32_t fast_heals;
uint32_t adaptive_targeting;
uint32_t casting_override;
float safe_hp_base;
float safe_hp_cloth;
float safe_hp_leather;
float safe_hp_chain;
float safe_hp_plate;
float critical_hp_base;
float critical_hp_cloth;
float critical_hp_leather;
float critical_hp_chain;
float critical_hp_plate;
};
static std::string PrimaryKey()
@@ -47,7 +47,7 @@ public:
return {
"heal_rotation_index",
"bot_id",
"interval",
"`interval`",
"fast_heals",
"adaptive_targeting",
"casting_override",
@@ -69,7 +69,7 @@ public:
return {
"heal_rotation_index",
"bot_id",
"interval",
"`interval`",
"fast_heals",
"adaptive_targeting",
"casting_override",
@@ -125,7 +125,7 @@ public:
e.heal_rotation_index = 0;
e.bot_id = 0;
e.interval = 0;
e.interval_ = 0;
e.fast_heals = 0;
e.adaptive_targeting = 0;
e.casting_override = 0;
@@ -164,8 +164,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_heal_rotations_id
)
);
@@ -174,12 +175,12 @@ public:
if (results.RowCount() == 1) {
BotHealRotations e{};
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.interval = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.fast_heals = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.adaptive_targeting = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.casting_override = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.heal_rotation_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.interval_ = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.fast_heals = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.adaptive_targeting = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.casting_override = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
return e;
}
@@ -214,7 +215,7 @@ public:
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.bot_id));
v.push_back(columns[2] + " = " + std::to_string(e.interval));
v.push_back(columns[2] + " = " + std::to_string(e.interval_));
v.push_back(columns[3] + " = " + std::to_string(e.fast_heals));
v.push_back(columns[4] + " = " + std::to_string(e.adaptive_targeting));
v.push_back(columns[5] + " = " + std::to_string(e.casting_override));
@@ -251,7 +252,7 @@ public:
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.interval));
v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override));
@@ -296,7 +297,7 @@ public:
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.interval));
v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override));
@@ -343,12 +344,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotations e{};
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.interval = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.fast_heals = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.adaptive_targeting = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.casting_override = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.heal_rotation_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.interval_ = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.fast_heals = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.adaptive_targeting = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.casting_override = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -373,12 +374,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotations e{};
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.interval = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.fast_heals = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.adaptive_targeting = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.casting_override = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.heal_rotation_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.interval_ = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.fast_heals = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.adaptive_targeting = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.casting_override = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -437,6 +438,92 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotHealRotations &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override));
v.push_back(std::to_string(e.safe_hp_base));
v.push_back(std::to_string(e.safe_hp_cloth));
v.push_back(std::to_string(e.safe_hp_leather));
v.push_back(std::to_string(e.safe_hp_chain));
v.push_back(std::to_string(e.safe_hp_plate));
v.push_back(std::to_string(e.critical_hp_base));
v.push_back(std::to_string(e.critical_hp_cloth));
v.push_back(std::to_string(e.critical_hp_leather));
v.push_back(std::to_string(e.critical_hp_chain));
v.push_back(std::to_string(e.critical_hp_plate));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotHealRotations> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override));
v.push_back(std::to_string(e.safe_hp_base));
v.push_back(std::to_string(e.safe_hp_cloth));
v.push_back(std::to_string(e.safe_hp_leather));
v.push_back(std::to_string(e.safe_hp_chain));
v.push_back(std::to_string(e.safe_hp_plate));
v.push_back(std::to_string(e.critical_hp_base));
v.push_back(std::to_string(e.critical_hp_cloth));
v.push_back(std::to_string(e.critical_hp_leather));
v.push_back(std::to_string(e.critical_hp_chain));
v.push_back(std::to_string(e.critical_hp_plate));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_HEAL_ROTATIONS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_INSPECT_MESSAGES_REPOSITORY_H
@@ -108,8 +108,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_inspect_messages_id
)
);
@@ -118,7 +119,7 @@ public:
if (results.RowCount() == 1) {
BotInspectMessages e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.inspect_message = row[1] ? row[1] : "";
return e;
@@ -242,7 +243,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotInspectMessages e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(e);
@@ -268,7 +269,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotInspectMessages e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(e);
@@ -328,6 +329,64 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotInspectMessages &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.inspect_message) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotInspectMessages> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.inspect_message) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_INSPECT_MESSAGES_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_INVENTORIES_REPOSITORY_H
@@ -168,8 +168,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_inventories_id
)
);
@@ -178,23 +179,23 @@ public:
if (results.RowCount() == 1) {
BotInventories e{};
e.inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.slot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.inst_charges = static_cast<uint16_t>(strtoul(row[4], nullptr, 10));
e.inst_color = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.inst_no_drop = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.slot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.inst_charges = row[4] ? static_cast<uint16_t>(strtoul(row[4], nullptr, 10)) : 0;
e.inst_color = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.inst_no_drop = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.inst_custom_data = row[7] ? row[7] : "";
e.ornament_icon = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.ornament_id_file = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.ornament_hero_model = static_cast<int32_t>(atoi(row[10]));
e.augment_1 = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.augment_2 = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.augment_3 = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.augment_4 = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.augment_5 = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.augment_6 = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.ornament_icon = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.ornament_id_file = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.ornament_hero_model = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
e.augment_1 = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.augment_2 = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.augment_3 = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.augment_4 = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.augment_5 = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.augment_6 = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
return e;
}
@@ -361,23 +362,23 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotInventories e{};
e.inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.slot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.inst_charges = static_cast<uint16_t>(strtoul(row[4], nullptr, 10));
e.inst_color = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.inst_no_drop = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.slot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.inst_charges = row[4] ? static_cast<uint16_t>(strtoul(row[4], nullptr, 10)) : 0;
e.inst_color = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.inst_no_drop = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.inst_custom_data = row[7] ? row[7] : "";
e.ornament_icon = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.ornament_id_file = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.ornament_hero_model = static_cast<int32_t>(atoi(row[10]));
e.augment_1 = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.augment_2 = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.augment_3 = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.augment_4 = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.augment_5 = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.augment_6 = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.ornament_icon = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.ornament_id_file = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.ornament_hero_model = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
e.augment_1 = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.augment_2 = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.augment_3 = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.augment_4 = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.augment_5 = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.augment_6 = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -402,23 +403,23 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotInventories e{};
e.inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.slot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.inst_charges = static_cast<uint16_t>(strtoul(row[4], nullptr, 10));
e.inst_color = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.inst_no_drop = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.slot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.inst_charges = row[4] ? static_cast<uint16_t>(strtoul(row[4], nullptr, 10)) : 0;
e.inst_color = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.inst_no_drop = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.inst_custom_data = row[7] ? row[7] : "";
e.ornament_icon = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.ornament_id_file = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.ornament_hero_model = static_cast<int32_t>(atoi(row[10]));
e.augment_1 = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.augment_2 = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.augment_3 = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.augment_4 = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.augment_5 = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.augment_6 = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.ornament_icon = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.ornament_id_file = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.ornament_hero_model = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
e.augment_1 = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.augment_2 = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.augment_3 = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.augment_4 = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.augment_5 = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.augment_6 = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -477,6 +478,94 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotInventories &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.inventories_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.inst_charges));
v.push_back(std::to_string(e.inst_color));
v.push_back(std::to_string(e.inst_no_drop));
v.push_back("'" + Strings::Escape(e.inst_custom_data) + "'");
v.push_back(std::to_string(e.ornament_icon));
v.push_back(std::to_string(e.ornament_id_file));
v.push_back(std::to_string(e.ornament_hero_model));
v.push_back(std::to_string(e.augment_1));
v.push_back(std::to_string(e.augment_2));
v.push_back(std::to_string(e.augment_3));
v.push_back(std::to_string(e.augment_4));
v.push_back(std::to_string(e.augment_5));
v.push_back(std::to_string(e.augment_6));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotInventories> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.inventories_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.inst_charges));
v.push_back(std::to_string(e.inst_color));
v.push_back(std::to_string(e.inst_no_drop));
v.push_back("'" + Strings::Escape(e.inst_custom_data) + "'");
v.push_back(std::to_string(e.ornament_icon));
v.push_back(std::to_string(e.ornament_id_file));
v.push_back(std::to_string(e.ornament_hero_model));
v.push_back(std::to_string(e.augment_1));
v.push_back(std::to_string(e.augment_2));
v.push_back(std::to_string(e.augment_3));
v.push_back(std::to_string(e.augment_4));
v.push_back(std::to_string(e.augment_5));
v.push_back(std::to_string(e.augment_6));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_INVENTORIES_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_OWNER_OPTIONS_REPOSITORY_H
@@ -112,8 +112,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_owner_options_id
)
);
@@ -122,9 +123,9 @@ public:
if (results.RowCount() == 1) {
BotOwnerOptions e{};
e.owner_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.option_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
e.option_value = static_cast<uint16_t>(strtoul(row[2], nullptr, 10));
e.owner_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.option_type = row[1] ? static_cast<uint16_t>(strtoul(row[1], nullptr, 10)) : 0;
e.option_value = row[2] ? static_cast<uint16_t>(strtoul(row[2], nullptr, 10)) : 0;
return e;
}
@@ -250,9 +251,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotOwnerOptions e{};
e.owner_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.option_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
e.option_value = static_cast<uint16_t>(strtoul(row[2], nullptr, 10));
e.owner_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.option_type = row[1] ? static_cast<uint16_t>(strtoul(row[1], nullptr, 10)) : 0;
e.option_value = row[2] ? static_cast<uint16_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -277,9 +278,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotOwnerOptions e{};
e.owner_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.option_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
e.option_value = static_cast<uint16_t>(strtoul(row[2], nullptr, 10));
e.owner_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.option_type = row[1] ? static_cast<uint16_t>(strtoul(row[1], nullptr, 10)) : 0;
e.option_value = row[2] ? static_cast<uint16_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -338,6 +339,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotOwnerOptions &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.option_type));
v.push_back(std::to_string(e.option_value));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotOwnerOptions> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.option_type));
v.push_back(std::to_string(e.option_value));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_OWNER_OPTIONS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_PET_BUFFS_REPOSITORY_H
@@ -120,8 +120,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_pet_buffs_id
)
);
@@ -130,11 +131,11 @@ public:
if (results.RowCount() == 1) {
BotPetBuffs e{};
e.pet_buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.caster_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.duration = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.pet_buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
return e;
}
@@ -265,11 +266,11 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotPetBuffs e{};
e.pet_buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.caster_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.duration = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.pet_buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -294,11 +295,11 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotPetBuffs e{};
e.pet_buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.caster_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.duration = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.pet_buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -357,6 +358,70 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotPetBuffs &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_buffs_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotPetBuffs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_buffs_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_PET_BUFFS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_PET_INVENTORIES_REPOSITORY_H
@@ -112,8 +112,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_pet_inventories_id
)
);
@@ -122,9 +123,9 @@ public:
if (results.RowCount() == 1) {
BotPetInventories e{};
e.pet_inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.pet_inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
return e;
}
@@ -249,9 +250,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotPetInventories e{};
e.pet_inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.pet_inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -276,9 +277,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotPetInventories e{};
e.pet_inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.pet_inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -337,6 +338,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotPetInventories &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_inventories_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotPetInventories> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_inventories_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.item_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_PET_INVENTORIES_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_PETS_REPOSITORY_H
@@ -124,8 +124,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_pets_id
)
);
@@ -134,12 +135,12 @@ public:
if (results.RowCount() == 1) {
BotPets e{};
e.pets_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.pets_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.spell_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : "";
e.mana = static_cast<int32_t>(atoi(row[4]));
e.hp = static_cast<int32_t>(atoi(row[5]));
e.mana = row[4] ? static_cast<int32_t>(atoi(row[4])) : 0;
e.hp = row[5] ? static_cast<int32_t>(atoi(row[5])) : 0;
return e;
}
@@ -273,12 +274,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotPets e{};
e.pets_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.pets_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.spell_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : "";
e.mana = static_cast<int32_t>(atoi(row[4]));
e.hp = static_cast<int32_t>(atoi(row[5]));
e.mana = row[4] ? static_cast<int32_t>(atoi(row[4])) : 0;
e.hp = row[5] ? static_cast<int32_t>(atoi(row[5])) : 0;
all_entries.push_back(e);
}
@@ -303,12 +304,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotPets e{};
e.pets_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.pets_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.spell_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : "";
e.mana = static_cast<int32_t>(atoi(row[4]));
e.hp = static_cast<int32_t>(atoi(row[5]));
e.mana = row[4] ? static_cast<int32_t>(atoi(row[4])) : 0;
e.hp = row[5] ? static_cast<int32_t>(atoi(row[5])) : 0;
all_entries.push_back(e);
}
@@ -367,6 +368,72 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotPets &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.hp));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotPets> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.hp));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_PETS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_SPELL_CASTING_CHANCES_REPOSITORY_H
@@ -180,8 +180,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_spell_casting_chances_id
)
);
@@ -190,26 +191,26 @@ public:
if (results.RowCount() == 1) {
BotSpellCastingChances e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.spell_type_index = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.class_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.stance_index = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.nHSND_value = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.pH_value = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.pS_value = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.pHS_value = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.pN_value = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.pHN_value = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
e.pSN_value = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.pHSN_value = static_cast<uint8_t>(strtoul(row[11], nullptr, 10));
e.pD_value = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.pHD_value = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.pSD_value = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.pHSD_value = static_cast<uint8_t>(strtoul(row[15], nullptr, 10));
e.pND_value = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
e.pHND_value = static_cast<uint8_t>(strtoul(row[17], nullptr, 10));
e.pSND_value = static_cast<uint8_t>(strtoul(row[18], nullptr, 10));
e.pHSND_value = static_cast<uint8_t>(strtoul(row[19], nullptr, 10));
e.id = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.spell_type_index = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
e.class_id = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
e.stance_index = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.nHSND_value = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.pH_value = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.pS_value = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.pHS_value = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.pN_value = row[8] ? static_cast<uint8_t>(strtoul(row[8], nullptr, 10)) : 0;
e.pHN_value = row[9] ? static_cast<uint8_t>(strtoul(row[9], nullptr, 10)) : 0;
e.pSN_value = row[10] ? static_cast<uint8_t>(strtoul(row[10], nullptr, 10)) : 0;
e.pHSN_value = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.pD_value = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
e.pHD_value = row[13] ? static_cast<uint8_t>(strtoul(row[13], nullptr, 10)) : 0;
e.pSD_value = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
e.pHSD_value = row[15] ? static_cast<uint8_t>(strtoul(row[15], nullptr, 10)) : 0;
e.pND_value = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
e.pHND_value = row[17] ? static_cast<uint8_t>(strtoul(row[17], nullptr, 10)) : 0;
e.pSND_value = row[18] ? static_cast<uint8_t>(strtoul(row[18], nullptr, 10)) : 0;
e.pHSND_value = row[19] ? static_cast<uint8_t>(strtoul(row[19], nullptr, 10)) : 0;
return e;
}
@@ -385,26 +386,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellCastingChances e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.spell_type_index = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.class_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.stance_index = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.nHSND_value = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.pH_value = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.pS_value = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.pHS_value = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.pN_value = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.pHN_value = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
e.pSN_value = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.pHSN_value = static_cast<uint8_t>(strtoul(row[11], nullptr, 10));
e.pD_value = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.pHD_value = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.pSD_value = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.pHSD_value = static_cast<uint8_t>(strtoul(row[15], nullptr, 10));
e.pND_value = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
e.pHND_value = static_cast<uint8_t>(strtoul(row[17], nullptr, 10));
e.pSND_value = static_cast<uint8_t>(strtoul(row[18], nullptr, 10));
e.pHSND_value = static_cast<uint8_t>(strtoul(row[19], nullptr, 10));
e.id = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.spell_type_index = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
e.class_id = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
e.stance_index = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.nHSND_value = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.pH_value = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.pS_value = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.pHS_value = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.pN_value = row[8] ? static_cast<uint8_t>(strtoul(row[8], nullptr, 10)) : 0;
e.pHN_value = row[9] ? static_cast<uint8_t>(strtoul(row[9], nullptr, 10)) : 0;
e.pSN_value = row[10] ? static_cast<uint8_t>(strtoul(row[10], nullptr, 10)) : 0;
e.pHSN_value = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.pD_value = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
e.pHD_value = row[13] ? static_cast<uint8_t>(strtoul(row[13], nullptr, 10)) : 0;
e.pSD_value = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
e.pHSD_value = row[15] ? static_cast<uint8_t>(strtoul(row[15], nullptr, 10)) : 0;
e.pND_value = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
e.pHND_value = row[17] ? static_cast<uint8_t>(strtoul(row[17], nullptr, 10)) : 0;
e.pSND_value = row[18] ? static_cast<uint8_t>(strtoul(row[18], nullptr, 10)) : 0;
e.pHSND_value = row[19] ? static_cast<uint8_t>(strtoul(row[19], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -429,26 +430,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellCastingChances e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.spell_type_index = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.class_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.stance_index = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.nHSND_value = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.pH_value = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.pS_value = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.pHS_value = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.pN_value = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.pHN_value = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
e.pSN_value = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.pHSN_value = static_cast<uint8_t>(strtoul(row[11], nullptr, 10));
e.pD_value = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.pHD_value = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.pSD_value = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.pHSD_value = static_cast<uint8_t>(strtoul(row[15], nullptr, 10));
e.pND_value = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
e.pHND_value = static_cast<uint8_t>(strtoul(row[17], nullptr, 10));
e.pSND_value = static_cast<uint8_t>(strtoul(row[18], nullptr, 10));
e.pHSND_value = static_cast<uint8_t>(strtoul(row[19], nullptr, 10));
e.id = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.spell_type_index = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
e.class_id = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
e.stance_index = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.nHSND_value = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.pH_value = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.pS_value = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.pHS_value = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.pN_value = row[8] ? static_cast<uint8_t>(strtoul(row[8], nullptr, 10)) : 0;
e.pHN_value = row[9] ? static_cast<uint8_t>(strtoul(row[9], nullptr, 10)) : 0;
e.pSN_value = row[10] ? static_cast<uint8_t>(strtoul(row[10], nullptr, 10)) : 0;
e.pHSN_value = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.pD_value = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
e.pHD_value = row[13] ? static_cast<uint8_t>(strtoul(row[13], nullptr, 10)) : 0;
e.pSD_value = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
e.pHSD_value = row[15] ? static_cast<uint8_t>(strtoul(row[15], nullptr, 10)) : 0;
e.pND_value = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
e.pHND_value = row[17] ? static_cast<uint8_t>(strtoul(row[17], nullptr, 10)) : 0;
e.pSND_value = row[18] ? static_cast<uint8_t>(strtoul(row[18], nullptr, 10)) : 0;
e.pHSND_value = row[19] ? static_cast<uint8_t>(strtoul(row[19], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -507,6 +508,100 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotSpellCastingChances &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.spell_type_index));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.stance_index));
v.push_back(std::to_string(e.nHSND_value));
v.push_back(std::to_string(e.pH_value));
v.push_back(std::to_string(e.pS_value));
v.push_back(std::to_string(e.pHS_value));
v.push_back(std::to_string(e.pN_value));
v.push_back(std::to_string(e.pHN_value));
v.push_back(std::to_string(e.pSN_value));
v.push_back(std::to_string(e.pHSN_value));
v.push_back(std::to_string(e.pD_value));
v.push_back(std::to_string(e.pHD_value));
v.push_back(std::to_string(e.pSD_value));
v.push_back(std::to_string(e.pHSD_value));
v.push_back(std::to_string(e.pND_value));
v.push_back(std::to_string(e.pHND_value));
v.push_back(std::to_string(e.pSND_value));
v.push_back(std::to_string(e.pHSND_value));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotSpellCastingChances> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.spell_type_index));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.stance_index));
v.push_back(std::to_string(e.nHSND_value));
v.push_back(std::to_string(e.pH_value));
v.push_back(std::to_string(e.pS_value));
v.push_back(std::to_string(e.pHS_value));
v.push_back(std::to_string(e.pN_value));
v.push_back(std::to_string(e.pHN_value));
v.push_back(std::to_string(e.pSN_value));
v.push_back(std::to_string(e.pHSN_value));
v.push_back(std::to_string(e.pD_value));
v.push_back(std::to_string(e.pHD_value));
v.push_back(std::to_string(e.pSD_value));
v.push_back(std::to_string(e.pHSD_value));
v.push_back(std::to_string(e.pND_value));
v.push_back(std::to_string(e.pHND_value));
v.push_back(std::to_string(e.pSND_value));
v.push_back(std::to_string(e.pHSND_value));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_SPELL_CASTING_CHANCES_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_SPELL_SETTINGS_REPOSITORY_H
@@ -128,8 +128,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_spell_settings_id
)
);
@@ -138,13 +139,13 @@ public:
if (results.RowCount() == 1) {
BotSpellSettings e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<int32_t>(atoi(row[1]));
e.spell_id = static_cast<int16_t>(atoi(row[2]));
e.priority = static_cast<int16_t>(atoi(row[3]));
e.min_hp = static_cast<int16_t>(atoi(row[4]));
e.max_hp = static_cast<int16_t>(atoi(row[5]));
e.is_enabled = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spell_id = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.priority = row[3] ? static_cast<int16_t>(atoi(row[3])) : 0;
e.min_hp = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
e.max_hp = row[5] ? static_cast<int16_t>(atoi(row[5])) : 0;
e.is_enabled = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 1;
return e;
}
@@ -281,13 +282,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellSettings e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<int32_t>(atoi(row[1]));
e.spell_id = static_cast<int16_t>(atoi(row[2]));
e.priority = static_cast<int16_t>(atoi(row[3]));
e.min_hp = static_cast<int16_t>(atoi(row[4]));
e.max_hp = static_cast<int16_t>(atoi(row[5]));
e.is_enabled = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spell_id = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.priority = row[3] ? static_cast<int16_t>(atoi(row[3])) : 0;
e.min_hp = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
e.max_hp = row[5] ? static_cast<int16_t>(atoi(row[5])) : 0;
e.is_enabled = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 1;
all_entries.push_back(e);
}
@@ -312,13 +313,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellSettings e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.bot_id = static_cast<int32_t>(atoi(row[1]));
e.spell_id = static_cast<int16_t>(atoi(row[2]));
e.priority = static_cast<int16_t>(atoi(row[3]));
e.min_hp = static_cast<int16_t>(atoi(row[4]));
e.max_hp = static_cast<int16_t>(atoi(row[5]));
e.is_enabled = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spell_id = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.priority = row[3] ? static_cast<int16_t>(atoi(row[3])) : 0;
e.min_hp = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
e.max_hp = row[5] ? static_cast<int16_t>(atoi(row[5])) : 0;
e.is_enabled = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 1;
all_entries.push_back(e);
}
@@ -377,6 +378,74 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotSpellSettings &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.is_enabled));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotSpellSettings> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.is_enabled));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_SPELL_SETTINGS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_SPELLS_ENTRIES_REPOSITORY_H
@@ -160,8 +160,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_spells_entries_id
)
);
@@ -170,21 +171,21 @@ public:
if (results.RowCount() == 1) {
BotSpellsEntries e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.npc_spells_id = static_cast<int32_t>(atoi(row[1]));
e.spellid = static_cast<int16_t>(atoi(row[2]));
e.type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.manacost = static_cast<int16_t>(atoi(row[6]));
e.recast_delay = static_cast<int32_t>(atoi(row[7]));
e.priority = static_cast<int16_t>(atoi(row[8]));
e.resist_adjust = static_cast<int32_t>(atoi(row[9]));
e.min_hp = static_cast<int16_t>(atoi(row[10]));
e.max_hp = static_cast<int16_t>(atoi(row[11]));
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.npc_spells_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spellid = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.type = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.minlevel = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.maxlevel = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 255;
e.manacost = row[6] ? static_cast<int16_t>(atoi(row[6])) : -1;
e.recast_delay = row[7] ? static_cast<int32_t>(atoi(row[7])) : -1;
e.priority = row[8] ? static_cast<int16_t>(atoi(row[8])) : 0;
e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.bucket_name = row[12] ? row[12] : "";
e.bucket_value = row[13] ? row[13] : "";
e.bucket_comparison = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.bucket_comparison = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
return e;
}
@@ -345,21 +346,21 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellsEntries e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.npc_spells_id = static_cast<int32_t>(atoi(row[1]));
e.spellid = static_cast<int16_t>(atoi(row[2]));
e.type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.manacost = static_cast<int16_t>(atoi(row[6]));
e.recast_delay = static_cast<int32_t>(atoi(row[7]));
e.priority = static_cast<int16_t>(atoi(row[8]));
e.resist_adjust = static_cast<int32_t>(atoi(row[9]));
e.min_hp = static_cast<int16_t>(atoi(row[10]));
e.max_hp = static_cast<int16_t>(atoi(row[11]));
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.npc_spells_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spellid = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.type = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.minlevel = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.maxlevel = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 255;
e.manacost = row[6] ? static_cast<int16_t>(atoi(row[6])) : -1;
e.recast_delay = row[7] ? static_cast<int32_t>(atoi(row[7])) : -1;
e.priority = row[8] ? static_cast<int16_t>(atoi(row[8])) : 0;
e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.bucket_name = row[12] ? row[12] : "";
e.bucket_value = row[13] ? row[13] : "";
e.bucket_comparison = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.bucket_comparison = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -384,21 +385,21 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellsEntries e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.npc_spells_id = static_cast<int32_t>(atoi(row[1]));
e.spellid = static_cast<int16_t>(atoi(row[2]));
e.type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.manacost = static_cast<int16_t>(atoi(row[6]));
e.recast_delay = static_cast<int32_t>(atoi(row[7]));
e.priority = static_cast<int16_t>(atoi(row[8]));
e.resist_adjust = static_cast<int32_t>(atoi(row[9]));
e.min_hp = static_cast<int16_t>(atoi(row[10]));
e.max_hp = static_cast<int16_t>(atoi(row[11]));
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.npc_spells_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spellid = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.type = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.minlevel = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.maxlevel = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 255;
e.manacost = row[6] ? static_cast<int16_t>(atoi(row[6])) : -1;
e.recast_delay = row[7] ? static_cast<int32_t>(atoi(row[7])) : -1;
e.priority = row[8] ? static_cast<int16_t>(atoi(row[8])) : 0;
e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.bucket_name = row[12] ? row[12] : "";
e.bucket_value = row[13] ? row[13] : "";
e.bucket_comparison = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.bucket_comparison = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -457,6 +458,90 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotSpellsEntries &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.npc_spells_id));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.manacost));
v.push_back(std::to_string(e.recast_delay));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back("'" + Strings::Escape(e.bucket_name) + "'");
v.push_back("'" + Strings::Escape(e.bucket_value) + "'");
v.push_back(std::to_string(e.bucket_comparison));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotSpellsEntries> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.npc_spells_id));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.manacost));
v.push_back(std::to_string(e.recast_delay));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back("'" + Strings::Escape(e.bucket_name) + "'");
v.push_back("'" + Strings::Escape(e.bucket_value) + "'");
v.push_back(std::to_string(e.bucket_comparison));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_SPELLS_ENTRIES_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_STANCES_REPOSITORY_H
@@ -108,8 +108,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
bot_stances_id
)
);
@@ -118,8 +119,8 @@ public:
if (results.RowCount() == 1) {
BotStances e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.stance_id = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
return e;
}
@@ -242,8 +243,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotStances e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.stance_id = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -268,8 +269,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotStances e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.stance_id = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -328,6 +329,64 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotStances &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.stance_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotStances> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.stance_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_STANCES_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_STARTING_ITEMS_REPOSITORY_H
@@ -16,7 +16,6 @@
#include "../../strings.h"
#include <ctime>
class BaseBotStartingItemsRepository {
public:
struct BotStartingItems {
@@ -25,6 +24,7 @@ public:
uint32_t classes;
uint32_t item_id;
uint8_t item_charges;
uint8_t min_status;
int32_t slot_id;
int8_t min_expansion;
int8_t max_expansion;
@@ -45,6 +45,7 @@ public:
"classes",
"item_id",
"item_charges",
"min_status",
"slot_id",
"min_expansion",
"max_expansion",
@@ -61,6 +62,7 @@ public:
"classes",
"item_id",
"item_charges",
"min_status",
"slot_id",
"min_expansion",
"max_expansion",
@@ -111,6 +113,7 @@ public:
e.classes = 0;
e.item_id = 0;
e.item_charges = 1;
e.min_status = 0;
e.slot_id = -1;
e.min_expansion = -1;
e.max_expansion = -1;
@@ -152,16 +155,17 @@ public:
if (results.RowCount() == 1) {
BotStartingItems e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.races = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.classes = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.item_charges = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.slot_id = static_cast<int32_t>(atoi(row[5]));
e.min_expansion = static_cast<int8_t>(atoi(row[6]));
e.max_expansion = static_cast<int8_t>(atoi(row[7]));
e.content_flags = row[8] ? row[8] : "";
e.content_flags_disabled = row[9] ? row[9] : "";
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.races = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.classes = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.item_charges = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 1;
e.min_status = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.slot_id = row[6] ? static_cast<int32_t>(atoi(row[6])) : -1;
e.min_expansion = row[7] ? static_cast<int8_t>(atoi(row[7])) : -1;
e.max_expansion = row[8] ? static_cast<int8_t>(atoi(row[8])) : -1;
e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
return e;
}
@@ -199,11 +203,12 @@ public:
v.push_back(columns[2] + " = " + std::to_string(e.classes));
v.push_back(columns[3] + " = " + std::to_string(e.item_id));
v.push_back(columns[4] + " = " + std::to_string(e.item_charges));
v.push_back(columns[5] + " = " + std::to_string(e.slot_id));
v.push_back(columns[6] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[7] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[8] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[9] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
v.push_back(columns[5] + " = " + std::to_string(e.min_status));
v.push_back(columns[6] + " = " + std::to_string(e.slot_id));
v.push_back(columns[7] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[8] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[9] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[10] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
@@ -230,6 +235,7 @@ public:
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
@@ -269,6 +275,7 @@ public:
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
@@ -307,16 +314,17 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotStartingItems e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.races = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.classes = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.item_charges = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.slot_id = static_cast<int32_t>(atoi(row[5]));
e.min_expansion = static_cast<int8_t>(atoi(row[6]));
e.max_expansion = static_cast<int8_t>(atoi(row[7]));
e.content_flags = row[8] ? row[8] : "";
e.content_flags_disabled = row[9] ? row[9] : "";
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.races = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.classes = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.item_charges = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 1;
e.min_status = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.slot_id = row[6] ? static_cast<int32_t>(atoi(row[6])) : -1;
e.min_expansion = row[7] ? static_cast<int8_t>(atoi(row[7])) : -1;
e.max_expansion = row[8] ? static_cast<int8_t>(atoi(row[8])) : -1;
e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
all_entries.push_back(e);
}
@@ -341,16 +349,17 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotStartingItems e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.races = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.classes = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.item_charges = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.slot_id = static_cast<int32_t>(atoi(row[5]));
e.min_expansion = static_cast<int8_t>(atoi(row[6]));
e.max_expansion = static_cast<int8_t>(atoi(row[7]));
e.content_flags = row[8] ? row[8] : "";
e.content_flags_disabled = row[9] ? row[9] : "";
e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.races = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.classes = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.item_charges = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 1;
e.min_status = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.slot_id = row[6] ? static_cast<int32_t>(atoi(row[6])) : -1;
e.min_expansion = row[7] ? static_cast<int8_t>(atoi(row[7])) : -1;
e.max_expansion = row[8] ? static_cast<int8_t>(atoi(row[8])) : -1;
e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
all_entries.push_back(e);
}
@@ -409,6 +418,82 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotStartingItems &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.races));
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotStartingItems> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.races));
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_STARTING_ITEMS_REPOSITORY_H
@@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_BOT_TIMERS_REPOSITORY_H
@@ -16,7 +16,6 @@
#include "../../strings.h"
#include <ctime>
class BaseBotTimersRepository {
public:
struct BotTimers {
@@ -148,15 +147,15 @@ public:
if (results.RowCount() == 1) {
BotTimers e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.timer_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.timer_value = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.recast_time = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.is_spell = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.is_disc = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.is_item = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.timer_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.timer_value = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.recast_time = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.is_spell = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.is_disc = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.spell_id = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.is_item = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.item_id = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
return e;
}
@@ -300,15 +299,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotTimers e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.timer_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.timer_value = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.recast_time = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.is_spell = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.is_disc = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.is_item = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.timer_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.timer_value = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.recast_time = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.is_spell = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.is_disc = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.spell_id = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.is_item = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.item_id = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -333,15 +332,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
BotTimers e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.timer_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.timer_value = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.recast_time = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.is_spell = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.is_disc = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.is_item = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.timer_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.timer_value = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.recast_time = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.is_spell = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.is_disc = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.spell_id = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.is_item = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.item_id = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
all_entries.push_back(e);
}
@@ -400,6 +399,78 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotTimers &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.timer_id));
v.push_back(std::to_string(e.timer_value));
v.push_back(std::to_string(e.recast_time));
v.push_back(std::to_string(e.is_spell));
v.push_back(std::to_string(e.is_disc));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.is_item));
v.push_back(std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotTimers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.timer_id));
v.push_back(std::to_string(e.timer_value));
v.push_back(std::to_string(e.recast_time));
v.push_back(std::to_string(e.is_spell));
v.push_back(std::to_string(e.is_disc));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.is_item));
v.push_back(std::to_string(e.item_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BOT_TIMERS_REPOSITORY_H
@@ -19,13 +19,13 @@
class BasePetsBeastlordDataRepository {
public:
struct PetsBeastlordData {
uint32_t player_race;
uint32_t pet_race;
uint8_t texture;
uint8_t helm_texture;
uint8_t gender;
std::string size_modifier;
uint8_t face;
uint32_t player_race;
uint32_t pet_race;
uint8_t texture;
uint8_t helm_texture;
uint8_t gender;
float size_modifier;
uint8_t face;
};
static std::string PrimaryKey()
@@ -37,7 +37,7 @@ public:
uint32_t respawn_time;
uint32_t respawn_var;
int8_t triggered_number;
int8_t group;
int8_t group_;
int8_t despawn_when_triggered;
int8_t undetectable;
int8_t min_expansion;
@@ -72,7 +72,7 @@ public:
"respawn_time",
"respawn_var",
"triggered_number",
"group",
"`group`",
"despawn_when_triggered",
"undetectable",
"min_expansion",
@@ -103,7 +103,7 @@ public:
"respawn_time",
"respawn_var",
"triggered_number",
"group",
"`group`",
"despawn_when_triggered",
"undetectable",
"min_expansion",
@@ -168,7 +168,7 @@ public:
e.respawn_time = 60;
e.respawn_var = 0;
e.triggered_number = 0;
e.group = 0;
e.group_ = 0;
e.despawn_when_triggered = 0;
e.undetectable = 0;
e.min_expansion = -1;
@@ -229,7 +229,7 @@ public:
e.respawn_time = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 60;
e.respawn_var = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
e.triggered_number = row[17] ? static_cast<int8_t>(atoi(row[17])) : 0;
e.group = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.group_ = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.despawn_when_triggered = row[19] ? static_cast<int8_t>(atoi(row[19])) : 0;
e.undetectable = row[20] ? static_cast<int8_t>(atoi(row[20])) : 0;
e.min_expansion = row[21] ? static_cast<int8_t>(atoi(row[21])) : -1;
@@ -286,7 +286,7 @@ public:
v.push_back(columns[15] + " = " + std::to_string(e.respawn_time));
v.push_back(columns[16] + " = " + std::to_string(e.respawn_var));
v.push_back(columns[17] + " = " + std::to_string(e.triggered_number));
v.push_back(columns[18] + " = " + std::to_string(e.group));
v.push_back(columns[18] + " = " + std::to_string(e.group_));
v.push_back(columns[19] + " = " + std::to_string(e.despawn_when_triggered));
v.push_back(columns[20] + " = " + std::to_string(e.undetectable));
v.push_back(columns[21] + " = " + std::to_string(e.min_expansion));
@@ -332,7 +332,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));
@@ -386,7 +386,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));
@@ -444,7 +444,7 @@ public:
e.respawn_time = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 60;
e.respawn_var = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
e.triggered_number = row[17] ? static_cast<int8_t>(atoi(row[17])) : 0;
e.group = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.group_ = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.despawn_when_triggered = row[19] ? static_cast<int8_t>(atoi(row[19])) : 0;
e.undetectable = row[20] ? static_cast<int8_t>(atoi(row[20])) : 0;
e.min_expansion = row[21] ? static_cast<int8_t>(atoi(row[21])) : -1;
@@ -493,7 +493,7 @@ public:
e.respawn_time = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 60;
e.respawn_var = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
e.triggered_number = row[17] ? static_cast<int8_t>(atoi(row[17])) : 0;
e.group = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.group_ = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.despawn_when_triggered = row[19] ? static_cast<int8_t>(atoi(row[19])) : 0;
e.undetectable = row[20] ? static_cast<int8_t>(atoi(row[20])) : 0;
e.min_expansion = row[21] ? static_cast<int8_t>(atoi(row[21])) : -1;
@@ -592,7 +592,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));
@@ -639,7 +639,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));
+39
View File
@@ -44,7 +44,46 @@ public:
*/
// Custom extended repository methods here
static bool SaveAllHelmAppearances(Database& db, const uint32 owner_id, const bool show_flag)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `show_helm` = {} WHERE `owner_id` = {}",
TableName(),
show_flag ? 1 : 0,
owner_id
)
);
return results.Success();
}
static bool ToggleAllHelmAppearances(Database& db, const uint32 owner_id)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `show_helm` = (`show_helm` XOR '1') WHERE `owner_id` = {}",
TableName(),
owner_id
)
);
return results.Success();
}
static bool SaveAllFollowDistances(Database& db, const uint32 owner_id, const uint32 follow_distance)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `follow_distance` = {} WHERE `owner_id` = {}",
TableName(),
follow_distance,
owner_id
)
);
return results.Success();
}
};
#endif //EQEMU_BOT_DATA_REPOSITORY_H
@@ -44,7 +44,36 @@ public:
*/
// Custom extended repository methods here
static bool SaveAllInspectMessages(Database& db, const uint32 owner_id, const std::string& inspect_message)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
INSERT INTO `bot_inspect_messages` (`bot_id`, `inspect_message`) VALUES
(SELECT `bot_id`, '{}' inspect_message FROM `bot_data` WHERE `owner_id` = {})
),
inspect_message,
owner_id
)
);
return results.Success();
}
static bool DeleteAllInspectMessages(Database& db, const uint32 owner_id)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
DELETE FROM `bot_inspect_messages`
WHERE `bot_id` IN (SELECT `bot_id` FROM `bot_data` WHERE `owner_id` = {})
),
owner_id
)
);
return results.Success();
}
};
#endif //EQEMU_BOT_INSPECT_MESSAGES_REPOSITORY_H
@@ -44,7 +44,57 @@ public:
*/
// Custom extended repository methods here
static bool UpdateItemColors(Database& db, const uint32 bot_id, const uint32 color, const std::string& where_clause)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `inst_color` = {} WHERE `bot_id` = {} AND `slot_id` {}",
TableName(),
color,
bot_id,
where_clause
)
);
return results.Success();
}
static bool SaveAllArmorColors(Database& db, const uint32 owner_id, const uint32 color)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `inst_color` = {} WHERE `slot_id` IN ({}, {}, {}, {}, {}, {}, {}) AND `bot_id` IN (SELECT `bot_id` FROM `bot_data` WHERE `owner_id` = {})",
TableName(),
color,
EQ::invslot::slotHead,
EQ::invslot::slotChest,
EQ::invslot::slotArms,
EQ::invslot::slotWrist1,
EQ::invslot::slotWrist2,
EQ::invslot::slotHands,
EQ::invslot::slotLegs,
EQ::invslot::slotFeet,
owner_id
)
);
return results.Success();
}
static bool SaveAllArmorColorsBySlot(Database& db, const uint32 owner_id, const int16 slot_id, const uint32 color)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `inst_color` = {} WHERE `slot_id` = {} AND `bot_id` IN (SELECT `bot_id` FROM `bot_data` WHERE `owner_id` = {})",
TableName(),
color,
slot_id,
owner_id
)
);
return results.Success();
}
};
#endif //EQEMU_BOT_INVENTORIES_REPOSITORY_H
@@ -141,7 +141,7 @@ public:
{
db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `zone_id` = {}, `instance_id` = 0, `x` = {:.2f}, `y` = {:.2f}, `z` = {:.2f}`, `heading` = {:.2f}, `was_at_graveyard` = 1 WHERE `instance_id` = {}",
"UPDATE `{}` SET `zone_id` = {}, `instance_id` = 0, `x` = {:.2f}, `y` = {:.2f}, `z` = {:.2f}, `heading` = {:.2f}, `was_at_graveyard` = 1 WHERE `instance_id` = {}",
TableName(),
graveyard_zone_id,
position.x,
@@ -163,7 +163,7 @@ public:
{
db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `zone_id` = {}, `instance_id` = {}, `x` = {:.2f}, `y` = {:.2f}, `z` = {:.2f}`, `heading` = {:.2f}, `was_at_graveyard` = 1 WHERE `{}` = {}",
"UPDATE `{}` SET `zone_id` = {}, `instance_id` = {}, `x` = {:.2f}, `y` = {:.2f}, `z` = {:.2f}, `heading` = {:.2f}, `was_at_graveyard` = 1 WHERE `{}` = {}",
TableName(),
zone_id,
instance_id,
@@ -76,6 +76,48 @@ public:
return grid_entries;
}
static int GetHighestWaypoint(Database& db, uint32 zone_id, uint32 grid_id)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
SELECT COALESCE(MAX(`number`), 0) FROM `{}`
WHERE `zoneid` = {} AND `gridid` = {}
),
TableName(),
zone_id,
grid_id
)
);
if (!results.Success() || !results.RowCount()) {
return 0;
}
auto row = results.begin();
return Strings::ToInt(row[0]);
}
static int GetNextWaypoint(Database& db, uint32 zone_id, uint32 grid_id)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT MAX(`number`) FROM `{}` WHERE `zoneid` = {} AND `gridid` = {}",
TableName(),
zone_id,
grid_id
)
);
if (!results.Success() || !results.RowCount()) {
return 1;
}
auto row = results.begin();
return Strings::ToInt(row[0]) + 1;
}
};
#endif //EQEMU_GRID_ENTRIES_REPOSITORY_H
+21
View File
@@ -71,6 +71,27 @@ public:
return grids;
}
static int GetHighestGrid(Database& db, uint32 zone_id)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
SELECT COALESCE(MAX(`id`), 0) FROM `{}`
WHERE `zoneid` = {}
),
TableName(),
zone_id
)
);
if (!results.Success() || !results.RowCount()) {
return 0;
}
auto row = results.begin();
return Strings::ToInt(row[0]);
}
};
#endif //EQEMU_GRID_REPOSITORY_H
+28
View File
@@ -44,7 +44,35 @@ public:
*/
// Custom extended repository methods here
static uint32 GetPathGridBySpawn2ID(Database& db, uint32 spawn2_id)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT `pathgrid` FROM `{}` WHERE `id` = {}",
TableName(),
spawn2_id
)
);
if (!results.Success() || !results.RowCount()) {
return 0;
}
auto row = results.begin();
return Strings::ToUnsignedInt(row[0]);
}
static void SetPathGridBySpawn2ID(Database& db, uint32 spawn2_id, uint32 grid_id)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `spawn2` SET `pathgrid` = {} WHERE `id` = {}",
grid_id,
spawn2_id
)
);
}
};
#endif //EQEMU_SPAWN2_REPOSITORY_H
+5
View File
@@ -259,6 +259,7 @@ RULE_BOOL(Skills, RequireTomeHandin, false, "Disable click-to-learn and force ha
RULE_INT(Skills, TradeSkillClamp, 0, "Legacy tradeskills would clamp at 252 regardless of item modifiers and skill combination. DEFAULT: 0 will bypass clamp. Legacy value 252")
RULE_BOOL(Skills, UseAltSinisterStrikeFormula, false, "Enabling will utilize a formula derived from 2004 monkey business post which makes the AA actually worth something.")
RULE_BOOL(Skills, TrackingAutoRefreshSkillUps, true, "Disable to prevent tracking auto-refresh from giving skill-ups. Classic Style")
RULE_INT(Skills, MaximumTauntDistance, 150, "Maximum player taunt distance.")
RULE_CATEGORY_END()
RULE_CATEGORY(Pets)
@@ -269,6 +270,7 @@ RULE_BOOL(Pets, CanTakeNoDrop, false, "Setting whether anyone can give no-drop i
RULE_BOOL(Pets, CanTakeQuestItems, true, "Setting whether anyone can give quest items to pets")
RULE_BOOL(Pets, LivelikeBreakCharmOnInvis, true, "Default: true will break charm on any type of invis (hide/ivu/iva/etc) false will only break if the pet can not see you (ex. you have an undead pet and cast IVU")
RULE_BOOL(Pets, ClientPetsUseOwnerNameInLastName, true, "Disable this to keep client pet's last names from being owner_name's pet")
RULE_INT(Pets, PetTauntRange, 150, "Range at which a pet will taunt targets.")
RULE_CATEGORY_END()
RULE_CATEGORY(GM)
@@ -340,6 +342,9 @@ RULE_INT(Zone, GlobalLootMultiplier, 1, "Sets Global Loot drop multiplier for da
RULE_BOOL(Zone, KillProcessOnDynamicShutdown, true, "When process has booted a zone and has hit its zone shut down timer, it will hard kill the process to free memory back to the OS")
RULE_INT(Zone, SpawnEventMin, 3, "When strict is set in spawn_events, specifies the max EQ minutes into the trigger hour a spawn_event will fire. Going below 3 may cause the spawn_event to not fire.")
RULE_INT(Zone, ForageChance, 25, "Chance of foraging from zone table vs global table")
RULE_BOOL(Zone, AllowCrossZoneSpellsOnBots, false, "Set to true to allow cross zone spells (cast/remove) to affect bots")
RULE_BOOL(Zone, AllowCrossZoneSpellsOnMercs, false, "Set to true to allow cross zone spells (cast/remove) to affect mercenaries")
RULE_BOOL(Zone, AllowCrossZoneSpellsOnPets, false, "Set to true to allow cross zone spells (cast/remove) to affect pets")
RULE_CATEGORY_END()
RULE_CATEGORY(Map)
+2 -2
View File
@@ -25,7 +25,7 @@
// Build variables
// these get injected during the build pipeline
#define CURRENT_VERSION "22.43.2-dev" // always append -dev to the current version for custom-builds
#define CURRENT_VERSION "22.43.3-dev" // always append -dev to the current version for custom-builds
#define LOGIN_VERSION "0.8.0"
#define COMPILE_DATE __DATE__
#define COMPILE_TIME __TIME__
@@ -44,7 +44,7 @@
#define CURRENT_BINARY_DATABASE_VERSION 9256
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9041
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9042
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "eqemu-server",
"version": "22.43.2",
"version": "22.43.3",
"repository": {
"type": "git",
"url": "https://github.com/EQEmu/Server.git"
@@ -566,6 +566,12 @@ sub translate_mysql_data_type_to_c
elsif ($mysql_data_type =~ /int/) {
$struct_data_type = 'uint32_t';
}
elsif ($mysql_data_type =~ /float|decimal/i) {
$struct_data_type = 'float';
}
elsif ($mysql_data_type =~ /double/i) {
$struct_data_type = 'double';
}
}
elsif ($mysql_data_type =~ /bigint/) {
$struct_data_type = 'int64_t';
@@ -600,7 +606,9 @@ sub get_reserved_cpp_variable_names
"int",
"key",
"rank",
"range"
"range",
"interval",
"group"
);
}
+28 -2
View File
@@ -20,8 +20,34 @@ void WorldserverCLI::MercsEnable(int argc, char **argv, argh::parser &cmd, std::
LogInfo("Merc tables already exist, skipping bootstrap");
}
LogInfo("Enabling mercs");
uint32 expansions_setting = RuleManager::Instance()->GetIntRule(RuleManager::Int__ExpansionSettings);
uint32 expansions_setting_before = expansions_setting;
bool update_expansions = false;
if (expansions_setting != -1 && !(expansions_setting & EQ::expansions::ExpansionBitmask::bitSoD)) {
expansions_setting += EQ::expansions::ExpansionBitmask::bitSoD;
update_expansions = true;
}
LogInfo("Enabling Mercenaries");
LogInfo("Setting rule Mercs:AllowMercs to true");
RuleManager::Instance()->SetRule("Mercs:AllowMercs", "true", &database, true, true);
LogInfo("Mercs enabled");
if (update_expansions) {
LogInfo(
"Updating World:ExpansionSettings from [{}] to [{}] to enable Mercenary Liaison spawns",
expansions_setting_before,
expansions_setting
);
RuleManager::Instance()->SetRule(
"World:ExpansionSettings",
std::to_string(expansions_setting),
&database,
true,
true
);
}
LogInfo("Mercenaries enabled");
}
+4
View File
@@ -27,6 +27,7 @@
#include "../common/database_schema.h"
#include "../common/zone_store.h"
#include "worlddb.h"
#include "world_config.h"
extern ZSList zoneserver_list;
extern ClientList client_list;
@@ -274,4 +275,7 @@ void EQEmuApiWorldDataService::get(Json::Value &r, const std::vector<std::string
if (m == "reload") {
reload(r, args);
}
if (m == "lock_status") {
r["locked"] = WorldConfig::get()->Locked;
}
}
+302 -188
View File
@@ -1818,9 +1818,8 @@ bool Client::Death(Mob* killerMob, int64 damage, uint16 spell, EQ::skills::Skill
parse->EventNPC(EVENT_SLAY, killerMob->CastToNPC(), this, "", 0);
}
const uint32 emote_id = killerMob->GetEmoteID();
if (emote_id) {
killerMob->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::KilledPC, emote_id, this);
if (emoteid) {
killerMob->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::KilledPC, emoteid, this);
}
killerMob->TrySpellOnKill(killed_level, spell);
@@ -2376,10 +2375,15 @@ void NPC::Damage(Mob* other, int64 damage, uint16 spell_id, EQ::skills::SkillTyp
bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillType attack_skill)
{
LogCombat("Fatal blow dealt by [{}] with [{}] damage, spell [{}], skill [{}]",
((killer_mob) ? (killer_mob->GetName()) : ("[nullptr]")), damage, spell, attack_skill);
LogCombat(
"Fatal blow dealt by [{}] with [{}] damage, spell [{}], skill [{}]",
(killer_mob ? killer_mob->GetName() : "[nullptr]"),
damage,
spell,
attack_skill
);
Mob *oos = killer_mob ? killer_mob->GetOwnerOrSelf() : nullptr;
Mob* owner_or_self = killer_mob ? killer_mob->GetOwnerOrSelf() : nullptr;
if (IsNPC()) {
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_DEATH)) {
@@ -2391,7 +2395,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
static_cast<int>(attack_skill)
);
if (parse->EventNPC(EVENT_DEATH, this, oos, export_string, 0) != 0) {
if (parse->EventNPC(EVENT_DEATH, this, owner_or_self, export_string, 0) != 0) {
if (GetHP() < 0) {
SetHP(0);
}
@@ -2408,7 +2412,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
spell,
static_cast<int>(attack_skill)
);
if (parse->EventBot(EVENT_DEATH, CastToBot(), oos, export_string, 0) != 0) {
if (parse->EventBot(EVENT_DEATH, CastToBot(), owner_or_self, export_string, 0) != 0) {
if (GetHP() < 0) {
SetHP(0);
}
@@ -2435,7 +2439,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
if (IsEngaged()) {
zone->DelAggroMob();
Log(Logs::Detail, Logs::Attack, "%s Mobs currently Aggro %i", __FUNCTION__, zone->MobsAggroCount());
LogAttackDetail("{} Mob{} currently aggroed.", zone->MobsAggroCount(), zone->MobsAggroCount() != 1 ? "s" : "");
}
ShieldAbilityClearVariables();
@@ -2444,7 +2448,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
SetPet(0);
if (GetSwarmOwner()) {
auto* owner = entity_list.GetMobID(GetSwarmOwner());
Mob* owner = entity_list.GetMobID(GetSwarmOwner());
if (owner) {
owner->SetTempPetCount(owner->GetTempPetCount() - 1);
}
@@ -2458,31 +2462,40 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
return false;
}
const auto illusion_spell_id = spellbonuses.Illusion;
const int illusion_spell_id = spellbonuses.Illusion;
HasAISpellEffects = false;
BuffFadeAll();
const auto killed_level = GetLevel();
const uint8 killed_level = GetLevel();
if (GetClass() == Class::LDoNTreasure) { // open chest
auto outapp = new EQApplicationPacket(OP_Animation, sizeof(Animation_Struct));
Animation_Struct* anim = (Animation_Struct*)outapp->pBuffer;
anim->spawnid = GetID();
anim->action = 0x0F;
anim->speed = 10;
auto a = (Animation_Struct*) outapp->pBuffer;
a->spawnid = GetID();
a->action = 0x0F;
a->speed = 10;
entity_list.QueueCloseClients(this, outapp);
safe_delete(outapp);
}
auto app = new EQApplicationPacket(OP_Death, sizeof(Death_Struct));
auto* d = (Death_Struct*) app->pBuffer;
d->spawn_id = GetID();
d->killer_id = killer_mob ? killer_mob->GetID() : 0;
d->bindzoneid = 0;
d->spell_id = 0xffffffff; // Sending spell was causing extra DoT land msg
auto d = (Death_Struct*) app->pBuffer;
d->spawn_id = GetID();
d->killer_id = killer_mob ? killer_mob->GetID() : 0;
d->bindzoneid = 0;
d->spell_id = UINT32_MAX;
d->attack_skill = SkillDamageTypes[attack_skill];
d->damage = damage;
d->damage = damage;
app->priority = 6;
entity_list.QueueClients(killer_mob, app, false);
safe_delete(app);
@@ -2495,24 +2508,37 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
hate_list.AddEntToHateList(killer_mob, damage);
}
Mob *give_exp = hate_list.GetDamageTopOnHateList(this);
Mob* give_exp = hate_list.GetDamageTopOnHateList(this);
if (give_exp) {
give_exp = killer;
}
if (give_exp && give_exp->HasOwner()) {
bool ownerInGroup = false;
if ((give_exp->HasGroup() && give_exp->GetGroup()->IsGroupMember(give_exp->GetUltimateOwner()))
|| (give_exp->IsPet() && (give_exp->GetOwner()->IsClient()
|| (give_exp->GetOwner()->HasGroup() && give_exp->GetOwner()->GetGroup()->IsGroupMember(give_exp->GetOwner()->GetUltimateOwner()))))
) {
ownerInGroup = true;
bool owner_in_group = false;
if (
(
give_exp->HasGroup() &&
give_exp->GetGroup()->IsGroupMember(give_exp->GetUltimateOwner())
) ||
(
give_exp->IsPet() &&
(
give_exp->GetOwner()->IsClient() ||
(
give_exp->GetOwner()->HasGroup() &&
give_exp->GetOwner()->GetGroup()->IsGroupMember(give_exp->GetOwner()->GetUltimateOwner())
)
)
)
) {
owner_in_group = true;
}
give_exp = give_exp->GetUltimateOwner();
if (!RuleB(Bots, BotGroupXP) && !ownerInGroup) {
if (!RuleB(Bots, BotGroupXP) && !owner_in_group) {
give_exp = nullptr;
}
}
@@ -2526,9 +2552,9 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
}
}
int PlayerCount = 0; // QueryServ Player Counting
int player_count = 0; // QueryServ Player Counting
Client *give_exp_client = nullptr;
Client* give_exp_client = nullptr;
if (give_exp && give_exp->IsClient()) {
give_exp_client = give_exp->CastToClient();
}
@@ -2538,13 +2564,13 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
hate_list.DoFactionHits(GetNPCFactionID(), GetPrimaryFaction(), GetFactionAmount());
}
bool IsLdonTreasure = (GetClass() == Class::LDoNTreasure);
const bool is_ldon_treasure = GetClass() == Class::LDoNTreasure;
if (give_exp_client && !IsCorpse()) {
Group *kg = entity_list.GetGroupByClient(give_exp_client);
Raid *kr = entity_list.GetRaidByClient(give_exp_client);
Group* killer_group = entity_list.GetGroupByClient(give_exp_client);
Raid* killer_raid = entity_list.GetRaidByClient(give_exp_client);
int64 finalxp = give_exp_client->GetExperienceForKill(this);
int64 final_exp = give_exp_client->GetExperienceForKill(this);
// handle task credit on behalf of the killer
if (RuleB(TaskSystem, EnableTaskSystem)) {
@@ -2556,75 +2582,98 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
task_manager->HandleUpdateTasksOnKill(give_exp_client, this);
}
if (kr) {
if (!IsLdonTreasure && MerchantType == 0) {
kr->SplitExp((finalxp), this);
if (killer_mob && (kr->IsRaidMember(killer_mob->GetName()) || kr->IsRaidMember(killer_mob->GetUltimateOwner()->GetName())))
if (killer_raid) {
if (!is_ldon_treasure && MerchantType == 0) {
killer_raid->SplitExp(final_exp, this);
if (
killer_mob &&
(
killer_raid->IsRaidMember(killer_mob->GetName()) ||
killer_raid->IsRaidMember(killer_mob->GetUltimateOwner()->GetName())
)
) {
killer_mob->TrySpellOnKill(killed_level, spell);
}
}
/* Send the EVENT_KILLED_MERIT event for all raid members */
for (const auto& m : kr->members) {
for (const auto& m : killer_raid->members) {
if (m.is_bot) {
continue;
}
if (m.member && m.member->IsClient()) { // If Group Member is Client
Client *c = m.member;
if (m.member) {
m.member->RecordKilledNPCEvent(this);
c->RecordKilledNPCEvent(this);
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_KILLED_MERIT)) {
parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0);
parse->EventNPC(EVENT_KILLED_MERIT, this, m.member, "killed", 0);
}
if (RuleB(NPC, EnableMeritBasedFaction)) {
c->SetFactionLevel(c->CharacterID(), GetNPCFactionID(), c->GetBaseClass(), c->GetBaseRace(), c->GetDeity());
m.member->SetFactionLevel(
m.member->CharacterID(),
GetNPCFactionID(),
m.member->GetBaseClass(),
m.member->GetBaseRace(),
m.member->GetDeity()
);
}
PlayerCount++;
player_count++;
}
}
// QueryServ Logging - Raid Kills
if (RuleB(QueryServ, PlayerLogNPCKills)) {
auto pack =
new ServerPacket(ServerOP_QSPlayerLogNPCKills,
sizeof(QSPlayerLogNPCKill_Struct) +
(sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount));
PlayerCount = 0;
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
QS->s1.NPCID = GetNPCTypeID();
auto pack = new ServerPacket(
ServerOP_QSPlayerLogNPCKills,
sizeof(QSPlayerLogNPCKill_Struct) +
(sizeof(QSPlayerLogNPCKillsPlayers_Struct) * player_count)
);
player_count = 0;
auto QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
QS->s1.NPCID = GetNPCTypeID();
QS->s1.ZoneID = GetZoneID();
QS->s1.Type = 2; // Raid Fight
for (const auto& m : kr->members) {
QS->s1.Type = 2; // Raid Fight
for (const auto& m : killer_raid->members) {
if (m.is_bot) {
continue;
}
if (m.member && m.member->IsClient()) { // If Group Member is Client
Client *c = m.member;
QS->Chars[PlayerCount].char_id = c->CharacterID();
PlayerCount++;
if (m.member && m.member->IsClient()) {
QS->Chars[player_count].char_id = m.member->CastToClient()->CharacterID();
player_count++;
}
}
worldserver.SendPacket(pack); // Send Packet to World
worldserver.SendPacket(pack);
safe_delete(pack);
}
// End QueryServ Logging
} else if (give_exp_client->IsGrouped() && killer_group) {
if (!is_ldon_treasure && MerchantType == 0) {
killer_group->SplitExp(final_exp, this);
}
else if (give_exp_client->IsGrouped() && kg != nullptr) {
if (!IsLdonTreasure && MerchantType == 0) {
kg->SplitExp((finalxp), this);
if (killer_mob && (kg->IsGroupMember(killer_mob->GetName()) || kg->IsGroupMember(killer_mob->GetUltimateOwner()->GetName())))
if (
killer_mob &&
(
killer_group->IsGroupMember(killer_mob->GetName()) ||
killer_group->IsGroupMember(killer_mob->GetUltimateOwner()->GetName())
)
) {
killer_mob->TrySpellOnKill(killed_level, spell);
}
}
/* Send the EVENT_KILLED_MERIT event and update kill tasks
* for all group members */
for (int i = 0; i < MAX_GROUP_MEMBERS; i++) {
if (kg->members[i] != nullptr && kg->members[i]->IsClient()) { // If Group Member is Client
Client *c = kg->members[i]->CastToClient();
for (const auto& m : killer_group->members) {
if (m && m->IsClient()) {
Client* c = m->CastToClient();
c->RecordKilledNPCEvent(this);
@@ -2632,70 +2681,101 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0);
}
if (RuleB(NPC, EnableMeritBasedFaction))
c->SetFactionLevel(c->CharacterID(), GetNPCFactionID(), c->GetBaseClass(), c->GetBaseRace(), c->GetDeity());
if (RuleB(NPC, EnableMeritBasedFaction)) {
c->SetFactionLevel(
c->CharacterID(),
GetNPCFactionID(),
c->GetBaseClass(),
c->GetBaseRace(),
c->GetDeity()
);
}
PlayerCount++;
player_count++;
}
}
// QueryServ Logging - Group Kills
if (RuleB(QueryServ, PlayerLogNPCKills)) {
auto pack =
new ServerPacket(ServerOP_QSPlayerLogNPCKills,
sizeof(QSPlayerLogNPCKill_Struct) +
(sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount));
PlayerCount = 0;
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
QS->s1.NPCID = GetNPCTypeID();
auto pack = new ServerPacket(
ServerOP_QSPlayerLogNPCKills,
sizeof(QSPlayerLogNPCKill_Struct) +
(sizeof(QSPlayerLogNPCKillsPlayers_Struct) * player_count)
);
player_count = 0;
auto QS = (QSPlayerLogNPCKill_Struct*) pack->pBuffer;
QS->s1.NPCID = GetNPCTypeID();
QS->s1.ZoneID = GetZoneID();
QS->s1.Type = 1; // Group Fight
for (int i = 0; i < MAX_GROUP_MEMBERS; i++) {
if (kg->members[i] != nullptr && kg->members[i]->IsClient()) { // If Group Member is Client
Client *c = kg->members[i]->CastToClient();
QS->Chars[PlayerCount].char_id = c->CharacterID();
PlayerCount++;
QS->s1.Type = 1; // Group Fight
for (const auto& m : killer_group->members) {
if (m && m->IsClient()) {
QS->Chars[player_count].char_id = m->CastToClient()->CharacterID();
player_count++;
}
}
worldserver.SendPacket(pack); // Send Packet to World
worldserver.SendPacket(pack);
safe_delete(pack);
}
// End QueryServ Logging
}
else {
if (!IsLdonTreasure && MerchantType == 0) {
int conlevel = give_exp->GetLevelCon(GetLevel());
if (conlevel != CON_GRAY) {
} else {
if (!is_ldon_treasure && !MerchantType) {
const uint32 con_level = give_exp->GetLevelCon(GetLevel());
if (con_level != CON_GRAY) {
if (!GetOwner() || (GetOwner() && !GetOwner()->IsClient())) {
give_exp_client->AddEXP((finalxp), conlevel);
if (killer_mob && (killer_mob->GetID() == give_exp_client->GetID() || killer_mob->GetUltimateOwner()->GetID() == give_exp_client->GetID()))
give_exp_client->AddEXP(final_exp, con_level);
if (
killer_mob &&
(
killer_mob->GetID() == give_exp_client->GetID() ||
killer_mob->GetUltimateOwner()->GetID() == give_exp_client->GetID()
)
) {
killer_mob->TrySpellOnKill(killed_level, spell);
}
}
}
}
/* Send the EVENT_KILLED_MERIT event */
give_exp_client->RecordKilledNPCEvent(this);
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_KILLED_MERIT)) {
parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0);
}
if (RuleB(NPC, EnableMeritBasedFaction))
give_exp_client->SetFactionLevel(give_exp_client->CharacterID(), GetNPCFactionID(), give_exp_client->GetBaseClass(),
give_exp_client->GetBaseRace(), give_exp_client->GetDeity());
if (RuleB(NPC, EnableMeritBasedFaction)) {
give_exp_client->SetFactionLevel(
give_exp_client->CharacterID(),
GetNPCFactionID(),
give_exp_client->GetBaseClass(),
give_exp_client->GetBaseRace(),
give_exp_client->GetDeity()
);
}
// QueryServ Logging - Solo
if (RuleB(QueryServ, PlayerLogNPCKills)) {
auto pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills,
auto pack = new ServerPacket(
ServerOP_QSPlayerLogNPCKills,
sizeof(QSPlayerLogNPCKill_Struct) +
(sizeof(QSPlayerLogNPCKillsPlayers_Struct) * 1));
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
QS->s1.NPCID = GetNPCTypeID();
QS->s1.ZoneID = GetZoneID();
QS->s1.Type = 0; // Solo Fight
Client *c = give_exp_client;
QS->Chars[0].char_id = c->CharacterID();
PlayerCount++;
(sizeof(QSPlayerLogNPCKillsPlayers_Struct) * 1)
);
auto QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
QS->s1.NPCID = GetNPCTypeID();
QS->s1.ZoneID = GetZoneID();
QS->s1.Type = 0; // Solo Fight
QS->Chars[0].char_id = give_exp_client->CharacterID();
player_count++;
worldserver.SendPacket(pack); // Send Packet to World
safe_delete(pack);
}
@@ -2703,32 +2783,68 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
}
}
bool allow_merchant_corpse = RuleB(Merchant, AllowCorpse);
bool is_merchant = (class_ == Class::Merchant || class_ == Class::AdventureMerchant || MerchantType != 0);
const bool allow_merchant_corpse = RuleB(Merchant, AllowCorpse);
const bool is_merchant = (class_ == Class::Merchant || class_ == Class::AdventureMerchant || MerchantType != 0);
Corpse* corpse = nullptr;
const uint16 entity_id = GetID();
if (!HasOwner() && !IsMerc() && !GetSwarmInfo() && (!is_merchant || allow_merchant_corpse) &&
((killer && (killer->IsClient() || (killer->HasOwner() && killer->GetUltimateOwner()->IsClient()) ||
(killer->IsNPC() && killer->CastToNPC()->GetSwarmInfo() && killer->CastToNPC()->GetSwarmInfo()->GetOwner() && killer->CastToNPC()->GetSwarmInfo()->GetOwner()->IsClient())))
|| (killer_mob && IsLdonTreasure)))
{
if (killer != 0) {
if (killer->GetOwner() != 0 && killer->GetOwner()->IsClient())
if (
!HasOwner() &&
!IsMerc() &&
!GetSwarmInfo() &&
(!is_merchant || allow_merchant_corpse) &&
(
(
killer &&
(
killer->IsClient() ||
(
killer->HasOwner() &&
killer->GetUltimateOwner()->IsClient()
) ||
(
killer->IsNPC() &&
killer->CastToNPC()->GetSwarmInfo() &&
killer->CastToNPC()->GetSwarmInfo()->GetOwner() &&
killer->CastToNPC()->GetSwarmInfo()->GetOwner()->IsClient()
)
)
) ||
(
killer_mob && is_ldon_treasure
)
)
) {
if (killer) {
if (killer->GetOwner() != 0 && killer->GetOwner()->IsClient()) {
killer = killer->GetOwner();
}
if (killer->IsClient() && !killer->CastToClient()->GetGM())
if (killer->IsClient() && !killer->CastToClient()->GetGM()) {
CheckTrivialMinMaxLevelDrop(killer);
}
}
entity_list.RemoveFromAutoXTargets(this);
const uint32 emote_id = GetEmoteID();
corpse = new Corpse(this, &itemlist, GetNPCTypeID(), &NPCTypedata,
level > 54 ? RuleI(NPC, MajorNPCCorpseDecayTimeMS)
: RuleI(NPC, MinorNPCCorpseDecayTimeMS));
corpse = new Corpse(
this,
&itemlist,
GetNPCTypeID(),
&NPCTypedata,
(
level > 54 ?
RuleI(NPC, MajorNPCCorpseDecayTimeMS) :
RuleI(NPC, MinorNPCCorpseDecayTimeMS)
)
);
if (killer_mob && emoteid) {
DoNPCEmote(EQ::constants::EmoteEventTypes::AfterDeath, emoteid, killer_mob);
}
entity_list.LimitRemoveNPC(this);
entity_list.AddCorpse(corpse, GetID());
@@ -2740,103 +2856,99 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
SetID(0);
ApplyIllusionToCorpse(illusion_spell_id, corpse);
if (killer != 0 && emote_id)
corpse->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::AfterDeath, emote_id, killer);
if (killer != 0 && killer->IsClient()) {
if (killer && killer->IsClient()) {
corpse->AllowPlayerLoot(killer, 0);
if (killer->IsGrouped()) {
Group* group = entity_list.GetGroupByClient(killer->CastToClient());
if (group != 0) {
for (int i = 0; i<6; i++) { // Doesnt work right, needs work
if (group->members[i] != nullptr) {
corpse->AllowPlayerLoot(group->members[i], i);
Group* g = entity_list.GetGroupByClient(killer->CastToClient());
if (g) {
uint8 slot_id = 0;
for (const auto &m : g->members) {
if (m) {
corpse->AllowPlayerLoot(m, slot_id);
}
slot_id++;
}
}
}
else if (killer->IsRaidGrouped()) {
} else if (killer->IsRaidGrouped()) {
Raid* r = entity_list.GetRaidByClient(killer->CastToClient());
if (r) {
int i = 0;
for (const auto& m : r->members) {
uint8 slot_id = 0;
for (const auto &m : r->members) {
if (m.is_bot) {
continue;
}
switch (r->GetLootType()) {
case 0:
case 1:
if (m.member && m.is_raid_leader) {
corpse->AllowPlayerLoot(m.member, i);
i++;
}
break;
case 2:
if (m.member && (m.is_raid_leader || m.is_group_leader)) {
corpse->AllowPlayerLoot(m.member, i);
i++;
}
break;
case 3:
if (m.member && m.is_looter) {
corpse->AllowPlayerLoot(m.member, i);
i++;
}
break;
case 4:
if (m.member) {
corpse->AllowPlayerLoot(m.member, i);
i++;
}
break;
case RaidLootType::LeaderOnly:
if (m.member && m.is_raid_leader) {
corpse->AllowPlayerLoot(m.member, slot_id);
slot_id++;
}
break;
case RaidLootType::LeaderAndGroupLeadersOnly:
if (m.member && (m.is_raid_leader || m.is_group_leader)) {
corpse->AllowPlayerLoot(m.member, slot_id);
slot_id++;
}
break;
case RaidLootType::LeaderSelected:
if (m.member && m.is_looter) {
corpse->AllowPlayerLoot(m.member, slot_id);
slot_id++;
}
break;
case RaidLootType::EntireRaid:
default:
if (m.member) {
corpse->AllowPlayerLoot(m.member, slot_id);
slot_id++;
}
break;
}
}
}
}
}
else if (killer_mob && IsLdonTreasure) {
auto u_owner = killer_mob->GetUltimateOwner();
if (u_owner->IsClient())
corpse->AllowPlayerLoot(u_owner, 0);
} else if (killer_mob && is_ldon_treasure) {
Mob* ultimate_owner = killer_mob->GetUltimateOwner();
if (ultimate_owner->IsClient()) {
corpse->AllowPlayerLoot(ultimate_owner, 0);
}
}
if (zone && zone->adv_data) {
ServerZoneAdventureDataReply_Struct *sr = (ServerZoneAdventureDataReply_Struct*)zone->adv_data;
auto sr = (ServerZoneAdventureDataReply_Struct *) zone->adv_data;
if (sr->type == Adventure_Kill) {
zone->DoAdventureCountIncrease();
}
else if (sr->type == Adventure_Assassinate) {
} else if (sr->type == Adventure_Assassinate) {
if (sr->data_id == GetNPCTypeID()) {
zone->DoAdventureCountIncrease();
}
else {
} else {
zone->DoAdventureAssassinationCountIncrease();
}
}
}
}
else {
} else {
entity_list.RemoveFromXTargets(this);
}
// Parse quests even if we're killed by an NPC
if (oos) {
if (IsNPC()) {
const uint32 emote_id = GetEmoteID();
if (emote_id) {
DoNPCEmote(EQ::constants::EmoteEventTypes::OnDeath, emote_id, killer_mob);
}
if (IsNPC()) {
if (emoteid) {
DoNPCEmote(EQ::constants::EmoteEventTypes::OnDeath, emoteid, killer_mob);
}
}
if (oos->IsNPC()) {
if (parse->HasQuestSub(oos->GetNPCTypeID(), EVENT_NPC_SLAY)) {
parse->EventNPC(EVENT_NPC_SLAY, oos->CastToNPC(), this, "", 0);
if (owner_or_self) {
if (owner_or_self->IsNPC()) {
if (parse->HasQuestSub(owner_or_self->GetNPCTypeID(), EVENT_NPC_SLAY)) {
parse->EventNPC(EVENT_NPC_SLAY, owner_or_self->CastToNPC(), this, "", 0);
}
const uint32 emote_id = oos->GetEmoteID();
const uint32 emote_id = owner_or_self->GetEmoteID();
if (emote_id) {
oos->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::KilledNPC, emote_id, this);
owner_or_self->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::KilledNPC, emote_id, this);
}
if (killer_mob) {
@@ -2854,10 +2966,12 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
}
WipeHateList();
p_depop = true;
if (killer_mob && killer_mob->GetTarget() == this) //we can kill things without having them targeted
killer_mob->SetTarget(nullptr); //via AE effects and such..
if (killer_mob && killer_mob->GetTarget() == this) { // We can kill things without having them targeted
killer_mob->SetTarget(nullptr);
}
entity_list.UpdateFindableNPCState(this, true);
@@ -2875,7 +2989,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
std::vector<std::any> args = { corpse };
parse->EventNPC(EVENT_DEATH_COMPLETE, this, oos, export_string, 0, &args);
parse->EventNPC(EVENT_DEATH_COMPLETE, this, owner_or_self, export_string, 0, &args);
}
// Zone controller process EVENT_DEATH_ZONE (Death events)
@@ -2891,7 +3005,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
std::vector<std::any> args = { corpse, this };
DispatchZoneControllerEvent(EVENT_DEATH_ZONE, oos, export_string, 0, &args);
DispatchZoneControllerEvent(EVENT_DEATH_ZONE, owner_or_self, export_string, 0, &args);
}
return true;
@@ -4437,7 +4551,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
// produce a spell message. Send to everyone.
// This fixes issues with npc-procs like 1002 and 918 and
// damage based disciplines which need to spit out extra spell color.
if (IsValidSpell(spell_id) &&
if (IsValidSpell(spell_id) &&
(skill_used == EQ::skills::SkillTigerClaw ||
(IsDamageSpell(spell_id) && IsDiscipline(spell_id)))
) {
+30 -30
View File
@@ -107,15 +107,17 @@ Beacon::Beacon(const glm::vec4 &in_pos, int lifetime) : Mob(
{
remove_timer.Disable();
spell_timer.Disable();
remove_me = false;
spell_id = 0xFFFF;
resist_adjust = 0;
spell_iterations = 0;
caster_id = 0;
max_targets = 4; // default
if(lifetime)
remove_me = false;
spell_id = UINT16_MAX;
resist_adjust = 0;
spell_iterations = 0;
caster_id = 0;
max_targets = 4;
if (lifetime) {
remove_timer.Start();
}
}
Beacon::~Beacon()
@@ -125,55 +127,53 @@ Beacon::~Beacon()
bool Beacon::Process()
{
if(remove_me)
{
if (remove_me) {
return false;
}
if
(
if (
spell_timer.Enabled() &&
spell_timer.Check() &&
IsValidSpell(spell_id)
)
{
Mob *caster = entity_list.GetMob(caster_id);
if(caster && spell_iterations-- && max_targets)
{
) {
Mob* caster = entity_list.GetMob(caster_id);
if (caster && spell_iterations-- && max_targets) {
// NPCs should never be affected by an AE they cast. PB AEs shouldn't affect caster either
// I don't think any other cases that get here matter
bool affect_caster = (!caster->IsNPC() && !caster->IsAIControlled()) && spells[spell_id].target_type != ST_AECaster;
const bool affect_caster = (
!caster->IsNPC() &&
!caster->IsAIControlled() &&
spells[spell_id].target_type != ST_AECaster
);
entity_list.AESpell(caster, this, spell_id, affect_caster, resist_adjust, &max_targets);
}
else
{
} else {
// spell is done casting, or caster disappeared
spell_id = 0xFFFF;
caster_id = 0;
spell_id = UINT16_MAX;
spell_iterations = 0;
spell_timer.Disable();
caster_id = 0;
}
}
if(remove_timer.Enabled() && remove_timer.Check())
{
if (remove_timer.Enabled() && remove_timer.Check()) {
return false;
}
return true;
}
void Beacon::AELocationSpell(Mob *caster, uint16 cast_spell_id, int16 resist_adjust)
void Beacon::AELocationSpell(Mob *caster, uint16 cast_spell_id, int16 in_resist_adjust)
{
if (!IsValidSpell(cast_spell_id) || !caster) {
return;
}
caster_id = caster->GetID();
spell_id = cast_spell_id;
resist_adjust = resist_adjust;
spell_iterations = spells[spell_id].aoe_duration / 2500;
spell_iterations = spell_iterations < 1 ? 1 : spell_iterations; // at least 1
caster_id = caster->GetID();
spell_id = cast_spell_id;
resist_adjust = in_resist_adjust;
spell_iterations = ((spells[spell_id].aoe_duration / 2500) < 1) ? 1 : spell_iterations;
if (spells[spell_id].aoe_max_targets) {
max_targets = spells[spell_id].aoe_max_targets;
}
+1 -1
View File
@@ -46,7 +46,7 @@ public:
bool IsBeacon() const { return true; }
bool Process();
virtual void Depop(bool not_used = true) { remove_me = true; }
void AELocationSpell(Mob *caster, uint16 cast_spell_id, int16 resist_adjust);
void AELocationSpell(Mob *caster, uint16 cast_spell_id, int16 in_resist_adjust);
protected:
Timer remove_timer;
+22 -132
View File
@@ -228,17 +228,10 @@ Bot::Bot(
strcpy(name, GetCleanName());
memset(&_botInspectMessage, 0, sizeof(InspectMessage_Struct));
if (!database.botdb.LoadInspectMessage(GetBotID(), _botInspectMessage) && bot_owner)
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::LoadInspectMessage(), GetCleanName());
std::string error_message;
database.botdb.LoadInspectMessage(GetBotID(), _botInspectMessage);
EquipBot(&error_message);
if (!error_message.empty()) {
if (bot_owner)
bot_owner->Message(Chat::White, error_message.c_str());
error_message.clear();
}
EquipBot();
if (GetClass() == Class::Rogue) {
m_evade_timer.Start();
@@ -252,17 +245,12 @@ Bot::Bot(
GenerateBaseStats();
bot_timers.clear();
if (!database.botdb.LoadTimers(this) && bot_owner) {
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::LoadTimers(), GetCleanName());
}
database.botdb.LoadTimers(this);
LoadAAs();
if (!database.botdb.LoadBuffs(this)) {
if (bot_owner) {
bot_owner->Message(Chat::White, "&s for '%s'", BotDatabase::fail::LoadBuffs(), GetCleanName());
}
} else {
if (database.botdb.LoadBuffs(this)) {
//reapply some buffs
uint32 buff_count = GetMaxBuffSlots();
for (uint32 j1 = 0; j1 < buff_count; j1++) {
@@ -1335,38 +1323,23 @@ bool Bot::Save()
if (!bot_owner)
return false;
std::string error_message;
if (!GetBotID()) { // New bot record
uint32 bot_id = 0;
if (!database.botdb.SaveNewBot(this, bot_id) || !bot_id) {
bot_owner->Message(Chat::White, "%s '%s'", BotDatabase::fail::SaveNewBot(), GetCleanName());
return false;
}
SetBotID(bot_id);
}
else { // Update existing bot record
if (!database.botdb.SaveBot(this)) {
bot_owner->Message(Chat::White, "%s '%s'", BotDatabase::fail::SaveBot(), GetCleanName());
return false;
}
}
// All of these continue to process if any fail
if (!database.botdb.SaveBuffs(this))
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveBuffs(), GetCleanName());
if (!database.botdb.SaveTimers(this))
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveTimers(), GetCleanName());
if (!database.botdb.SaveStance(this)) {
bot_owner->Message(
Chat::White,
fmt::format(
"Failed to save stance for '{}'.",
GetCleanName()
).c_str()
);
}
database.botdb.SaveBuffs(this);
database.botdb.SaveTimers(this);
database.botdb.SaveStance(this);
if (!SavePet())
bot_owner->Message(Chat::White, "Failed to save pet for '%s'", GetCleanName());
@@ -1382,7 +1355,6 @@ bool Bot::DeleteBot()
}
if (!database.botdb.DeleteHealRotation(GetBotID())) {
bot_owner->Message(Chat::White, "%s", BotDatabase::fail::DeleteHealRotation());
return false;
}
@@ -1413,65 +1385,23 @@ bool Bot::DeleteBot()
RemoveBotFromRaid(this);
}
std::string error_message;
if (!database.botdb.DeleteItems(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteItems(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteTimers(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteTimers(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteBuffs(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteBuffs(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteStance(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteStance(),
GetCleanName()
).c_str()
);
return false;
}
if (!database.botdb.DeleteBot(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} '{}'",
BotDatabase::fail::DeleteBot(),
GetCleanName()
).c_str()
);
return false;
}
@@ -1511,20 +1441,16 @@ bool Bot::LoadPet()
}
}
std::string error_message;
uint32 pet_index = 0;
if (!database.botdb.LoadPetIndex(GetBotID(), pet_index)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetIndex(), GetCleanName());
return false;
}
if (!pet_index)
return true;
uint32 saved_pet_spell_id = 0;
if (!database.botdb.LoadPetSpellID(GetBotID(), saved_pet_spell_id)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetSpellID(), GetCleanName());
}
database.botdb.LoadPetSpellID(GetBotID(), saved_pet_spell_id);
if (!IsValidSpell(saved_pet_spell_id)) {
bot_owner->Message(Chat::White, "Invalid spell id for %s's pet", GetCleanName());
DeletePet();
@@ -1537,7 +1463,6 @@ bool Bot::LoadPet()
uint32 pet_spell_id = 0;
if (!database.botdb.LoadPetStats(GetBotID(), pet_name, pet_mana, pet_hp, pet_spell_id)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetStats(), GetCleanName());
return false;
}
@@ -1551,13 +1476,11 @@ bool Bot::LoadPet()
SpellBuff_Struct pet_buffs[PET_BUFF_COUNT];
memset(pet_buffs, 0, (sizeof(SpellBuff_Struct) * PET_BUFF_COUNT));
if (!database.botdb.LoadPetBuffs(GetBotID(), pet_buffs))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetBuffs(), GetCleanName());
database.botdb.LoadPetBuffs(GetBotID(), pet_buffs);
uint32 pet_items[EQ::invslot::EQUIPMENT_COUNT];
memset(pet_items, 0, (sizeof(uint32) * EQ::invslot::EQUIPMENT_COUNT));
if (!database.botdb.LoadPetItems(GetBotID(), pet_items))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetItems(), GetCleanName());
database.botdb.LoadPetItems(GetBotID(), pet_items);
pet_inst->SetPetState(pet_buffs, pet_items);
pet_inst->CalcBonuses();
@@ -1596,17 +1519,12 @@ bool Bot::SavePet()
std::string pet_name_str = pet_name;
safe_delete_array(pet_name)
std::string error_message;
if (!database.botdb.SavePetStats(GetBotID(), pet_name_str, pet_inst->GetMana(), pet_inst->GetHP(), pet_inst->GetPetSpellID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetStats(), GetCleanName());
return false;
}
if (!database.botdb.SavePetBuffs(GetBotID(), pet_buffs))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetBuffs(), GetCleanName());
if (!database.botdb.SavePetItems(GetBotID(), pet_items))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetItems(), GetCleanName());
database.botdb.SavePetBuffs(GetBotID(), pet_buffs);
database.botdb.SavePetItems(GetBotID(), pet_items);
return true;
}
@@ -1617,18 +1535,13 @@ bool Bot::DeletePet()
if (!bot_owner)
return false;
std::string error_message;
if (!database.botdb.DeletePetItems(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetItems(), GetCleanName());
return false;
}
if (!database.botdb.DeletePetBuffs(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetBuffs(), GetCleanName());
return false;
}
if (!database.botdb.DeletePetStats(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetStats(), GetCleanName());
return false;
}
@@ -3379,29 +3292,26 @@ bool Bot::Spawn(Client* botCharacterOwner) {
}
// Deletes the inventory record for the specified item from the database for this bot.
void Bot::RemoveBotItemBySlot(uint16 slot_id, std::string *error_message)
void Bot::RemoveBotItemBySlot(uint16 slot_id)
{
if (!GetBotID()) {
return;
}
if (!database.botdb.DeleteItemBySlot(GetBotID(), slot_id)) {
*error_message = BotDatabase::fail::DeleteItemBySlot();
}
database.botdb.DeleteItemBySlot(GetBotID(), slot_id);
m_inv.DeleteItem(slot_id);
UpdateEquipmentLight();
}
// Retrieves all the inventory records from the database for this bot.
void Bot::GetBotItems(EQ::InventoryProfile &inv, std::string* error_message)
void Bot::GetBotItems(EQ::InventoryProfile &inv)
{
if (!GetBotID()) {
return;
}
if (!database.botdb.LoadItems(GetBotID(), inv)) {
*error_message = BotDatabase::fail::LoadItems();
return;
}
@@ -3732,7 +3642,7 @@ void Bot::BotRemoveEquipItem(uint16 slot_id)
}
}
void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::string* error_message, bool save_to_database)
void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, bool save_to_database)
{
if (!inst) {
return;
@@ -3740,7 +3650,6 @@ void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::str
if (save_to_database) {
if (!database.botdb.SaveItemBySlot(this, slot_id, inst)) {
*error_message = BotDatabase::fail::SaveItemBySlot();
return;
}
@@ -3848,21 +3757,7 @@ void Bot::RemoveBotItem(uint32 item_id) {
if (inst->GetID() == item_id) {
std::string error_message;
RemoveBotItemBySlot(slot_id, &error_message);
if (!error_message.empty()) {
if (GetOwner()) {
GetOwner()->CastToClient()->Message(
Chat::White,
fmt::format(
"Database Error: {}",
error_message
).c_str()
);
}
return;
}
RemoveBotItemBySlot(slot_id);
BotRemoveEquipItem(slot_id);
CalcBotStats(GetOwner()->CastToClient()->GetBotOption(Client::booStatsUpdate));
return;
@@ -5389,18 +5284,15 @@ bool Bot::IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined) {
return Result;
}
void Bot::EquipBot(std::string* error_message) {
GetBotItems(m_inv, error_message);
void Bot::EquipBot() {
GetBotItems(m_inv);
const EQ::ItemInstance* inst = nullptr;
const EQ::ItemData* item = nullptr;
for (int slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id <= EQ::invslot::EQUIPMENT_END; ++slot_id) {
inst = GetBotItem(slot_id);
if (inst) {
item = inst->GetItem();
BotTradeAddItem(inst, slot_id, error_message, false);
if (!error_message->empty()) {
return;
}
BotTradeAddItem(inst, slot_id, false);
}
}
UpdateEquipmentLight();
@@ -8131,8 +8023,6 @@ bool Bot::DyeArmor(int16 slot_id, uint32 rgb, bool all_flag, bool save_flag)
save_slot = -2;
if (!database.botdb.SaveEquipmentColor(GetBotID(), save_slot, rgb)) {
if (GetBotOwner() && GetBotOwner()->IsClient())
GetBotOwner()->CastToClient()->Message(Chat::White, "%s", BotDatabase::fail::SaveEquipmentColor());
return false;
}
}
+5 -4
View File
@@ -386,8 +386,8 @@ public:
bool CheckDataBucket(std::string bucket_name, const std::string& bucket_value, uint8 bucket_comparison);
// Bot Equipment & Inventory Class Methods
void BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::string* error_message, bool save_to_database = true);
void EquipBot(std::string* error_message);
void BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, bool save_to_database = true);
void EquipBot();
bool CheckLoreConflict(const EQ::ItemData* item);
void UpdateEquipmentLight() override
{
@@ -704,7 +704,8 @@ public:
uint32 attack
);
void BotRemoveEquipItem(uint16 slot_id);
void RemoveBotItemBySlot(uint16 slot_id, std::string* error_message);
void RemoveBotItemBySlot(uint16 slot_id
);
void AddBotItem(
uint16 slot_id,
uint32 item_id,
@@ -938,7 +939,7 @@ private:
void SetReturningFlag(bool flag = true) { m_returning_flag = flag; }
// Private "Inventory" Methods
void GetBotItems(EQ::InventoryProfile &inv, std::string* error_message);
void GetBotItems(EQ::InventoryProfile &inv);
void BotAddEquipItem(uint16 slot_id, uint32 item_id);
// Private "Pet" Methods
+32 -108
View File
@@ -5843,7 +5843,7 @@ void bot_subcommand_bot_clone(Client *c, const Seperator *sep)
}
uint32 clone_id = 0;
if (!database.botdb.CreateCloneBot(c->CharacterID(), my_bot->GetBotID(), bot_name, clone_id) || !clone_id) {
if (!database.botdb.CreateCloneBot(my_bot->GetBotID(), bot_name, clone_id) || !clone_id) {
c->Message(
Chat::White,
fmt::format(
@@ -5875,7 +5875,7 @@ void bot_subcommand_bot_clone(Client *c, const Seperator *sep)
);
}
if (!database.botdb.CreateCloneBotInventory(c->CharacterID(), my_bot->GetBotID(), clone_id)) {
if (!database.botdb.CreateCloneBotInventory(my_bot->GetBotID(), clone_id)) {
c->Message(
Chat::White,
fmt::format(
@@ -6361,25 +6361,9 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) {
if (dye_all) {
if (!database.botdb.SaveAllArmorColors(c->CharacterID(), rgb_value)) {
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::SaveAllArmorColors()
).c_str()
);
}
database.botdb.SaveAllArmorColors(c->CharacterID(), rgb_value);
} else {
if (!database.botdb.SaveAllArmorColorBySlot(c->CharacterID(), slot_id, rgb_value)) {
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::SaveAllArmorColorBySlot()
).c_str()
);
}
database.botdb.SaveAllArmorColorBySlot(c->CharacterID(), slot_id, rgb_value);
}
}
}
@@ -6527,8 +6511,7 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
continue;
bot_iter->SetFollowDistance(bfd);
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveFollowDistance(c->CharacterID(), bot_iter->GetBotID(), bfd)) {
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveFollowDistance(), bot_iter->GetCleanName());
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveFollowDistance(bot_iter->GetBotID(), bfd)) {
return;
}
@@ -6537,7 +6520,6 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) {
if (!database.botdb.SaveAllFollowDistances(c->CharacterID(), bfd)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllFollowDistances());
return;
}
@@ -6706,7 +6688,6 @@ void bot_subcommand_bot_inspect_message(Client *c, const Seperator *sep)
memcpy(bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct));
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveInspectMessage(bot_iter->GetBotID(), *bot_message_struct)) {
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveInspectMessage(), bot_iter->GetCleanName());
return;
}
@@ -6720,7 +6701,6 @@ void bot_subcommand_bot_inspect_message(Client *c, const Seperator *sep)
memcpy(&bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct));
if (!database.botdb.SaveAllInspectMessages(c->CharacterID(), bot_message_struct)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllInspectMessages());
return;
}
@@ -6800,7 +6780,6 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
std::list<BotsAvailableList> bots_list;
if (!database.botdb.LoadBotsList(c->CharacterID(), bots_list, Account)) {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadBotsList());
return;
}
@@ -6814,18 +6793,18 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
auto bot_number = 1;
for (auto bots_iter : bots_list) {
if (filter_mask) {
if ((filter_mask & MaskClass) && filter_value[FilterClass] != bots_iter.Class) {
if ((filter_mask & MaskClass) && filter_value[FilterClass] != bots_iter.class_) {
continue;
}
if ((filter_mask & MaskRace) && filter_value[FilterRace] != bots_iter.Race) {
if ((filter_mask & MaskRace) && filter_value[FilterRace] != bots_iter.race) {
continue;
}
if (filter_mask & MaskName) {
std::string name_criteria = sep->arg[name_criteria_arg];
std::transform(name_criteria.begin(), name_criteria.end(), name_criteria.begin(), ::tolower);
std::string name_check = bots_iter.Name;
std::string name_check = bots_iter.bot_name;
std::transform(name_check.begin(), name_check.end(), name_check.begin(), ::tolower);
if (name_check.find(name_criteria) == std::string::npos) {
continue;
@@ -6833,7 +6812,7 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
}
}
auto* bot = entity_list.GetBotByBotName(bots_iter.Name);
auto* bot = entity_list.GetBotByBotName(bots_iter.bot_name);
c->Message(
Chat::White,
@@ -6841,22 +6820,22 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
"Bot {} | {} is a Level {} {} {} {} owned by {}.",
bot_number,
(
(c->CharacterID() == bots_iter.Owner_ID && !bot) ?
(c->CharacterID() == bots_iter.owner_id && !bot) ?
Saylink::Silent(
fmt::format("^spawn {}", bots_iter.Name),
bots_iter.Name
fmt::format("^spawn {}", bots_iter.bot_name),
bots_iter.bot_name
) :
bots_iter.Name
bots_iter.bot_name
),
bots_iter.Level,
GetGenderName(bots_iter.Gender),
GetRaceIDName(bots_iter.Race),
GetClassIDName(bots_iter.Class),
bots_iter.Owner
bots_iter.level,
GetGenderName(bots_iter.gender),
GetRaceIDName(bots_iter.race),
GetClassIDName(bots_iter.class_),
bots_iter.owner_name
).c_str()
);
if (c->CharacterID() == bots_iter.Owner_ID) {
if (c->CharacterID() == bots_iter.owner_id) {
bots_owned++;
}
@@ -6975,10 +6954,7 @@ void bot_subcommand_bot_surname(Client *c, const Seperator *sep)
std::replace(bot_surname.begin(), bot_surname.end(), '_', ' ');
my_bot->SetSurname(bot_surname);
if (!database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, "Bot Surname Saved.");
}
}
@@ -7003,10 +6979,7 @@ void bot_subcommand_bot_title(Client *c, const Seperator *sep)
std::replace(bot_title.begin(), bot_title.end(), '_', ' ');
my_bot->SetTitle(bot_title);
if (!database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, "Bot Title Saved.");
}
}
@@ -7031,10 +7004,7 @@ void bot_subcommand_bot_suffix(Client *c, const Seperator *sep)
std::replace(bot_suffix.begin(), bot_suffix.end(), '_', ' ');
my_bot->SetSuffix(bot_suffix);
if (!database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, "Bot Suffix Saved.");
}
}
@@ -7149,7 +7119,7 @@ void bot_subcommand_bot_spawn(Client *c, const Seperator *sep)
uint32 bot_id = 0;
uint8 bot_class = Class::None;
if (!database.botdb.LoadBotID(c->CharacterID(), bot_name, bot_id, bot_class)) {
if (!database.botdb.LoadBotID(bot_name, bot_id, bot_class)) {
c->Message(
Chat::White,
fmt::format(
@@ -7387,8 +7357,7 @@ void bot_subcommand_bot_stop_melee_level(Client *c, const Seperator *sep)
// [reset] falls through with initialization value
my_bot->SetStopMeleeLevel(sml);
if (!database.botdb.SaveStopMeleeLevel(c->CharacterID(), my_bot->GetBotID(), sml))
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveStopMeleeLevel(), my_bot->GetCleanName());
database.botdb.SaveStopMeleeLevel(my_bot->GetBotID(), sml);
c->Message(Chat::White, "Successfully set stop melee level for %s to %u", my_bot->GetCleanName(), sml);
}
@@ -7587,8 +7556,7 @@ void bot_subcommand_bot_toggle_helm(Client *c, const Seperator *sep)
bot_iter->SetShowHelm(helm_state);
if (ab_type != ActionableBots::ABT_All) {
if (!database.botdb.SaveHelmAppearance(c->CharacterID(), bot_iter->GetBotID(), bot_iter->GetShowHelm())) {
c->Message(Chat::White, "%s for '%s'", bot_iter->GetCleanName());
if (!database.botdb.SaveHelmAppearance(bot_iter->GetBotID(), bot_iter->GetShowHelm())) {
return;
}
@@ -7608,12 +7576,10 @@ void bot_subcommand_bot_toggle_helm(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) {
if (toggle_helm) {
if (!database.botdb.ToggleAllHelmAppearances(c->CharacterID()))
c->Message(Chat::White, "%s", BotDatabase::fail::ToggleAllHelmAppearances());
database.botdb.ToggleAllHelmAppearances(c->CharacterID());
}
else {
if (!database.botdb.SaveAllHelmAppearances(c->CharacterID(), helm_state))
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllHelmAppearances());
database.botdb.SaveAllHelmAppearances(c->CharacterID(), helm_state);
}
c->Message(Chat::White, "%s all of your bot show helm flags", toggle_helm ? "Toggled" : (helm_state ? "Set" : "Cleared"));
@@ -8357,8 +8323,7 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
bool member_fail = false;
bool target_fail = false;
if (!database.botdb.LoadHealRotation(creator_member, member_list, target_list, load_flag, member_fail, target_fail))
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotation());
database.botdb.LoadHealRotation(creator_member, member_list, target_list, load_flag, member_fail, target_fail);
if (!load_flag) {
c->Message(Chat::White, "Successfully added %s as a current member to a new Heal Rotation", creator_member->GetCleanName());
@@ -8387,9 +8352,6 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
c->Message(Chat::White, "Could not locate member with bot id '%u'", member_iter);
}
}
else {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotationMembers());
}
if (!target_fail) {
for (auto target_iter : target_list) {
@@ -8406,9 +8368,6 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
c->Message(Chat::White, "Failed to add target '%s'", target_mob->GetCleanName());
}
}
else {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotationTargets());
}
c->Message(Chat::White, "Successfully loaded %s's Heal Rotation", creator_member->GetCleanName());
}
@@ -8430,11 +8389,7 @@ void bot_subcommand_heal_rotation_delete(Client *c, const Seperator *sep)
}
if (all_flag) {
if (database.botdb.DeleteAllHealRotations(c->CharacterID()))
c->Message(Chat::White, "Succeeded in deleting all heal rotations");
else
c->Message(Chat::White, "%s", BotDatabase::fail::DeleteAllHealRotations());
database.botdb.DeleteAllHealRotations(c->CharacterID());
return;
}
@@ -8454,7 +8409,6 @@ void bot_subcommand_heal_rotation_delete(Client *c, const Seperator *sep)
}
if (!database.botdb.DeleteHealRotation(current_member->GetBotID())) {
c->Message(Chat::White, "%s", BotDatabase::fail::DeleteHealRotation());
return;
}
@@ -8741,7 +8695,6 @@ void bot_subcommand_heal_rotation_save(Client *c, const Seperator *sep)
bool member_fail = false;
bool target_fail = false;
if (!database.botdb.SaveHealRotation(current_member, member_fail, target_fail)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveHealRotation());
return;
}
if (member_fail)
@@ -8997,15 +8950,7 @@ void bot_subcommand_inventory_list(Client *c, const Seperator *sep)
}
uint32 database_count = 0;
if (!database.botdb.QueryInventoryCount(my_bot->GetBotID(), database_count)) {
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::QueryInventoryCount()
).c_str()
);
}
database.botdb.QueryInventoryCount(my_bot->GetBotID(), database_count);
if (inventory_count != database_count) {
c->Message(
@@ -9114,7 +9059,6 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
return;
}
std::string error_message;
if (itm) {
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemInst);
@@ -9128,18 +9072,7 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
my_bot->SetBotArcherySetting(false, true);
}
my_bot->RemoveBotItemBySlot(slot_id, &error_message);
if (!error_message.empty()) {
c->Message(
Chat::White,
fmt::format(
"Database Error: {}",
error_message
).c_str()
);
return;
}
my_bot->RemoveBotItemBySlot(slot_id);
my_bot->BotRemoveEquipItem(slot_id);
my_bot->CalcBotStats(c->GetBotOption(Client::booStatsUpdate));
@@ -10671,16 +10604,7 @@ void bot_command_caster_range(Client* c, const Seperator* sep)
my_bot->SetBotCasterRange(crange);
++success_count;
if (!database.botdb.SaveBotCasterRange(c->CharacterID(), my_bot->GetBotID(), crange)) {
c->Message(
Chat::White,
fmt::format(
"{} for '{}'",
BotDatabase::fail::SaveBotCasterRange(),
my_bot->GetCleanName()
).c_str()
);
}
database.botdb.SaveBotCasterRange(my_bot->GetBotID(), crange);
}
}
if (!current_check) {
+1367 -1792
View File
File diff suppressed because it is too large Load Diff
+19 -43
View File
@@ -50,31 +50,28 @@ public:
/* Bot functions */
bool QueryNameAvailablity(const std::string& bot_name, bool& available_flag);
bool QueryBotCount(const uint32 owner_id, int class_id, uint32& bot_count, uint32& bot_class_count);
bool LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list, bool ByAccount = false);
bool LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list, bool by_account = false);
bool LoadOwnerID(const std::string& bot_name, uint32& owner_id);
bool LoadOwnerID(const uint32 bot_id, uint32& owner_id);
uint32 GetOwnerID(const uint32 bot_id);
bool LoadBotID(const uint32 owner_id, const std::string& bot_name, uint32& bot_id);
bool LoadBotID(const uint32 owner_id, const std::string& bot_name, uint32& bot_id, uint8& bot_class_id);
bool LoadBotID(const std::string& bot_name, uint32& bot_id, uint8& bot_class_id);
bool LoadBot(const uint32 bot_id, Bot*& loaded_bot);
bool SaveNewBot(Bot* bot_inst, uint32& bot_id);
bool SaveBot(Bot* bot_inst);
bool SaveNewBot(Bot* b, uint32& bot_id);
bool SaveBot(Bot* b);
bool DeleteBot(const uint32 bot_id);
bool LoadBuffs(Bot* bot_inst);
bool SaveBuffs(Bot* bot_inst);
bool LoadBuffs(Bot* b);
bool SaveBuffs(Bot* b);
bool DeleteBuffs(const uint32 bot_id);
bool LoadStance(const uint32 bot_id, int& bot_stance);
bool LoadStance(Bot* bot_inst, bool& stance_flag);
bool LoadStance(Bot* b, bool& stance_flag);
bool SaveStance(const uint32 bot_id, const int bot_stance);
bool SaveStance(Bot* bot_inst);
bool SaveStance(Bot* b);
bool DeleteStance(const uint32 bot_id);
bool LoadTimers(Bot* bot_inst);
bool SaveTimers(Bot* bot_inst);
bool LoadTimers(Bot* b);
bool SaveTimers(Bot* b);
bool DeleteTimers(const uint32 bot_id);
@@ -82,17 +79,14 @@ public:
bool QueryInventoryCount(const uint32 bot_id, uint32& item_count);
bool LoadItems(const uint32 bot_id, EQ::InventoryProfile &inventory_inst);
bool SaveItems(Bot* bot_inst);
bool DeleteItems(const uint32 bot_id);
bool LoadItemSlots(const uint32 bot_id, std::map<uint16, uint32>& m);
bool LoadItemBySlot(Bot* bot_inst);
bool LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint32& item_id);
bool SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const EQ::ItemInstance* item_inst);
bool SaveItemBySlot(Bot* b, const uint32 slot_id, const EQ::ItemInstance* inst);
bool DeleteItemBySlot(const uint32 bot_id, const uint32 slot_id);
bool LoadEquipmentColor(const uint32 bot_id, const uint8 material_slot_id, uint32& rgb);
bool SaveEquipmentColor(const uint32 bot_id, const int16 slot_id, const uint32 rgb);
bool SaveEquipmentColor(const uint32 bot_id, const int16 slot_id, const uint32 color);
bool SaveExpansionBitmask(const uint32 bot_id, const int expansion_bitmask);
bool SaveEnforceSpellSetting(const uint32 bot_id, const bool enforce_spell_setting);
@@ -126,19 +120,18 @@ public:
bool SaveAllArmorColorBySlot(const uint32 owner_id, const int16 slot_id, const uint32 rgb_value);
bool SaveAllArmorColors(const uint32 owner_id, const uint32 rgb_value);
bool SaveHelmAppearance(const uint32 owner_id, const uint32 bot_id, const bool show_flag = true);
bool SaveHelmAppearance(const uint32 bot_id, const bool show_flag = true);
bool SaveAllHelmAppearances(const uint32 owner_id, const bool show_flag = true);
bool ToggleHelmAppearance(const uint32 owner_id, const uint32 bot_id);
bool ToggleAllHelmAppearances(const uint32 owner_id);
bool SaveFollowDistance(const uint32 owner_id, const uint32 bot_id, const uint32 follow_distance);
bool SaveFollowDistance(const uint32 bot_id, const uint32 follow_distance);
bool SaveAllFollowDistances(const uint32 owner_id, const uint32 follow_distance);
bool CreateCloneBot(const uint32 owner_id, const uint32 bot_id, const std::string& clone_name, uint32& clone_id);
bool CreateCloneBotInventory(const uint32 owner_id, const uint32 bot_id, const uint32 clone_id);
bool CreateCloneBot(const uint32 bot_id, const std::string& clone_name, uint32& clone_id);
bool CreateCloneBotInventory(const uint32 bot_id, const uint32 clone_id);
bool SaveStopMeleeLevel(const uint32 owner_id, const uint32 bot_id, const uint8 sml_value);
bool SaveStopMeleeLevel(const uint32 bot_id, const uint8 sml_value);
bool SaveBotArcherSetting(const uint32 bot_id, const bool bot_archer_setting);
@@ -146,7 +139,7 @@ public:
bool SaveOwnerOption(const uint32 owner_id, size_t type, const bool flag);
bool SaveOwnerOption(const uint32 owner_id, const std::pair<size_t, size_t> type, const std::pair<bool, bool> flag);
bool SaveBotCasterRange(const uint32 owner_id, const uint32 bot_id, const uint32 bot_caster_range_value);
bool SaveBotCasterRange(const uint32 bot_id, const uint32 bot_caster_range_value);
/* Bot group functions */
bool LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 group_id, std::list<uint32>& group_list);
@@ -164,16 +157,12 @@ public:
/* Bot miscellaneous functions */
uint8 GetSpellCastingChance(uint8 spell_type_index, uint8 class_index, uint8 stance_index, uint8 conditional_index);
std::string GetBotNameByID(const uint32 bot_id);
uint16 GetRaceClassBitmask(uint16 bot_race);
uint32 GetRaceClassBitmask(uint32 bot_race);
class fail {
public:
/* fail::Bot functions */
static const char* LoadBotsList();
static const char* LoadOwnerID();
static const char* LoadBotID();
static const char* LoadBot();
static const char* SaveNewBot();
static const char* SaveBot();
@@ -189,11 +178,9 @@ public:
/* fail::Bot inventory functions */
static const char* QueryInventoryCount();
static const char* LoadItems();
static const char* SaveItems();
static const char* DeleteItems();
static const char* SaveItemBySlot();
static const char* DeleteItemBySlot();
static const char* LoadEquipmentColor();
static const char* SaveEquipmentColor();
/* fail::Bot pet functions */
@@ -212,34 +199,23 @@ public:
/* fail::Bot command functions */
static const char* LoadInspectMessage();
static const char* SaveInspectMessage();
static const char* DeleteInspectMessage();
static const char* SaveAllInspectMessages();
static const char* DeleteAllInspectMessages();
static const char* SaveAllArmorColorBySlot();
static const char* SaveAllArmorColors();
static const char* SaveHelmAppearance();
static const char* SaveAllHelmAppearances();
static const char* ToggleHelmAppearance();
static const char* ToggleAllHelmAppearances();
static const char* SaveFollowDistance();
static const char* SaveAllFollowDistances();
static const char* SaveStopMeleeLevel();
static const char* SaveBotCasterRange();
/* fail::Bot group functions */
static const char* LoadGroupedBotsByGroupID();
/* fail::Bot heal rotation functions */
static const char* LoadHealRotationIDByBotID();
static const char* LoadHealRotation();
static const char* LoadHealRotationMembers();
static const char* LoadHealRotationTargets();
static const char* SaveHealRotation();
static const char* DeleteHealRotation();
static const char* DeleteAllHealRotations();
/* fail::Bot miscellaneous functions */
static const char* GetBotNameByID();
};
private:
+4 -4
View File
@@ -25,7 +25,7 @@
#include "quest_parser_collection.h"
#include "../common/data_verification.h"
std::vector<RaidMember> Raid::GetRaidGroupMembers(uint32 gid)
std::vector<RaidMember> Raid::GetRaidGroupMembers(uint32 gid)
{
std::vector<RaidMember> raid_group_members;
raid_group_members.clear();
@@ -126,9 +126,9 @@ void Raid::HandleOfflineBots(uint32 owner) {
}
for (const auto& b: bots_list) {
if (IsRaidMember(b.Name)) {
if (IsRaidMember(b.bot_name)) {
for (const auto& m: members) {
if (m.is_bot && strcmp(m.member_name, b.Name) == 0) {
if (m.is_bot && strcmp(m.member_name, b.bot_name) == 0) {
uint32 gid = GetGroup(m.member_name);
SendRaidGroupRemove(m.member_name, gid);
RemoveMember(m.member_name);
@@ -313,7 +313,7 @@ void Client::SpawnRaidBotsOnConnect(Raid* raid) {
if (strlen(m.member_name) != 0) {
for (const auto& b: bots_list) {
if (strcmp(m.member_name, b.Name) == 0) {
if (strcmp(m.member_name, b.bot_name) == 0) {
std::string buffer = "^spawn ";
buffer.append(m.member_name);
bot_command_real_dispatch(this, buffer.c_str());
+8 -8
View File
@@ -24,14 +24,14 @@
#include <sstream>
struct BotsAvailableList {
uint32 ID;
char Name[64];
uint16 Class;
uint8 Level;
uint16 Race;
uint8 Gender;
char Owner[64];
uint32 Owner_ID;
uint32 bot_id;
char bot_name[64];
uint16 class_;
uint8 level;
uint16 race;
uint8 gender;
char owner_name[64];
uint32 owner_id;
};
struct BotSpell {
+5
View File
@@ -14905,6 +14905,11 @@ void Client::Handle_OP_Taunt(const EQApplicationPacket *app)
return;
}
if (DistanceSquared(GetPosition(), GetTarget()->GetPosition()) > (RuleI(Skills, MaximumTauntDistance) * (RuleI(Skills, MaximumTauntDistance)))) {
MessageString(Chat::TooFarAway, TAUNT_TOO_FAR);
return;
}
Taunt(GetTarget()->CastToNPC(), false);
return;
}
+1 -1
View File
@@ -525,7 +525,7 @@ void EntityList::MobProcess()
// -- the entity's spawn2 point is marked as path_while_zone_idle
// -- the zone is newly empty and we're allowing mobs to settle
if (
numclients > 0 ||
numclients > 0 || zone->quest_idle_override ||
(s2 && s2->PathWhenZoneIdle()) ||
mob_settle_timer->Enabled()
) {
+106 -100
View File
@@ -31,6 +31,8 @@
#include "water_map.h"
#include "zonedb.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/repositories/forage_repository.h"
#include "../common/repositories/fishing_repository.h"
#include "../common/events/player_event_logs.h"
#include "worldserver.h"
@@ -46,141 +48,145 @@ struct NPCType;
//for a given zone.
#define FORAGE_ITEM_LIMIT 50
uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) {
uint32 ZoneDatabase::LoadForage(uint32 zone_id, uint8 skill_level)
{
uint32 forage_items[FORAGE_ITEM_LIMIT];
uint32 item[FORAGE_ITEM_LIMIT];
uint32 chance[FORAGE_ITEM_LIMIT];
uint32 ret;
for (int c=0; c < FORAGE_ITEM_LIMIT; c++) {
item[c] = 0;
for (uint16 slot_id = 0; slot_id < FORAGE_ITEM_LIMIT; slot_id++) {
forage_items[slot_id] = 0;
}
uint32 chancepool = 0;
std::string query = fmt::format(
SQL(
SELECT
itemid,
chance
FROM
forage
WHERE
zoneid = '{}'
and level <= '{}'
{}
LIMIT
{}
),
ZoneID,
skill,
ContentFilterCriteria::apply(),
FORAGE_ITEM_LIMIT
const auto& l = ForageRepository::GetWhere(
*this,
fmt::format(
"(`zoneid` = {} || `zoneid` = 0) AND `level` <= {} {} LIMIT {}",
zone_id,
skill_level,
ContentFilterCriteria::apply(),
FORAGE_ITEM_LIMIT
)
);
auto results = QueryDatabase(query);
if (!results.Success()) {
if (l.empty()) {
return 0;
}
uint8 index = 0;
for (auto row = results.begin(); row != results.end(); ++row, ++index) {
if (index >= FORAGE_ITEM_LIMIT) {
LogInfo(
"Loaded [{}] Forage Item{}",
Strings::Commify(l.size()),
l.size() != 1 ? "s" : ""
);
int forage_chances[FORAGE_ITEM_LIMIT];
int current_chance = 0;
uint32 item_id = 0;
uint8 count = 0;
for (const auto& e : l) {
if (count >= FORAGE_ITEM_LIMIT) {
break;
}
item[index] = Strings::ToInt(row[0]);
chance[index] = Strings::ToInt(row[1]) + chancepool;
chancepool = chance[index];
forage_items[count] = e.Itemid;
forage_chances[count] = e.chance;
current_chance = forage_chances[count];
count++;
}
if(chancepool == 0 || index < 1)
if (current_chance == 0 || count < 1) {
return 0;
if(index == 1) {
return item[0];
}
ret = 0;
if (count == 1) {
return forage_items[0];
}
uint32 rindex = zone->random.Int(1, chancepool);
const int roll = zone->random.Int(1, current_chance);
for(int i = 0; i < index; i++) {
if(rindex <= chance[i]) {
ret = item[i];
for (uint16 slot_id = 0; slot_id < count; slot_id++) {
if (roll <= forage_chances[slot_id]) {
item_id = forage_items[slot_id];
break;
}
}
return ret;
return item_id;
}
uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, uint8 &npc_chance)
uint32 ZoneDatabase::LoadFishing(uint32 zone_id, uint8 skill_level, uint32 &npc_id, uint8 &npc_chance)
{
uint32 item[50];
uint32 chance[50];
uint32 npc_ids[50];
uint32 npc_chances[50];
uint32 chancepool = 0;
uint32 ret = 0;
uint32 fishing_items[50];
int fishing_chances[50];
for (int c=0; c<50; c++) {
item[c]=0;
chance[c]=0;
for (uint16 slot_id = 0; slot_id < 50; slot_id++) {
fishing_items[slot_id] = 0;
fishing_chances[slot_id] = 0;
}
std::string query = fmt::format(
SQL(
SELECT
itemid,
chance,
npc_id,
npc_chance
FROM
fishing
WHERE
(zoneid = '{}' || zoneid = 0)
AND skill_level <= '{}'
{}
),
ZoneID,
skill,
ContentFilterCriteria::apply()
const auto& l = FishingRepository::GetWhere(
*this,
fmt::format(
"(`zoneid` = {} || `zoneid` = 0) AND `skill_level` <= {} {}",
zone_id,
skill_level,
ContentFilterCriteria::apply()
)
);
auto results = QueryDatabase(query);
if (!results.Success()) {
if (l.empty()) {
return 0;
}
}
uint8 index = 0;
for (auto row = results.begin(); row != results.end(); ++row, ++index) {
if (index >= 50)
break;
LogInfo(
"Loaded [{}] Fishing Item{}",
Strings::Commify(l.size()),
l.size() != 1 ? "s" : ""
);
item[index] = Strings::ToInt(row[0]);
chance[index] = Strings::ToInt(row[1])+chancepool;
chancepool = chance[index];
uint32 npc_ids[50];
uint32 npc_chances[50];
npc_ids[index] = Strings::ToInt(row[2]);
npc_chances[index] = Strings::ToInt(row[3]);
}
int current_chance = 0;
uint32 item_id = 0;
uint8 count = 0;
npc_id = 0;
for (const auto &e: l) {
if (count >= 50) {
break;
}
fishing_items[count] = e.Itemid;
fishing_chances[count] = e.chance + current_chance;
npc_ids[count] = e.npc_id;
npc_chances[count] = e.npc_chance;
current_chance = fishing_chances[count];
}
npc_id = 0;
npc_chance = 0;
if (index <= 0)
return 0;
uint32 random = zone->random.Int(1, chancepool);
for (int i = 0; i < index; i++)
{
if (random > chance[i])
continue;
if (count <= 0) {
return 0;
}
ret = item[i];
npc_id = npc_ids[i];
npc_chance = npc_chances[i];
break;
}
const int roll = zone->random.Int(1, current_chance);
return ret;
for (uint16 i = 0; i < count; i++) {
if (roll > fishing_chances[i]) {
continue;
}
item_id = fishing_items[i];
npc_id = npc_ids[i];
npc_chance = npc_chances[i];
break;
}
return item_id;
}
//we need this function to immediately determine, after we receive OP_Fishing, if we can even try to fish, otherwise we have to wait a while to get the failure
@@ -307,7 +313,7 @@ void Client::GoFish()
if (zone->random.Int(0, 399) <= fishing_skill ) {
uint32 npc_id = 0;
uint8 npc_chance = 0;
food_id = content_db.GetZoneFishing(m_pp.zone_id, fishing_skill, npc_id, npc_chance);
food_id = content_db.LoadFishing(m_pp.zone_id, fishing_skill, npc_id, npc_chance);
//check for add NPC
if (npc_chance > 0 && npc_id) {
@@ -452,7 +458,7 @@ void Client::ForageItem(bool guarantee) {
uint32 stringid = FORAGE_NOEAT;
if (zone->random.Roll(RuleI(Zone, ForageChance))) {
foragedfood = content_db.GetZoneForage(m_pp.zone_id, skill_level);
foragedfood = content_db.LoadForage(m_pp.zone_id, skill_level);
}
//not an else in case theres no DB food
+106 -84
View File
@@ -1,82 +1,138 @@
#include "../client.h"
#include "../../common/repositories/grid_entries_repository.h"
void command_grid(Client *c, const Seperator *sep)
{
auto command_type = sep->arg[1];
auto zone_id = zone->GetZoneID();
if (strcasecmp("max", command_type) == 0) {
c->Message(
Chat::White,
fmt::format(
"Highest grid ID in this zone is {}.",
content_db.GetHighestGrid(zone_id)
).c_str()
);
const uint16 arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #grid add [Grid ID] [Wander Type] [Pause Type] - Add a grid with the specified wander and pause type");
c->Message(Chat::White, "Usage: #grid delete [Grid ID] - Delete a grid");
c->Message(Chat::White, "Usage: #grid hide - Hides waypoint nodes from targeted NPC's grid");
c->Message(Chat::White, "Usage: #grid max - Displays the highest grid ID used in this zone (for add)");
c->Message(Chat::White, "Usage: #grid show - Displays waypoint nodes for targeted NPC's grid");
return;
}
else if (strcasecmp("add", command_type) == 0) {
auto grid_id = Strings::ToInt(sep->arg[2]);
auto wander_type = Strings::ToInt(sep->arg[3]);
auto pause_type = Strings::ToInt(sep->arg[4]);
if (!content_db.GridExistsInZone(zone_id, grid_id)) {
content_db.ModifyGrid(c, false, grid_id, wander_type, pause_type, zone_id);
const bool is_add = !strcasecmp(sep->arg[1], "add");
const bool is_delete = !strcasecmp(sep->arg[1], "delete");
const bool is_hide = !strcasecmp(sep->arg[1], "hide");
const bool is_max = !strcasecmp(sep->arg[1], "max");
const bool is_show = !strcasecmp(sep->arg[1], "show");
if (!is_add && !is_delete && !is_hide && !is_max && !is_show) {
c->Message(Chat::White, "Usage: #grid add [Grid ID] [Wander Type] [Pause Type] - Add a grid with the specified wander and pause type");
c->Message(Chat::White, "Usage: #grid delete [Grid ID] - Delete a grid");
c->Message(Chat::White, "Usage: #grid hide - Hides waypoint nodes from targeted NPC's grid");
c->Message(Chat::White, "Usage: #grid max - Displays the highest grid ID used in this zone (for add)");
c->Message(Chat::White, "Usage: #grid show - Displays waypoint nodes for targeted NPC's grid");
return;
}
if (is_add) {
const uint32 grid_id = Strings::ToUnsignedInt(sep->arg[2]);
const uint8 wander_type = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[3]));
const uint8 pause_type = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[4]));
if (!grid_id) {
c->Message(Chat::White, "You must specify a valid grid ID.");
return;
}
if (!content_db.GridExistsInZone(zone->GetZoneID(), grid_id)) {
content_db.ModifyGrid(c, false, grid_id, wander_type, pause_type, zone->GetZoneID());
c->Message(
Chat::White,
fmt::format(
"Grid {} added to zone ID {} with wander type {} and pause type {}.",
grid_id,
zone_id,
zone->GetZoneID(),
wander_type,
pause_type
).c_str()
);
}
else {
} else {
c->Message(
Chat::White,
fmt::format(
"Grid {} already exists in zone ID {}.",
grid_id,
zone_id
zone->GetZoneID()
).c_str()
);
return;
}
}
else if (strcasecmp("show", command_type) == 0) {
Mob *target = c->GetTarget();
if (!target || !target->IsNPC()) {
c->Message(Chat::White, "You need to target an NPC!");
} else if (is_delete) {
const uint32 grid_id = Strings::ToUnsignedInt(sep->arg[2]);
content_db.ModifyGrid(c, true, grid_id, 0, 0, zone->GetZoneID());
c->Message(
Chat::White,
fmt::format(
"Grid {} deleted from zone ID {}.",
grid_id,
zone->GetZoneID()
).c_str()
);
} else if (is_hide) {
Mob* t = c->GetTarget();
if (!t || !t->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
auto grid_id = target->CastToNPC()->GetGrid();
std::string query = fmt::format(
"SELECT `x`, `y`, `z`, `heading`, `number` "
"FROM `grid_entries` "
"WHERE `zoneid` = {} AND `gridid` = {} "
"ORDER BY `number`",
zone_id,
grid_id
const uint32 grid_id = t->CastToNPC()->GetGrid();
entity_list.DespawnGridNodes(grid_id);
c->Message(
Chat::White,
fmt::format(
"Depawning nodes for grid {}.",
grid_id
).c_str()
);
} else if (is_max) {
c->Message(
Chat::White,
fmt::format(
"Highest grid ID in this zone is {}.",
content_db.GetHighestGrid(zone->GetZoneID())
).c_str()
);
} else if (is_show) {
Mob* t = c->GetTarget();
if (!t || !t->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
const uint32 grid_id = t->CastToNPC()->GetGrid();
const auto& l = GridEntriesRepository::GetWhere(
content_db,
fmt::format(
"`zoneid` = {} AND `gridid` = {} ORDER BY `number`",
zone->GetZoneID(),
grid_id
)
);
auto results = content_db.QueryDatabase(query);
if (!results.Success()) {
c->Message(Chat::White, "Error querying database.");
c->Message(Chat::White, query.c_str());
}
if (results.RowCount() == 0) {
if (l.empty()) {
c->Message(Chat::White, "No grid found.");
return;
}
// Depop any node npc's already spawned
// Depop any grid nodes already spawned
entity_list.DespawnGridNodes(grid_id);
// Spawn grid nodes
std::map<std::vector<float>, int32> zoffset;
for (auto row : results) {
glm::vec4 node_position = glm::vec4(Strings::ToFloat(row[0]), Strings::ToFloat(row[1]), Strings::ToFloat(row[2]), Strings::ToFloat(row[3]));
for (const auto& e : l) {
glm::vec4 node_position = glm::vec4(e.x, e.y, e.z, e.heading);
std::vector<float> node_loc{
node_position.x,
node_position.y,
@@ -84,19 +140,20 @@ void command_grid(Client *c, const Seperator *sep)
};
// If we already have a node at this location, set the z offset
// higher from the existing one so we can see it. Adjust so if
// higher from the existing one, so we can see it. Adjust so if
// there is another at the same spot we adjust again.
auto search = zoffset.find(node_loc);
if (search != zoffset.end()) {
search->second = search->second + 3;
}
else {
search->second += 3;
} else {
zoffset[node_loc] = 0.0;
}
node_position.z += zoffset[node_loc];
NPC::SpawnGridNodeNPC(node_position, grid_id, Strings::ToInt(row[4]), zoffset[node_loc]);
NPC::SpawnGridNodeNPC(node_position, grid_id, e.number, zoffset[node_loc]);
}
c->Message(
Chat::White,
fmt::format(
@@ -105,39 +162,4 @@ void command_grid(Client *c, const Seperator *sep)
).c_str()
);
}
else if (strcasecmp("hide", command_type) == 0) {
Mob *target = c->GetTarget();
if (!target || !target->IsNPC()) {
c->Message(Chat::White, "You need to target an NPC!");
return;
}
auto grid_id = target->CastToNPC()->GetGrid();
entity_list.DespawnGridNodes(grid_id);
c->Message(
Chat::White,
fmt::format(
"Depawning nodes for grid {}.",
grid_id
).c_str()
);
}
else if (strcasecmp("delete", command_type) == 0) {
auto grid_id = Strings::ToInt(sep->arg[2]);
content_db.ModifyGrid(c, true, grid_id, 0, 0, zone_id);
c->Message(
Chat::White,
fmt::format(
"Grid {} deleted from zone ID {}.",
grid_id,
zone_id
).c_str()
);
}
else {
c->Message(Chat::White, "Usage: #grid [add|delete] [grid_id] [wander_type] [pause_type]");
c->Message(Chat::White, "Usage: #grid [max] - displays the highest grid ID used in this zone (for add)");
c->Message(Chat::White, "Usage: #grid [show] - displays wp nodes as boxes");
}
}
+57 -16
View File
@@ -2,24 +2,65 @@
void command_petitems(Client *c, const Seperator *sep)
{
if (!c->GetPet()) {
c->Message(Chat::White, "You must have a pet to use this command.");
NPC* t = nullptr;
if (c->GetPet()) {
t = c->GetPet()->CastToNPC();
}
if (c->GetTarget() && c->GetTarget()->IsNPC()) {
t = c->GetTarget()->CastToNPC();
}
if (!t || !t->IsPet()) {
c->Message(Chat::White, "You must have a pet or target a bot's pet to use this command.");
return;
}
Mob* o = t->GetOwner();
if (!o) {
c->Message(Chat::White, "Invalid owner for pet.");
return;
}
auto pet = c->GetPet()->CastToNPC();
auto loot_list = pet->GetLootList();
if (!loot_list.empty()) {
pet->QueryLoot(c, true);
c->Message(
Chat::White,
fmt::format(
"Your pet has {} item{}.",
loot_list.size(),
loot_list.size() != 1 ? "s" : ""
).c_str()
);
} else {
c->Message(Chat::White, "Your pet has no items.");
if (
o->IsBot() &&
o->CastToBot()->GetBotOwnerCharacterID() != c->CharacterID()
) {
c->Message(Chat::White, "You do not own the targeted pet.");
return;
}
if (
o->IsClient() &&
o->GetID() != c->GetID()
) {
c->Message(Chat::White, "You do not own the targeted pet.");
return;
}
const std::string& pet_owner = (
o->IsClient() ?
"Your" :
fmt::format(
"Your bot {}{}",
o->GetCleanName(),
Strings::EndsWith(o->GetCleanName(), "s") ? "'" : "'s"
)
);
const auto& l = t->GetLootList();
if (!l.empty()) {
t->QueryLoot(c, true);
}
c->Message(
Chat::White,
fmt::format(
"{} pet has {} item{}.",
pet_owner,
l.size(),
l.size() != 1 ? "s" : ""
).c_str()
);
}
+2 -2
View File
@@ -14,12 +14,12 @@ void command_wp(Client *c, const Seperator *sep)
}
if (strcasecmp("-h", sep->arg[5]) == 0) {
content_db.AddWP(c, grid_id, waypoint, c->GetPosition(), pause, zone_id);
content_db.AddWaypoint(c, grid_id, waypoint, c->GetPosition(), pause, zone_id);
}
else {
auto position = c->GetPosition();
position.w = -1;
content_db.AddWP(c, grid_id, waypoint, position, pause, zone_id);
content_db.AddWaypoint(c, grid_id, waypoint, position, pause, zone_id);
}
c->Message(
Chat::White,
+1 -1
View File
@@ -29,7 +29,7 @@ void command_wpadd(Client *c, const Seperator *sep)
}
auto zone_id = zone->GetZoneID();
uint32 tmp_grid = content_db.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone_id);
uint32 tmp_grid = content_db.AddWaypointForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone_id);
if (tmp_grid) {
target->CastToNPC()->SetGrid(tmp_grid);
}
+10 -7
View File
@@ -80,15 +80,18 @@ bool HateList::IsEntOnHateList(Mob *mob)
return false;
}
struct_HateList *HateList::Find(Mob *in_entity)
struct_HateList* HateList::Find(Mob* m)
{
auto iterator = list.begin();
while (iterator != list.end())
{
if ((*iterator)->entity_on_hatelist == in_entity)
return (*iterator);
++iterator;
if (!m) {
return nullptr;
}
for (auto* e : list) {
if (e->entity_on_hatelist && e->entity_on_hatelist == m) {
return e;
}
}
return nullptr;
}
+1 -1
View File
@@ -89,7 +89,7 @@ public:
protected:
struct_HateList *Find(Mob *ent);
struct_HateList* Find(Mob* m);
private:
std::list<struct_HateList *> list;
Mob *hate_owner;
+2 -3
View File
@@ -1800,9 +1800,8 @@ void Mob::AI_Event_Engaged(Mob *attacker, bool yell_for_help)
parse->EventNPC(EVENT_COMBAT, CastToNPC(), attacker, "1", 0);
}
const uint32 emote_id = GetEmoteID();
if (emote_id) {
CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::EnterCombat, emote_id, attacker);
if (emoteid) {
CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::EnterCombat, emoteid, attacker);
}
std::string mob_name = GetCleanName();
+6 -9
View File
@@ -438,7 +438,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
qGlobals = nullptr;
SetEmoteID(static_cast<uint32>(npc_type_data->emoteid));
SetEmoteID(npc_type_data->emoteid);
InitializeBuffSlots();
CalcBonuses();
@@ -1113,9 +1113,8 @@ void NPC::UpdateEquipmentLight()
}
void NPC::Depop(bool start_spawn_timer) {
const uint32 emote_id = GetEmoteID();
if (emote_id) {
DoNPCEmote(EQ::constants::EmoteEventTypes::OnDespawn, emote_id);
if (emoteid) {
DoNPCEmote(EQ::constants::EmoteEventTypes::OnDespawn, emoteid);
}
if (IsNPC()) {
@@ -3073,10 +3072,8 @@ void NPC::SendPayload(int payload_id, std::string payload_value)
NPC_Emote_Struct* NPC::GetNPCEmote(uint32 emote_id, uint8 event_) {
std::vector<NPC_Emote_Struct*> emotes;
for (const auto &e : zone->npc_emote_list) {
auto nes = e;
if (nes->emoteid == emote_id && nes->event_ == event_) {
for (auto& e : zone->npc_emote_list) {
if (e->emoteid == emote_id && e->event_ == event_) {
emotes.emplace_back(e);
}
}
@@ -3098,7 +3095,7 @@ void NPC::DoNPCEmote(uint8 event_, uint32 emote_id, Mob* t)
return;
}
auto e = GetNPCEmote(emote_id, event_);
const auto& e = GetNPCEmote(emote_id, event_);
if (!e) {
return;
}
+26 -29
View File
@@ -21,6 +21,7 @@
#include "../common/strings.h"
#include "../common/repositories/pets_repository.h"
#include "../common/repositories/pets_beastlord_data_repository.h"
#include "entity.h"
#include "client.h"
@@ -196,15 +197,18 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
}
// Beastlord Pets
if(record.petnaming == 2) {
if (record.petnaming == 2) {
uint16 race_id = GetBaseRace();
auto beastlord_pet_data = content_db.GetBeastlordPetData(race_id);
npc_type->race = beastlord_pet_data.race_id;
npc_type->texture = beastlord_pet_data.texture;
npc_type->helmtexture = beastlord_pet_data.helm_texture;
npc_type->gender = beastlord_pet_data.gender;
npc_type->size *= beastlord_pet_data.size_modifier;
npc_type->luclinface = beastlord_pet_data.face;
auto d = content_db.GetBeastlordPetData(race_id);
npc_type->race = d.race_id;
npc_type->texture = d.texture;
npc_type->helmtexture = d.helm_texture;
npc_type->gender = d.gender;
npc_type->luclinface = d.face;
npc_type->size *= d.size_modifier;
}
// handle monster summoning pet appearance
@@ -655,27 +659,20 @@ bool Pet::CheckSpellLevelRestriction(Mob *caster, uint16 spell_id)
}
BeastlordPetData::PetStruct ZoneDatabase::GetBeastlordPetData(uint16 race_id) {
BeastlordPetData::PetStruct beastlord_pet_data;
std::string query = fmt::format(
SQL(
SELECT
`pet_race`, `texture`, `helm_texture`, `gender`, `size_modifier`, `face`
FROM `pets_beastlord_data`
WHERE `player_race` = {}
),
race_id
);
auto results = QueryDatabase(query);
if (!results.Success() || results.RowCount() != 1) {
return beastlord_pet_data;
BeastlordPetData::PetStruct d;
const auto& e = PetsBeastlordDataRepository::FindOne(*this, race_id);
if (!e.player_race) {
return d;
}
auto row = results.begin();
beastlord_pet_data.race_id = Strings::ToInt(row[0]);
beastlord_pet_data.texture = Strings::ToInt(row[1]);
beastlord_pet_data.helm_texture = Strings::ToInt(row[2]);
beastlord_pet_data.gender = Strings::ToInt(row[3]);
beastlord_pet_data.size_modifier = Strings::ToFloat(row[4]);
beastlord_pet_data.face = Strings::ToInt(row[5]);
return beastlord_pet_data;
d.race_id = e.pet_race;
d.texture = e.texture;
d.helm_texture = e.helm_texture;
d.gender = e.gender;
d.size_modifier = e.size_modifier;
d.face = e.face;
return d;
}
+37 -26
View File
@@ -41,6 +41,7 @@
#include "../common/repositories/tradeskill_recipe_repository.h"
#include "../common/repositories/instance_list_repository.h"
#include "../common/repositories/grid_entries_repository.h"
#include <iostream>
#include <limits.h>
@@ -934,9 +935,9 @@ void QuestManager::repopzone() {
}
}
void QuestManager::processmobswhilezoneempty(bool turn_on) {
void QuestManager::processmobswhilezoneempty(bool on) {
if (zone) {
zone->SetIdleWhenEmpty(!turn_on);
zone->quest_idle_override = on;
} else {
LogQuests(
"QuestManager::processmobswhilezoneempty called with nullptr zone. Probably syntax error in quest file"
@@ -1988,38 +1989,48 @@ void QuestManager::setanim(int npc_type, int animnum) {
}
//displays an in game path based on a waypoint grid
void QuestManager::showgrid(int grid) {
void QuestManager::showgrid(int grid_id)
{
QuestManagerCurrentQuestVars();
if(initiator == nullptr)
if (!initiator) {
return;
}
FindPerson_Point pt;
std::vector<FindPerson_Point> pts;
std::vector<FindPerson_Point> v;
pt.x = initiator->GetX();
pt.y = initiator->GetY();
pt.z = initiator->GetZ();
pts.push_back(pt);
v.push_back(
FindPerson_Point{
.y = initiator->GetY(),
.x = initiator->GetX(),
.z = initiator->GetZ()
}
);
// Retrieve all waypoints for this grid
std::string query = StringFormat("SELECT `x`,`y`,`z` FROM grid_entries "
"WHERE `gridid` = %i AND `zoneid` = %i "
"ORDER BY `number`", grid, zone->GetZoneID());
auto results = content_db.QueryDatabase(query);
if (!results.Success()) {
LogQuests("Error loading grid [{}] for showgrid(): [{}]", grid, results.ErrorMessage().c_str());
const auto& l = GridEntriesRepository::GetWhere(
content_db,
fmt::format(
"`gridid` = {} AND `zoneid` = {} ORDER BY `number`",
grid_id,
zone->GetZoneID()
)
);
if (l.empty()) {
return;
}
}
for(auto row = results.begin(); row != results.end(); ++row) {
pt.x = Strings::ToFloat(row[0]);
pt.y = Strings::ToFloat(row[1]);
pt.z = Strings::ToFloat(row[2]);
for (const auto& e : l) {
v.push_back(
FindPerson_Point{
.y = e.y,
.x = e.x,
.z = e.z
}
);
}
pts.push_back(pt);
}
initiator->SendPathPacket(pts);
initiator->SendPathPacket(v);
}
+2 -2
View File
@@ -106,7 +106,7 @@ public:
void depopall(int npc_type = 0);
void depopzone(bool StartSpawnTimer = true);
void repopzone();
void processmobswhilezoneempty(bool idle_when_empty);
void processmobswhilezoneempty(bool quest_override_on);
void settarget(const char *type, int target_id);
void follow(int entity_id, int distance);
void sfollow();
@@ -183,7 +183,7 @@ public:
void enable_proximity_say();
void disable_proximity_say();
void setanim(int npc_type, int animnum);
void showgrid(int gridid);
void showgrid(int grid_id);
void spawn_condition(const char *zone_short, uint32 instance_id, uint16 condition_id, short new_value);
short get_spawn_condition(const char *zone_short, uint32 instance_id, uint16 condition_id);
void toggle_spawn_event(int event_id, bool enable, bool strict, bool reset_base);
+218 -194
View File
@@ -27,6 +27,9 @@
#include "zone.h"
#include "zonedb.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/repositories/spawn_conditions_repository.h"
#include "../common/repositories/spawn_condition_values_repository.h"
#include "../common/repositories/spawn_events_repository.h"
#include "../common/repositories/spawn2_repository.h"
#include "../common/repositories/spawn2_disabled_repository.h"
#include "../common/repositories/respawn_times_repository.h"
@@ -253,7 +256,7 @@ bool Spawn2::Process() {
if (spawn_group->wp_spawns && grid_ > 0)
{
glm::vec4 wploc;
starting_wp = content_db.GetRandomWaypointLocFromGrid(wploc, zone->GetZoneID(), grid_);
starting_wp = content_db.GetRandomWaypointFromGrid(wploc, zone->GetZoneID(), grid_);
if (wploc.x != 0.0f || wploc.y != 0.0f || wploc.z != 0.0f)
{
loc = wploc;
@@ -539,23 +542,31 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
return true;
}
bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* zone, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value)
bool ZoneDatabase::CreateSpawn2(
Client* c,
uint32 spawngroup_id,
const std::string& zone_short_name,
const glm::vec4& position,
uint32 respawn,
uint32 variance,
uint16 condition,
int16 condition_value
)
{
auto e = Spawn2Repository::NewEntity();
std::string query = StringFormat("INSERT INTO spawn2 (spawngroupID, zone, x, y, z, heading, "
"respawntime, variance, _condition, cond_value) "
"VALUES (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)",
spawngroup, zone, position.x, position.y, position.z, position.w,
respawn, variance, condition, cond_value);
auto results = QueryDatabase(query);
if (!results.Success()) {
return false;
}
e.spawngroupID = spawngroup_id;
e.zone = zone_short_name;
e.x = position.x;
e.y = position.y;
e.z = position.z;
e.heading = position.w;
e.respawntime = respawn;
e.variance = variance;
e._condition = condition;
e.cond_value = condition_value;
if (results.RowsAffected() != 1)
return false;
return true;
return Spawn2Repository::InsertOne(*this, e).id;
}
uint32 Zone::CountSpawn2() {
@@ -718,7 +729,7 @@ void SpawnConditionManager::Process() {
EQTime::ToString(&cevent.next, t);
LogSpawns("Event [{}]: Will trigger again in [{}] EQ minutes at [{}]", cevent.id, cevent.period, t.c_str());
//save the next event time in the DB
UpdateDBEvent(cevent);
UpdateSpawnEvent(cevent);
//find the next closest event timer.
FindNearestEvent();
//minor optimization, if theres no more possible events,
@@ -786,147 +797,162 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
cond.value = new_value;
}
void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) {
void SpawnConditionManager::UpdateSpawnEvent(SpawnEvent &event)
{
auto e = SpawnEventsRepository::FindOne(database, event.id);
std::string query = StringFormat("UPDATE spawn_events SET "
"next_minute = %d, next_hour = %d, "
"next_day = %d, next_month = %d, "
"next_year = %d, enabled = %d, "
"strict = %d WHERE id = %d",
event.next.minute, event.next.hour,
event.next.day, event.next.month,
event.next.year, event.enabled? 1: 0,
event.strict? 1: 0, event.id);
database.QueryDatabase(query);
e.next_minute = event.next.minute;
e.next_hour = event.next.hour;
e.next_day = event.next.day;
e.next_month = event.next.month;
e.next_year = event.next.year;
e.enabled = event.enabled ? 1 : 0;
e.next_minute = event.strict;
SpawnEventsRepository::UpdateOne(database, e);
}
void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value) {
std::string query = StringFormat("REPLACE INTO spawn_condition_values "
"(id, value, zone, instance_id) "
"VALUES( %u, %u, '%s', %u)",
cond_id, value, zone_name, instance_id);
database.QueryDatabase(query);
void SpawnConditionManager::UpdateSpawnCondition(
const std::string& zone_short_name,
uint32 instance_id,
uint16 condition,
int16 condition_value
)
{
SpawnConditionValuesRepository::ReplaceOne(
database,
SpawnConditionValuesRepository::SpawnConditionValues{
.id = condition,
.value = static_cast<uint8_t>(condition_value),
.zone = zone_short_name,
.instance_id = instance_id
}
);
}
bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) {
bool SpawnConditionManager::LoadSpawnEvent(
uint32 event_id,
SpawnEvent& event,
std::string& zone_short_name
)
{
const auto& e = SpawnEventsRepository::FindOne(database, event_id);
std::string query = StringFormat("SELECT id, cond_id, period, "
"next_minute, next_hour, next_day, "
"next_month, next_year, enabled, "
"action, argument, strict, zone "
"FROM spawn_events WHERE id = %d", event_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
if (!e.id) {
return false;
}
if (results.RowCount() == 0)
return false;
event.id = e.id;
event.condition_id = e.cond_id;
event.period = e.period;
event.next.minute = e.next_minute;
event.next.hour = e.next_hour;
event.next.day = e.next_day;
event.next.month = e.next_month;
event.next.year = e.next_year;
event.enabled = e.enabled;
event.action = static_cast<SpawnEvent::Action>(e.action);
event.argument = e.argument;
event.strict = e.strict;
auto row = results.begin();
zone_short_name = e.zone;
event.id = Strings::ToInt(row[0]);
event.condition_id = Strings::ToInt(row[1]);
event.period = Strings::ToInt(row[2]);
std::string time_string;
EQTime::ToString(&event.next, time_string);
event.next.minute = Strings::ToInt(row[3]);
event.next.hour = Strings::ToInt(row[4]);
event.next.day = Strings::ToInt(row[5]);
event.next.month = Strings::ToInt(row[6]);
event.next.year = Strings::ToInt(row[7]);
event.enabled = Strings::ToInt(row[8]) != 0;
event.action = (SpawnEvent::Action) Strings::ToInt(row[9]);
event.argument = Strings::ToInt(row[10]);
event.strict = Strings::ToInt(row[11]) != 0;
zone_name = row[12];
std::string timeAsString;
EQTime::ToString(&event.next, timeAsString);
LogSpawns("(LoadDBEvent) Loaded [{}] spawn event [{}] on condition [{}] with period [{}] action [{}] argument [{}] strict [{}]. Will trigger at [{}]", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, timeAsString.c_str());
LogSpawns(
"Loaded [{}] event_id [{}] condition [{}] period [{}] action [{}] argument [{}] strict [{}] time [{}]",
event.enabled ? "enabled" : "disabled",
event.id,
event.condition_id,
event.period,
event.action,
event.argument,
event.strict,
time_string
);
return true;
}
bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 instance_id)
bool SpawnConditionManager::LoadSpawnConditions(const std::string& zone_short_name, uint32 instance_id)
{
//clear out old stuff..
spawn_conditions.clear();
std::string query = StringFormat("SELECT id, onchange, value "
"FROM spawn_conditions "
"WHERE zone = '%s'", zone_name);
auto results = content_db.QueryDatabase(query);
if (!results.Success()) {
return false;
}
const auto& conditions = SpawnConditionsRepository::GetWhere(
content_db,
fmt::format(
"`zone` = '{}'",
Strings::Escape(zone_short_name)
)
);
for (auto row = results.begin(); row != results.end(); ++row) {
//load spawn conditions
SpawnCondition cond;
for (const auto& e : conditions) {
SpawnCondition c;
cond.condition_id = Strings::ToInt(row[0]);
cond.value = Strings::ToInt(row[2]);
cond.on_change = (SpawnCondition::OnChange) Strings::ToInt(row[1]);
spawn_conditions[cond.condition_id] = cond;
c.condition_id = e.id;
c.value = e.value;
c.on_change = static_cast<SpawnCondition::OnChange>(e.onchange);
LogSpawns("Loaded spawn condition [{}] with value [{}] and on_change [{}]", cond.condition_id, cond.value, cond.on_change);
}
spawn_conditions[c.condition_id] = c;
LogInfo("Loaded [{}] spawn_conditions", Strings::Commify(std::to_string(results.RowCount())));
LogSpawns(
"Loaded spawn condition [{}] with value [{}] and on_change [{}]",
c.condition_id,
c.value,
c.on_change
);
}
//load values
query = StringFormat("SELECT id, value FROM spawn_condition_values "
"WHERE zone = '%s' AND instance_id = %u",
zone_name, instance_id);
results = database.QueryDatabase(query);
if (!results.Success()) {
spawn_conditions.clear();
return false;
}
LogInfo("Loaded [{}] spawn_conditions", Strings::Commify(std::to_string(conditions.size())));
for (auto row = results.begin(); row != results.end(); ++row) {
auto iter = spawn_conditions.find(Strings::ToInt(row[0]));
const auto& condition_values = SpawnConditionValuesRepository::GetWhere(
database,
fmt::format(
"`zone` = '{}' AND `instance_id` = {}",
Strings::Escape(zone_short_name),
instance_id
)
);
if(iter != spawn_conditions.end())
iter->second.value = Strings::ToInt(row[1]);
}
for (const auto& e : condition_values) {
auto i = spawn_conditions.find(e.id);
if (i != spawn_conditions.end()) {
i->second.value = e.value;
}
}
//load spawn events
query = StringFormat("SELECT id, cond_id, period, next_minute, next_hour, "
"next_day, next_month, next_year, enabled, action, argument, strict "
"FROM spawn_events WHERE zone = '%s'", zone_name);
results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
const auto& events = SpawnEventsRepository::GetWhere(
database,
fmt::format(
"`zone` = '{}'",
Strings::Escape(zone_short_name)
)
);
LogInfo("Loaded [{}] spawn_events", Strings::Commify(std::to_string(results.RowCount())));
LogInfo("Loaded [{}] spawn_events", Strings::Commify(std::to_string(events.size())));
for (auto row = results.begin(); row != results.end(); ++row) {
for (const auto& e : events) {
SpawnEvent event;
event.id = Strings::ToInt(row[0]);
event.condition_id = Strings::ToInt(row[1]);
event.period = Strings::ToInt(row[2]);
event.id = e.id;
event.condition_id = e.cond_id;
event.period = e.period;
if (event.period == 0) {
if (!event.period) {
LogError("Refusing to load spawn event #[{}] because it has a period of 0\n", event.id);
continue;
}
event.next.minute = Strings::ToInt(row[3]);
event.next.hour = Strings::ToInt(row[4]);
event.next.day = Strings::ToInt(row[5]);
event.next.month = Strings::ToInt(row[6]);
event.next.year = Strings::ToInt(row[7]);
event.enabled = Strings::ToInt(row[8]) == 0 ? false : true;
event.action = (SpawnEvent::Action) Strings::ToInt(row[9]);
event.argument = Strings::ToInt(row[10]);
event.strict = Strings::ToInt(row[11]) == 0 ? false : true;
event.next.minute = e.next_minute;
event.next.hour = e.next_hour;
event.next.day = e.next_day;
event.next.month = e.next_month;
event.next.year = e.next_year;
event.enabled = e.enabled;
event.action = static_cast<SpawnEvent::Action>(e.action);
event.argument = e.argument;
event.strict = e.strict;
spawn_events.push_back(event);
@@ -945,68 +971,70 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
//now we need to catch up on events that happened while we were away
//and use them to alter just the condition variables.
//each spawn2 will then use its correct condition value when
//it decides what to do. This essentially forces a 'depop' action
//on spawn points which are turned off, and a 'repop' action on
//spawn points which get turned on. Im too lazy to figure out a
//better solution, and I just dont care thats much.
//get our current time
TimeOfDay_Struct tod{};
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
for(auto cur = spawn_events.begin(); cur != spawn_events.end(); ++cur) {
SpawnEvent &cevent = *cur;
for (auto& e : spawn_events) {
bool is_strict = false;
bool StrictCheck = false;
if(cevent.strict &&
cevent.next.hour == tod.hour &&
cevent.next.day == tod.day &&
cevent.next.month == tod.month &&
cevent.next.year == tod.year)
StrictCheck = true;
if (
e.strict &&
e.next.hour == tod.hour &&
e.next.day == tod.day &&
e.next.month == tod.month &&
e.next.year == tod.year
) {
is_strict = true;
}
//If event is disabled, or we failed the strict check, set initial spawn_condition to default startup value from spawn_conditions.
if(!cevent.enabled || !StrictCheck) {
if (!e.enabled || !is_strict) {
SetCondition(
zone->GetShortName(),
zone->GetInstanceID(),
cevent.condition_id,
spawn_conditions[cevent.condition_id].value
zone->GetShortName(),
zone->GetInstanceID(),
e.condition_id,
spawn_conditions[e.condition_id].value
);
}
if(!cevent.enabled)
continue;
if (!e.enabled) {
continue;
}
//watch for special case of all 0s, which means to reset next to now
if (cevent.next.year == 0 && cevent.next.month == 0 && cevent.next.day == 0 && cevent.next.hour == 0 &&
cevent.next.minute == 0) {
LogSpawns("Initial next trigger time set for spawn event [{}]", cevent.id);
memcpy(&cevent.next, &tod, sizeof(cevent.next));
//add one period
EQTime::AddMinutes(cevent.period, &cevent.next);
//save it in the db.
UpdateDBEvent(cevent);
continue; //were done with this event.
if (
e.next.year == 0 &&
e.next.month == 0 &&
e.next.day == 0 &&
e.next.hour == 0 &&
e.next.minute == 0
) {
LogSpawns("Initial next trigger time set for spawn event [{}]", e.id);
memcpy(&e.next, &tod, sizeof(e.next));
EQTime::AddMinutes(e.period, &e.next);
UpdateSpawnEvent(e);
continue;
}
bool ran = false;
while (EQTime::IsTimeBefore(&tod, &cevent.next)) {
LogSpawns("Catch up triggering on event [{}]", cevent.id);
while (EQTime::IsTimeBefore(&tod, &e.next)) {
LogSpawns("Catch up triggering on event [{}]", e.id);
//this event has been triggered.
//execute the event
if (!cevent.strict || StrictCheck) {
ExecEvent(cevent, false);
if (!e.strict || is_strict) {
ExecEvent(e, false);
}
//add the period of the event to the trigger time
EQTime::AddMinutes(cevent.period, &cevent.next);
EQTime::AddMinutes(e.period, &e.next);
ran = true;
}
//only write it out if the event actually ran
if(ran)
UpdateDBEvent(cevent); //save the event in the DB
if (ran) {
UpdateSpawnEvent(e);
}
}
//now our event timers are all up to date, find our closest event.
@@ -1095,7 +1123,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
//set our local value
cond.value = new_value;
//save it in the DB too
UpdateDBCondition(zone_short, instance_id, condition_id, new_value);
UpdateSpawnCondition(zone_short, instance_id, condition_id, new_value);
LogSpawns("Local Condition update requested for [{}] with value [{}]", condition_id, new_value);
@@ -1109,7 +1137,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
LogSpawns("Remote spawn condition [{}] set to [{}]. Updating DB and notifying world", condition_id, new_value);
UpdateDBCondition(zone_short, instance_id, condition_id, new_value);
UpdateSpawnCondition(zone_short, instance_id, condition_id, new_value);
auto pack = new ServerPacket(ServerOP_SpawnCondition, sizeof(ServerSpawnCondition_Struct));
ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer;
@@ -1138,7 +1166,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) {
if(cevent.id == event_id) {
//load the event into the old event slot
if(!LoadDBEvent(event_id, cevent, zone_short_name)) {
if(!LoadSpawnEvent(event_id, cevent, zone_short_name)) {
//unable to find the event in the database...
LogSpawns("Failed to reload event [{}] from the database", event_id);
return;
@@ -1151,7 +1179,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) {
//if we get here, it is a new event...
SpawnEvent e;
if(!LoadDBEvent(event_id, e, zone_short_name)) {
if(!LoadSpawnEvent(event_id, e, zone_short_name)) {
//unable to find the event in the database...
LogSpawns("Failed to reload event [{}] from the database", event_id);
return;
@@ -1195,7 +1223,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
}
//save the event in the DB
UpdateDBEvent(cevent);
UpdateSpawnEvent(cevent);
//sync up our nearest event
FindNearestEvent();
@@ -1218,7 +1246,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
//update its in-memory event list
SpawnEvent e;
std::string zone_short_name;
if(!LoadDBEvent(event_id, e, zone_short_name)) {
if(!LoadSpawnEvent(event_id, e, zone_short_name)) {
LogSpawns("Unable to find spawn event [{}] in the database", event_id);
//unable to find the event in the database...
return;
@@ -1239,7 +1267,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
LogSpawns("Spawn event [{}] is in zone [{}]. State changed. Notifying world", event_id, zone_short_name.c_str(), e.period);
}
//save the event in the DB
UpdateDBEvent(e);
UpdateSpawnEvent(e);
//now notify the zone
@@ -1253,43 +1281,39 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
safe_delete(pack);
}
int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id) {
if(!strcasecmp(zone_short, zone->GetShortName()) && instance_id == zone->GetInstanceID())
{
//this is a local spawn condition
std::map<uint16, SpawnCondition>::iterator condi;
condi = spawn_conditions.find(condition_id);
if(condi == spawn_conditions.end())
{
LogSpawns("Unable to find local condition [{}] in Get request", condition_id);
return(0); //unable to find the spawn condition
int16 SpawnConditionManager::GetCondition(const std::string& zone_short_name, uint32 instance_id, uint16 condition)
{
if (
Strings::EqualFold(zone_short_name, zone->GetShortName()) &&
instance_id == zone->GetInstanceID()
) {
auto i = spawn_conditions.find(condition);
if (i == spawn_conditions.end()) {
LogSpawns("Unable to find local condition [{}] in Get request", condition);
return (0); //unable to find the spawn condition
}
SpawnCondition &cond = condi->second;
return cond.value;
return i->second.value;
}
//this is a remote spawn condition, grab it from the DB
//load spawn conditions
std::string query = StringFormat(
"SELECT value FROM spawn_condition_values "
"WHERE zone = '%s' AND instance_id = %u AND id = %d",
zone_short, instance_id, condition_id
const auto& l = SpawnConditionValuesRepository::GetWhere(
database,
fmt::format(
"`zone` = '{}' AND `instance_id` = {} AND `id` = {}",
Strings::Escape(zone_short_name),
instance_id,
condition
)
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition_id, zone_short);
return 0; //dunno a better thing to do...
if (l.empty()) {
LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition, zone_short_name);
return 0;
}
if (results.RowCount() == 0) {
LogSpawns("Unable to load remote condition [{}] from zone [{}] in Get request", condition_id, zone_short);
return 0; //dunno a better thing to do...
}
const auto& e = l.front();
auto row = results.begin();
return Strings::ToInt(row[0]);
return e.value;
}
bool SpawnConditionManager::Check(uint16 condition, int16 min_value) {
+5 -5
View File
@@ -147,9 +147,9 @@ public:
SpawnConditionManager();
void Process();
bool LoadSpawnConditions(const char* zone_name, uint32 instance_id);
bool LoadSpawnConditions(const std::string& zone_short_name, uint32 instance_id);
int16 GetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id);
int16 GetCondition(const std::string& zone_short_name, uint32 instance_id, uint16 condition);
void SetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id, int16 new_value, bool world_update = false);
void ToggleEvent(uint32 event_id, bool enabled, bool strict, bool reset_base);
bool Check(uint16 condition, int16 min_value);
@@ -160,9 +160,9 @@ protected:
std::vector<SpawnEvent> spawn_events;
void ExecEvent(SpawnEvent &e, bool send_update);
void UpdateDBEvent(SpawnEvent &e);
bool LoadDBEvent(uint32 event_id, SpawnEvent &e, std::string &zone_name);
void UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value);
void UpdateSpawnEvent(SpawnEvent &e);
bool LoadSpawnEvent(uint32 event_id, SpawnEvent& event, std::string& zone_short_name);
void UpdateSpawnCondition(const std::string& zone_short_name, uint32 instance_id, uint16 condition, int16 condition_value);
void FindNearestEvent();
Timer minute_timer;
+4 -2
View File
@@ -1819,14 +1819,16 @@ void NPC::DoClassAttacks(Mob *target) {
target->GetBodyType() != BT_Undead &&
taunt_time &&
type_of_pet &&
type_of_pet != petTargetLock
type_of_pet != petTargetLock &&
DistanceSquared(GetPosition(), target->GetPosition()) <= (RuleI(Pets, PetTauntRange) * RuleI(Pets, PetTauntRange))
) {
GetOwner()->MessageString(Chat::PetResponse, PET_TAUNTING);
Taunt(target->CastToNPC(), false);
}
if(!ca_time)
if(!ca_time) {
return;
}
float HasteModifier = GetHaste() * 0.01f;
+2 -1
View File
@@ -125,7 +125,8 @@
#define FAIL_DISARM_DETECTED_TRAP 370 //You fail to disarm the detected trap.
#define LOOT_LORE_ERROR 371 //You cannot loot this Lore Item. You already have one.
#define PICK_LORE 379 //You cannot pick up a lore item you already possess.
#define POISON_TOO_HIGH 382 // This poison is too high level for you to apply.
#define POISON_TOO_HIGH 382 //This poison is too high level for you to apply.
#define TAUNT_TOO_FAR 386 //You are too far away from your target to taunt.
#define CORPSE_TOO_FAR 389 //The corpse is too far away to summon.
#define CONSENT_DENIED 390 //You do not have consent to summon that corpse.
#define DISCIPLINE_RDY 393 //You are ready to use a new discipline now.
+94 -89
View File
@@ -24,6 +24,7 @@
#include "mob.h"
#include "trap.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/repositories/traps_repository.h"
/*
@@ -439,59 +440,63 @@ void EntityList::ClearTrapPointers()
}
bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
std::string query = StringFormat(
"SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, "
"maxzdiff, radius, chance, message, respawn_time, respawn_var, level, "
"`group`, triggered_number, despawn_when_triggered, undetectable FROM traps WHERE zone='%s' AND version=%u %s",
zonename,
version,
ContentFilterCriteria::apply().c_str()
bool ZoneDatabase::LoadTraps(const std::string& zone_short_name, int16 instance_version)
{
const auto& l = TrapsRepository::GetWhere(
*this,
fmt::format(
"`zone` = '{}' AND `version` = {} {}",
Strings::Escape(zone_short_name),
instance_version,
ContentFilterCriteria::apply()
)
);
auto results = QueryDatabase(query);
if (!results.Success()) {
if (l.empty()) {
return false;
}
for (auto row = results.begin(); row != results.end(); ++row) {
uint32 tid = Strings::ToInt(row[0]);
uint8 grp = Strings::ToInt(row[15]);
if (grp > 0)
{
// If a member of our group is already spawned skip loading this trap.
if (entity_list.IsTrapGroupSpawned(tid, grp))
{
for (const auto& e : l) {
if (e.group_) {
if (entity_list.IsTrapGroupSpawned(e.id, e.group_)) {
// If a member of our group is already spawned skip loading this trap.
continue;
}
}
auto trap = new Trap();
trap->trap_id = tid;
trap->db_id = tid;
trap->m_Position = glm::vec3(Strings::ToFloat(row[1]), Strings::ToFloat(row[2]), Strings::ToFloat(row[3]));
trap->effect = Strings::ToInt(row[4]);
trap->effectvalue = Strings::ToInt(row[5]);
trap->effectvalue2 = Strings::ToInt(row[6]);
trap->skill = Strings::ToInt(row[7]);
trap->maxzdiff = Strings::ToFloat(row[8]);
trap->radius = Strings::ToFloat(row[9]);
trap->chance = Strings::ToInt(row[10]);
trap->message = row[11];
trap->respawn_time = Strings::ToInt(row[12]);
trap->respawn_var = Strings::ToInt(row[13]);
trap->level = Strings::ToInt(row[14]);
trap->group = grp;
trap->triggered_number = Strings::ToInt(row[16]);
trap->despawn_when_triggered = atobool(row[17]);
trap->undetectable = atobool(row[18]);
entity_list.AddTrap(trap);
trap->CreateHiddenTrigger();
Log(Logs::General, Logs::Traps, "Trap %d successfully loaded.", trap->trap_id);
auto t = new Trap();
t->trap_id = e.id;
t->db_id = e.id;
t->m_Position = glm::vec3(e.x, e.y, e.z);
t->effect = e.effect;
t->effectvalue = e.effectvalue;
t->effectvalue2 = e.effectvalue2;
t->skill = e.skill;
t->maxzdiff = e.maxzdiff;
t->radius = e.radius;
t->chance = e.chance;
t->message = e.message;
t->respawn_time = e.respawn_time;
t->respawn_var = e.respawn_var;
t->level = e.level;
t->group = e.group_;
t->triggered_number = e.triggered_number;
t->despawn_when_triggered = e.despawn_when_triggered;
t->undetectable = e.undetectable;
entity_list.AddTrap(t);
t->CreateHiddenTrigger();
}
LogInfo("Loaded [{}] trap(s)", Strings::Commify(results.RowCount()));
LogInfo(
"Loaded [{}] Trap{}",
Strings::Commify(l.size()),
l.size() != 1 ? "s" : ""
);
return true;
}
@@ -525,61 +530,61 @@ void Trap::CreateHiddenTrigger()
SetHiddenTrigger(npca);
}
bool ZoneDatabase::SetTrapData(Trap* trap, bool repopnow) {
bool ZoneDatabase::SetTrapData(Trap* t, bool repop)
{
const auto& l = TrapsRepository::GetWhere(
*this,
fmt::format(
"`zone` = '{}' AND `id` = {}{}",
zone->GetShortName(),
t->db_id,
(
t->group ?
fmt::format(
" AND `group` = {} ORDER BY RAND() LIMIT 1",
t->group
) :
""
)
)
);
uint32 dbid = trap->db_id;
std::string query;
if (trap->group > 0)
{
query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, "
"maxzdiff, radius, chance, message, respawn_time, respawn_var, level, "
"triggered_number, despawn_when_triggered, undetectable FROM traps WHERE zone='%s' AND `group`=%d AND id != %d ORDER BY RAND() LIMIT 1", zone->GetShortName(), trap->group, dbid);
}
else
{
// We could just use the existing data here, but querying the DB is not expensive, and allows content developers to change traps without rebooting.
query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, "
"maxzdiff, radius, chance, message, respawn_time, respawn_var, level, "
"triggered_number, despawn_when_triggered, undetectable FROM traps WHERE zone='%s' AND id = %d", zone->GetShortName(), dbid);
}
auto results = QueryDatabase(query);
if (!results.Success()) {
if (l.empty()) {
return false;
}
for (auto row = results.begin(); row != results.end(); ++row) {
const uint32 before_id = t->db_id;
trap->db_id = Strings::ToInt(row[0]);
trap->m_Position = glm::vec3(Strings::ToFloat(row[1]), Strings::ToFloat(row[2]), Strings::ToFloat(row[3]));
trap->effect = Strings::ToInt(row[4]);
trap->effectvalue = Strings::ToInt(row[5]);
trap->effectvalue2 = Strings::ToInt(row[6]);
trap->skill = Strings::ToInt(row[7]);
trap->maxzdiff = Strings::ToFloat(row[8]);
trap->radius = Strings::ToFloat(row[9]);
trap->chance = Strings::ToInt(row[10]);
trap->message = row[11];
trap->respawn_time = Strings::ToInt(row[12]);
trap->respawn_var = Strings::ToInt(row[13]);
trap->level = Strings::ToInt(row[14]);
trap->triggered_number = Strings::ToInt(row[15]);
trap->despawn_when_triggered = atobool(row[16]);
trap->undetectable = atobool(row[17]);
trap->CreateHiddenTrigger();
for (const auto& e : l) {
t->db_id = e.id;
t->m_Position = glm::vec3(e.x, e.y, e.z);
t->effect = e.effect;
t->effectvalue = e.effectvalue;
t->effectvalue2 = e.effectvalue2;
t->skill = e.skill;
t->maxzdiff = e.maxzdiff;
t->radius = e.radius;
t->chance = e.chance;
t->message = e.message;
t->respawn_var = e.respawn_var;
t->level = e.level;
t->triggered_number = e.triggered_number;
t->despawn_when_triggered = e.despawn_when_triggered;
t->undetectable = e.undetectable;
t->respawn_time = e.respawn_time;
if (repopnow)
{
trap->chkarea_timer.Enable();
}
else
{
trap->respawn_timer.Start((trap->respawn_time + zone->random.Int(0, trap->respawn_var)) * 1000);
t->CreateHiddenTrigger();
if (repop) {
t->chkarea_timer.Enable();
} else {
t->respawn_timer.Start((t->respawn_time + zone->random.Int(0, t->respawn_var)) * 1000);
}
if (trap->trap_id != trap->db_id)
Log(Logs::General, Logs::Traps, "Trap (%d) DBID has changed from %d to %d", trap->trap_id, dbid, trap->db_id);
if (t->trap_id != t->db_id) {
LogTraps("Trap ({}) DBID has changed from {} to {}.", t->trap_id, before_id, t->db_id);
}
return true;
}
+172 -203
View File
@@ -32,6 +32,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "fastmath.h"
#include "mob_movement_manager.h"
#include "../common/repositories/grid_repository.h"
#include "../common/repositories/grid_entries_repository.h"
#include "../common/repositories/spawn2_repository.h"
#include <math.h>
extern FastMath g_Math;
@@ -1052,233 +1056,198 @@ glm::vec4 Mob::TryMoveAlong(const glm::vec4 &start, float distance, float angle)
return {new_pos.x, new_pos.y, new_pos.z, start.w};
}
int ZoneDatabase::GetHighestGrid(uint32 zoneid) {
std::string query = StringFormat("SELECT COALESCE(MAX(id), 0) FROM grid WHERE zoneid = %i", zoneid);
auto results = QueryDatabase(query);
if (!results.Success()) {
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
return Strings::ToInt(row[0]);
int ZoneDatabase::GetHighestGrid(uint32 zone_id)
{
return GridRepository::GetHighestGrid(*this, zone_id);
}
/******************
* ModifyGrid - Either adds an empty grid, or removes a grid and all its waypoints, for a particular zone.
* remove: TRUE if we are deleting the specified grid, FALSE if we are adding it
* id: The ID# of the grid to add or delete
* type,type2: The type and type2 values for the grid being created (ignored if grid is being deleted)
* zoneid: The ID number of the zone the grid is being created/deleted in
*/
void ZoneDatabase::ModifyGrid(Client *client, bool remove, uint32 id, uint8 type, uint8 type2, uint16 zoneid) {
void ZoneDatabase::ModifyGrid(
Client* c,
bool remove,
uint32 grid_id,
uint8 type,
uint8 type2,
uint32 zone_id
)
{
if (!remove) {
GridRepository::InsertOne(
*this,
GridRepository::Grid{
.id = static_cast<int32_t>(grid_id),
.zoneid = static_cast<int32_t>(zone_id),
.type = type,
.type2 = type2
}
);
if (!remove)
{
std::string query = StringFormat("INSERT INTO grid(id, zoneid, type, type2) "
"VALUES (%i, %i, %i, %i)", id, zoneid, type, type2);
auto results = QueryDatabase(query);
if (!results.Success()) {
return;
return;
}
GridRepository::DeleteWhere(
*this,
fmt::format(
"`id` = {} AND `zoneid` = {}",
grid_id,
zone_id
)
);
GridEntriesRepository::DeleteWhere(
*this,
fmt::format(
"`gridid` = {} AND `zoneid` = {}",
grid_id,
zone_id
)
);
}
bool ZoneDatabase::GridExistsInZone(uint32 zone_id, uint32 grid_id)
{
const auto& l = GridRepository::GetWhere(
*this,
fmt::format(
"`id` = {} AND `zoneid` = {}",
grid_id,
zone_id
)
);
if (l.empty()) {
return false;
}
return true;
}
void ZoneDatabase::AddWaypoint(
Client* c,
uint32 grid_id,
uint32 number,
const glm::vec4& position,
uint32 pause,
uint32 zone_id
)
{
GridEntriesRepository::InsertOne(
*this,
GridEntriesRepository::GridEntries{
.gridid = static_cast<int32_t>(grid_id),
.zoneid = static_cast<int32_t>(zone_id),
.number = static_cast<int32_t>(number),
.x = position.x,
.y = position.y,
.z = position.z,
.heading = position.w,
.pause = static_cast<int32_t>(pause)
}
);
}
void ZoneDatabase::DeleteWaypoint(Client* c, uint32 grid_id, uint32 number, uint32 zone_id)
{
GridEntriesRepository::DeleteWhere(
*this,
fmt::format(
"`gridid` = {} AND `zoneid` = {} AND `number` = {}",
grid_id,
zone_id,
number
)
);
}
uint32 ZoneDatabase::AddWaypointForSpawn(
Client* c,
uint32 spawn2_id,
const glm::vec4& position,
uint32 pause,
int type,
int type2,
uint32 zone_id
)
{
uint32 grid_id = Spawn2Repository::GetPathGridBySpawn2ID(*this, spawn2_id); // The grid number the spawn is assigned to (if spawn has no grid, will be the grid number we end up creating)
bool created; // Did we create a new grid in this function?
if (!grid_id) { // Our spawn doesn't have a grid assigned to it -- we need to create a new grid and assign it to the spawn
created = true;
grid_id = GetFreeGrid(zone_id);
if (grid_id == 0) { // There are no grids for the current zone -- create Grid #1
grid_id = 1;
}
return;
GridRepository::InsertOne(
*this,
GridRepository::Grid{
.id = static_cast<int32_t>(grid_id),
.zoneid = static_cast<int32_t>(zone_id),
.type = type,
.type2 = type2
}
);
Spawn2Repository::SetPathGridBySpawn2ID(*this, spawn2_id, grid_id);
} else { // NPC had a grid assigned to it
created = false;
}
std::string query = StringFormat("DELETE FROM grid where id=%i and zoneid=%i", id, zoneid);
auto results = QueryDatabase(query);
int next_waypoint = GridEntriesRepository::GetNextWaypoint(*this, zone_id, grid_id); // The waypoint number we should be assigning to the new waypoint
query = StringFormat("DELETE FROM grid_entries WHERE zoneid = %i AND gridid = %i", zoneid, id);
results = QueryDatabase(query);
}
bool ZoneDatabase::GridExistsInZone(uint32 zone_id, uint32 grid_id) {
bool grid_exists = false;
std::string query = fmt::format(
"SELECT * FROM `grid` WHERE `id` = {} AND `zoneid` = {}",
grid_id,
zone_id
GridEntriesRepository::InsertOne(
*this,
GridEntriesRepository::GridEntries{
.gridid = static_cast<int32_t>(grid_id),
.zoneid = static_cast<int32_t>(zone_id),
.number = next_waypoint,
.x = position.x,
.y = position.y,
.z = position.z,
.heading = position.w,
.pause = static_cast<int32_t>(pause)
}
);
auto results = QueryDatabase(query);
if (!results.Success()) {
return grid_exists;
}
if (results.RowCount() == 1) {
grid_exists = true;
}
return grid_exists;
return created ? grid_id : 0;
}
/**************************************
* AddWP - Adds a new waypoint to a specific grid for a specific zone.
*/
void ZoneDatabase::AddWP(Client *client, uint32 gridid, uint32 wpnum, const glm::vec4& position, uint32 pause, uint16 zoneid)
uint32 ZoneDatabase::GetFreeGrid(uint32 zone_id)
{
std::string query = StringFormat("INSERT INTO grid_entries (gridid, zoneid, `number`, x, y, z, pause, heading) "
"VALUES (%i, %i, %i, %f, %f, %f, %i, %f)",
gridid, zoneid, wpnum, position.x, position.y, position.z, pause, position.w);
auto results = QueryDatabase(query);
if (!results.Success()) {
return;
}
return GridRepository::GetHighestGrid(*this, zone_id) + 1;
}
/**********
* ModifyWP() has been obsoleted. The #wp command either uses AddWP() or DeleteWaypoint()
***********/
/******************
* DeleteWaypoint - Removes a specific waypoint from the grid
* grid_id: The ID number of the grid whose wp is being deleted
* wp_num: The number of the waypoint being deleted
* zoneid: The ID number of the zone that Contains the waypoint being deleted
*/
void ZoneDatabase::DeleteWaypoint(Client *client, uint32 grid_num, uint32 wp_num, uint16 zoneid)
int ZoneDatabase::GetHighestWaypoint(uint32 zone_id, uint32 grid_id)
{
std::string query = StringFormat("DELETE FROM grid_entries WHERE "
"gridid = %i AND zoneid = %i AND `number` = %i",
grid_num, zoneid, wp_num);
auto results = QueryDatabase(query);
if (!results.Success()) {
return;
}
return GridEntriesRepository::GetHighestWaypoint(*this, zone_id, grid_id);
}
/******************
* AddWPForSpawn - Used by the #wpadd command - for a given spawn, this will add a new waypoint to whatever grid that spawn is assigned to.
* If there is currently no grid assigned to the spawn, a new grid will be created using the next available Grid ID number for the zone
* the spawn is in.
* Returns 0 if the function didn't have to create a new grid. If the function had to create a new grid for the spawn, then the ID of
* the created grid is returned.
*/
uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::vec4& position, uint32 pause, int type1, int type2, uint16 zoneid) {
uint32 grid_num; // The grid number the spawn is assigned to (if spawn has no grid, will be the grid number we end up creating)
uint32 next_wp_num; // The waypoint number we should be assigning to the new waypoint
bool createdNewGrid; // Did we create a new grid in this function?
// See what grid number our spawn is assigned
std::string query = StringFormat("SELECT pathgrid FROM spawn2 WHERE id = %i", spawn2id);
auto results = QueryDatabase(query);
if (!results.Success()) {
// Query error
return 0;
}
if (results.RowCount() == 0)
return 0;
auto row = results.begin();
grid_num = Strings::ToInt(row[0]);
if (grid_num == 0)
{ // Our spawn doesn't have a grid assigned to it -- we need to create a new grid and assign it to the spawn
createdNewGrid = true;
grid_num = GetFreeGrid(zoneid);
if (grid_num == 0) // There are no grids for the current zone -- create Grid #1
grid_num = 1;
query = StringFormat("INSERT INTO grid SET id = '%i', zoneid = %i, type ='%i', type2 = '%i'",
grid_num, zoneid, type1, type2);
QueryDatabase(query);
query = StringFormat("UPDATE spawn2 SET pathgrid = '%i' WHERE id = '%i'", grid_num, spawn2id);
QueryDatabase(query);
}
else // NPC had a grid assigned to it
createdNewGrid = false;
// Find out what the next waypoint is for this grid
query = StringFormat("SELECT max(`number`) FROM grid_entries WHERE zoneid = '%i' AND gridid = '%i'", zoneid, grid_num);
results = QueryDatabase(query);
if (!results.Success()) { // Query error
return 0;
}
row = results.begin();
if (row[0] != 0)
next_wp_num = Strings::ToInt(row[0]) + 1;
else // No waypoints in this grid yet
next_wp_num = 1;
query = StringFormat("INSERT INTO grid_entries(gridid, zoneid, `number`, x, y, z, pause, heading) "
"VALUES (%i, %i, %i, %f, %f, %f, %i, %f)",
grid_num, zoneid, next_wp_num, position.x, position.y, position.z, pause, position.w);
results = QueryDatabase(query);
return createdNewGrid ? grid_num : 0;
}
uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) {
std::string query = StringFormat("SELECT max(id) FROM grid WHERE zoneid = %i", zoneid);
auto results = QueryDatabase(query);
if (!results.Success()) {
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
uint32 freeGridID = row[0] ? Strings::ToInt(row[0]) + 1 : 1;
return freeGridID;
}
int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) {
std::string query = StringFormat("SELECT COALESCE(MAX(number), 0) FROM grid_entries "
"WHERE zoneid = %i AND gridid = %i", zoneid, gridid);
auto results = QueryDatabase(query);
if (!results.Success()) {
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
return Strings::ToInt(row[0]);
}
int ZoneDatabase::GetRandomWaypointLocFromGrid(glm::vec4 &loc, uint16 zoneid, int grid)
int ZoneDatabase::GetRandomWaypointFromGrid(glm::vec4 &loc, uint32 zone_id, uint32 grid_id)
{
loc.x = loc.y = loc.z = loc.w = 0.0f;
std::string query = StringFormat("SELECT `x`,`y`,`z`,`heading` "
"FROM grid_entries WHERE `gridid` = %i AND `zoneid` = %u ORDER BY `number`", grid, zone->GetZoneID());
auto results = content_db.QueryDatabase(query);
if (!results.Success()) {
Log(Logs::General, Logs::Error, "MySQL Error while trying get random waypoint loc from grid %i in zoneid %u; %s", grid, zoneid, results.ErrorMessage().c_str());
const auto& l = GridEntriesRepository::GetWhere(
*this,
fmt::format(
"`zoneid` = {} AND `gridid` = {} ORDER BY RAND() LIMIT 1",
zone_id,
grid_id
)
);
if (l.empty()) {
return 0;
}
if (results.RowCount() > 0)
{
int roll = zone->random.Int(0, results.RowCount() - 1);
int i = 0;
auto row = results.begin();
while (i < roll)
{
row++;
i++;
}
loc.x = Strings::ToFloat(row[0]);
loc.y = Strings::ToFloat(row[1]);
loc.z = Strings::ToFloat(row[2]);
loc.w = Strings::ToFloat(row[3]);
return i;
}
return 0;
auto e = l.front();
loc.x = e.x;
loc.y = e.y;
loc.z = e.z;
loc.w = e.heading;
return e.number;
}
void NPC::SaveGuardSpotCharm()
+783 -638
View File
File diff suppressed because it is too large Load Diff
+75 -107
View File
@@ -66,6 +66,7 @@
#include "../common/repositories/npc_emotes_repository.h"
#include "../common/serverinfo.h"
#include "../common/repositories/merc_stance_entries_repository.h"
#include "../common/repositories/alternate_currency_repository.h"
#include <time.h>
@@ -660,68 +661,53 @@ void Zone::LoadNewMerchantData(uint32 merchantid) {
merchanttable[merchantid] = merchant_list;
}
void Zone::GetMerchantDataForZoneLoad() {
auto query = fmt::format(
SQL (
SELECT
merchantid,
slot,
item,
faction_required,
level_required,
min_status,
max_status,
alt_currency_cost,
classes_required,
probability,
bucket_name,
bucket_value,
bucket_comparison
from merchantlist where merchantid IN (
select merchant_id from npc_types where id in (
select npcID from spawnentry where spawngroupID IN (
select spawngroupID from spawn2 where `zone` = '{}' and (`version` = {} OR `version` = -1)
void Zone::LoadMerchants()
{
const auto& l = MerchantlistRepository::GetWhere(
content_db,
fmt::format(
SQL(
`merchantid` IN (
SELECT `merchant_id` FROM `npc_types` WHERE `id` IN (
SELECT `npcID` FROM `spawnentry` WHERE `spawngroupID` IN (
SELECT `spawngroupID` FROM `spawn2` WHERE `zone` = '{}' AND (`version` = {} OR `version` = -1)
)
)
)
)
{}
ORDER BY
merchantlist.slot
),
GetShortName(),
GetInstanceVersion(),
ContentFilterCriteria::apply()
{}
ORDER BY `merchantlist`.`slot`
),
GetShortName(),
GetInstanceVersion(),
ContentFilterCriteria::apply()
)
);
auto results = content_db.QueryDatabase(query);
LogInfo("Loaded [{}] merchant lists", Strings::Commify(l.size()));
LogInfo("Loaded [{}] merchant lists", Strings::Commify(results.RowCount()));
std::map<uint32, std::list<MerchantList> >::iterator merchant_list;
uint32 npc_id = 0;
if (!results.Success() || !results.RowCount()) {
if (l.empty()) {
LogDebug("No Merchant Data found for [{}]", GetShortName());
return;
}
for (auto row : results) {
MerchantList mle{};
mle.id = Strings::ToUnsignedInt(row[0]);
if (npc_id != mle.id) {
merchant_list = merchanttable.find(mle.id);
if (merchant_list == merchanttable.end()) {
std::map<uint32, std::list<MerchantList>>::iterator ml;
uint32 npc_id = 0;
for (const auto& e : l) {
if (npc_id != e.merchantid) {
ml = merchanttable.find(e.merchantid);
if (ml == merchanttable.end()) {
std::list<MerchantList> empty;
merchanttable[mle.id] = empty;
merchant_list = merchanttable.find(mle.id);
merchanttable[e.merchantid] = empty;
ml = merchanttable.find(e.merchantid);
}
npc_id = mle.id;
npc_id = e.merchantid;
}
bool found = false;
for (const auto &m : merchant_list->second) {
if (m.item == mle.id) {
for (const auto &m : ml->second) {
if (m.item == e.merchantid) {
found = true;
break;
}
@@ -731,20 +717,23 @@ void Zone::GetMerchantDataForZoneLoad() {
continue;
}
mle.slot = Strings::ToUnsignedInt(row[1]);
mle.item = Strings::ToUnsignedInt(row[2]);
mle.faction_required = static_cast<int16>(Strings::ToInt(row[3]));
mle.level_required = static_cast<uint8>(Strings::ToUnsignedInt(row[4]));
mle.min_status = static_cast<uint8>(Strings::ToUnsignedInt(row[5]));
mle.max_status = static_cast<uint8>(Strings::ToUnsignedInt(row[6]));
mle.alt_currency_cost = static_cast<uint16>(Strings::ToUnsignedInt(row[7]));
mle.classes_required = Strings::ToUnsignedInt(row[8]);
mle.probability = static_cast<uint8>(Strings::ToUnsignedInt(row[9]));
mle.bucket_name = row[10];
mle.bucket_value = row[11];
mle.bucket_comparison = static_cast<uint8>(Strings::ToUnsignedInt(row[12]));
merchant_list->second.push_back(mle);
ml->second.push_back(
MerchantList{
.id = static_cast<uint32>(e.merchantid),
.slot = e.slot,
.item = static_cast<uint32>(e.item),
.faction_required = e.faction_required,
.level_required = static_cast<int8>(e.level_required),
.min_status = e.min_status,
.max_status = e.max_status,
.alt_currency_cost = e.alt_currency_cost,
.classes_required = static_cast<uint32>(e.classes_required),
.probability = static_cast<uint8>(e.probability),
.bucket_name = e.bucket_name,
.bucket_value = e.bucket_value,
.bucket_comparison = e.bucket_comparison
}
);
}
}
@@ -974,6 +963,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
default_ruleset = 0;
is_zone_time_localized = false;
quest_idle_override = false;
loglevelvar = 0;
merchantvar = 0;
@@ -1133,49 +1123,25 @@ bool Zone::Init(bool is_static) {
watermap = WaterMap::LoadWaterMapfile(map_name);
pathing = IPathfinder::Load(map_name);
if(!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) {
LogError("Loading spawn conditions failed, continuing without them");
}
spawn_conditions.LoadSpawnConditions(short_name, instanceid);
if (!content_db.LoadStaticZonePoints(&zone_point_list, short_name, GetInstanceVersion())) {
LogError("Loading static zone points failed");
return false;
}
content_db.LoadStaticZonePoints(&zone_point_list, short_name, GetInstanceVersion());
if (!content_db.LoadSpawnGroups(short_name, GetInstanceVersion(), &spawn_group_list)) {
LogError("Loading spawn groups failed");
return false;
}
if (!content_db.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion()))
{
LogError("Loading spawn2 points failed");
return false;
}
content_db.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion());
database.LoadCharacterCorpses(zoneid, instanceid);
if (!database.LoadCharacterCorpses(zoneid, instanceid)) {
LogError("Loading player corpses failed");
return false;
}
if (!content_db.LoadTraps(short_name, GetInstanceVersion()))
{
LogError("Loading traps failed");
return false;
}
content_db.LoadTraps(short_name, GetInstanceVersion());
LogInfo("Loading adventure flavor text");
LoadAdventureFlavor();
if (!LoadGroundSpawns())
{
LogError("Loading ground spawns failed. continuing");
}
if (!LoadZoneObjects())
{
LogError("Loading World Objects failed. continuing");
}
LoadGroundSpawns();
LoadZoneObjects();
RespawnTimesRepository::ClearExpiredRespawnTimers(database);
@@ -1199,7 +1165,7 @@ bool Zone::Init(bool is_static) {
content_db.LoadGlobalLoot();
//Load merchant data
GetMerchantDataForZoneLoad();
LoadMerchants();
//Load temporary merchant data
LoadTempMerchantData();
@@ -1933,9 +1899,7 @@ void Zone::Repop()
LogError("Loading spawn groups failed");
}
if (!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) {
LogError("Loading spawn conditions failed, continuing without them");
}
spawn_conditions.LoadSpawnConditions(short_name, instanceid);
if (!content_db.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion())) {
LogDebug("Error in Zone::Repop: database.PopulateZoneSpawnList failed");
@@ -2456,21 +2420,25 @@ void Zone::LoadAlternateCurrencies()
{
AlternateCurrencies.clear();
AltCurrencyDefinition_Struct current_currency;
const auto& l = AlternateCurrencyRepository::All(content_db);
const std::string query = "SELECT id, item_id FROM alternate_currency";
auto results = content_db.QueryDatabase(query);
if (!results.Success()) {
if (l.empty()) {
return;
}
}
for (auto row : results) {
current_currency.id = Strings::ToUnsignedInt(row[0]);
current_currency.item_id = Strings::ToUnsignedInt(row[1]);
AlternateCurrencies.push_back(current_currency);
}
AltCurrencyDefinition_Struct c;
LogInfo("Loaded [{}] alternate currencies", Strings::Commify(results.RowCount()));
for (const auto &e : l) {
c.id = e.id;
c.item_id = e.item_id;
AlternateCurrencies.push_back(c);
}
LogInfo(
"Loaded [{}] Alternate Currenc{}",
Strings::Commify(l.size()),
l.size() != 1 ? "ies" : "y"
);
}
void Zone::UpdateQGlobal(uint32 qid, QGlobal newGlobal)
+2 -1
View File
@@ -105,6 +105,7 @@ public:
AA::Ability *GetAlternateAdvancementAbilityByRank(int rank_id);
AA::Rank *GetAlternateAdvancementRank(int rank_id);
bool is_zone_time_localized;
bool quest_idle_override;
bool IsIdleWhenEmpty() const;
void SetIdleWhenEmpty(bool idle_when_empty);
uint32 GetSecondsBeforeIdle() const;
@@ -277,7 +278,7 @@ public:
void DoAdventureActions();
void DoAdventureAssassinationCountIncrease();
void DoAdventureCountIncrease();
void GetMerchantDataForZoneLoad();
void LoadMerchants();
void GetTimeSync();
void LoadAdventureFlavor();
void LoadAlternateAdvancement();
+20 -24
View File
@@ -15,8 +15,6 @@
#include "bot_database.h"
#define WOLF 42
class Client;
class Corpse;
class Merc;
@@ -337,12 +335,12 @@ struct CharacterCorpseEntry
namespace BeastlordPetData {
struct PetStruct {
uint16 race_id = WOLF;
uint8 texture = 0;
uint8 helm_texture = 0;
uint8 gender = Gender::Neuter;
float size_modifier = 1.0f;
uint8 face = 0;
uint16 race_id = Race::Wolf;
uint8 texture = 0;
uint8 helm_texture = 0;
uint8 gender = Gender::Neuter;
float size_modifier = 1.0f;
uint8 face = 0;
};
}
@@ -530,23 +528,21 @@ public:
bool LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list);
bool LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList* spawn_group_list);
bool PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version);
bool CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value);
bool CreateSpawn2(Client* c, uint32 spawngroup_id, const std::string& zone_short_name, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 condition_value);
void UpdateRespawnTime(uint32 spawn2_id, uint16 instance_id,uint32 timeleft);
uint32 GetSpawnTimeLeft(uint32 spawn2_id, uint16 instance_id);
void UpdateSpawn2Status(uint32 id, uint8 new_status, uint32 instance_id);
/* Grids/Paths */
uint32 GetFreeGrid(uint16 zoneid);
void DeleteGrid(Client *c, uint32 sg2, uint32 grid_num, bool grid_too, uint16 zoneid);
void DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid);
void AddWP(Client *c, uint32 gridid, uint32 wpnum, const glm::vec4& position, uint32 pause, uint16 zoneid);
uint32 AddWPForSpawn(Client *c, uint32 spawn2id, const glm::vec4& position, uint32 pause, int type1, int type2, uint16 zoneid);
void ModifyGrid(Client *c, bool remove, uint32 id, uint8 type = 0, uint8 type2 = 0, uint16 zoneid = 0);
bool GridExistsInZone(uint32 zone_id, uint32 grid_id);
void ModifyWP(Client *c, uint32 grid_id, uint32 wp_num, const glm::vec3& location, uint32 script = 0, uint16 zoneid = 0);
int GetHighestGrid(uint32 zoneid);
int GetHighestWaypoint(uint32 zoneid, uint32 gridid);
int GetRandomWaypointLocFromGrid(glm::vec4 &loc, uint16 zoneid, int grid);
uint32 GetFreeGrid(uint32 zone_id);
void DeleteWaypoint(Client* c, uint32 grid_id, uint32 number, uint32 zone_id);
void AddWaypoint(Client* c, uint32 grid_id, uint32 number, const glm::vec4 &position, uint32 pause, uint32 zone_id);
uint32 AddWaypointForSpawn(Client* c, uint32 spawn2_id, const glm::vec4 &position, uint32 pause, int type, int type2, uint32 zone_id);
void ModifyGrid(Client* c, bool remove, uint32 grid_id, uint8 type = 0, uint8 type2 = 0, uint32 zone_id = 0);
bool GridExistsInZone(uint32 zone_id, uint32 grid_id);
int GetHighestGrid(uint32 zone_id);
int GetHighestWaypoint(uint32 zone_id, uint32 grid_id);
int GetRandomWaypointFromGrid(glm::vec4 &loc, uint32 zone_id, uint32 grid_id);
/* NPCs */
@@ -602,8 +598,8 @@ public:
/* Tradeskills */
bool GetTradeRecipe(const EQ::ItemInstance* container, uint8 c_type, uint32 some_id, Client* c, DBTradeskillRecipe_Struct* spec, bool* is_augmented);
bool GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id, Client* c, DBTradeskillRecipe_Struct* spec);
uint32 GetZoneForage(uint32 ZoneID, uint8 skill); /* for foraging */
uint32 GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, uint8 &npc_chance);
uint32 LoadForage(uint32 zone_id, uint8 skill_level);
uint32 LoadFishing(uint32 zone_id, uint8 skill_level, uint32 &npc_id, uint8 &npc_chance);
void UpdateRecipeMadecount(uint32 recipe_id, uint32 char_id, uint32 madecount);
bool EnableRecipe(uint32 recipe_id);
bool DisableRecipe(uint32 recipe_id);
@@ -623,8 +619,8 @@ public:
bool LoadBlockedSpells(int64 blocked_spells_count, ZoneSpellsBlocked* into, uint32 zone_id);
/* Traps */
bool LoadTraps(const char* zonename, int16 version);
bool SetTrapData(Trap* trap, bool repopnow = false);
bool LoadTraps(const std::string& zone_short_name, int16 instance_version);
bool SetTrapData(Trap* t, bool repop = false);
/* Time */
uint32 GetZoneTimezone(uint32 zoneid, uint32 version);