Skip to content

Commit

Permalink
[Commands] Cleanup #object Command (#3722)
Browse files Browse the repository at this point in the history
* [Commands] Cleanup #object Command

# Notes
- Cleanup messages and logic.
- Introduce enum for object types.
- Set ground work for object manipulation similar to door manipulation.

* Update object_manipulation.cpp

* Final push

* Update client_packet.cpp

* Update object_manipulation.cpp

* Update object_manipulation.cpp

* Update object.h

* Update client_packet.cpp

* Update client_packet.cpp

* Push.

* Update version.h

* Update database_update_manifest.cpp

* Update zone.cpp
  • Loading branch information
Kinglykrab authored Dec 3, 2023
1 parent 226cc3d commit b03f52d
Show file tree
Hide file tree
Showing 15 changed files with 1,562 additions and 1,395 deletions.
13 changes: 13 additions & 0 deletions common/database/database_update_manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5093,6 +5093,19 @@ RENAME TABLE `starting_items_new` TO `starting_items`;
.sql = R"(
ALTER TABLE `items` MODIFY COLUMN `updated` datetime NULL DEFAULT NULL;
)"
},
ManifestEntry{
.version = 9245,
.description = "2023_12_03_object_incline.sql",
.check = "SHOW COLUMNS FROM `object` LIKE 'incline'",
.condition = "empty",
.match = "",
.sql = R"(
ALTER TABLE `object`
CHANGE COLUMN `unknown08` `size_percentage` float NOT NULL DEFAULT 0 AFTER `icon`;
CHANGE COLUMN `unknown10` `solid_type` mediumint(5) NOT NULL DEFAULT 0 AFTER `size`,
CHANGE COLUMN `unknown20` `incline` int(11) NOT NULL DEFAULT 0 AFTER `solid_type`;
)"
}

// -- template; copy/paste this when you need to create a new entry
Expand Down
4 changes: 2 additions & 2 deletions common/eq_packet_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2594,11 +2594,11 @@ struct BookButton_Struct
struct Object_Struct {
/*00*/ uint32 linked_list_addr[2];// They are, get this, prev and next, ala linked list
/*08*/ float size; //
/*10*/ uint16 solidtype; //
/*10*/ uint16 solid_type; //
/*12*/ uint32 drop_id; // Unique object id for zone
/*16*/ uint16 zone_id; // Redudant, but: Zone the object appears in
/*18*/ uint16 zone_instance; //
/*20*/ uint32 unknown020; //
/*20*/ uint32 incline; //
/*24*/ uint32 unknown024; //
/*28*/ float tilt_x;
/*32*/ float tilt_y;
Expand Down
64 changes: 33 additions & 31 deletions common/repositories/base/base_object_repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "../../strings.h"
#include <ctime>


class BaseObjectRepository {
public:
struct Object {
Expand All @@ -31,9 +32,9 @@ class BaseObjectRepository {
std::string objectname;
int32_t type;
int32_t icon;
int32_t unknown08;
int32_t unknown10;
int32_t unknown20;
float size_percentage;
int32_t solid_type;
int32_t incline;
int32_t unknown24;
int32_t unknown60;
int32_t unknown64;
Expand Down Expand Up @@ -71,9 +72,9 @@ class BaseObjectRepository {
"objectname",
"type",
"icon",
"unknown08",
"unknown10",
"unknown20",
"size_percentage",
"solid_type",
"incline",
"unknown24",
"unknown60",
"unknown64",
Expand Down Expand Up @@ -107,9 +108,9 @@ class BaseObjectRepository {
"objectname",
"type",
"icon",
"unknown08",
"unknown10",
"unknown20",
"size_percentage",
"solid_type",
"incline",
"unknown24",
"unknown60",
"unknown64",
Expand Down Expand Up @@ -177,9 +178,9 @@ class BaseObjectRepository {
e.objectname = "";
e.type = 0;
e.icon = 0;
e.unknown08 = 0;
e.unknown10 = 0;
e.unknown20 = 0;
e.size_percentage = 0;
e.solid_type = 0;
e.incline = 0;
e.unknown24 = 0;
e.unknown60 = 0;
e.unknown64 = 0;
Expand Down Expand Up @@ -220,8 +221,9 @@ class BaseObjectRepository {
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
object_id
)
);
Expand All @@ -242,9 +244,9 @@ class BaseObjectRepository {
e.objectname = row[9] ? row[9] : "";
e.type = static_cast<int32_t>(atoi(row[10]));
e.icon = static_cast<int32_t>(atoi(row[11]));
e.unknown08 = static_cast<int32_t>(atoi(row[12]));
e.unknown10 = static_cast<int32_t>(atoi(row[13]));
e.unknown20 = static_cast<int32_t>(atoi(row[14]));
e.size_percentage = strtof(row[12], nullptr);
e.solid_type = static_cast<int32_t>(atoi(row[13]));
e.incline = static_cast<int32_t>(atoi(row[14]));
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
Expand Down Expand Up @@ -304,9 +306,9 @@ class BaseObjectRepository {
v.push_back(columns[9] + " = '" + Strings::Escape(e.objectname) + "'");
v.push_back(columns[10] + " = " + std::to_string(e.type));
v.push_back(columns[11] + " = " + std::to_string(e.icon));
v.push_back(columns[12] + " = " + std::to_string(e.unknown08));
v.push_back(columns[13] + " = " + std::to_string(e.unknown10));
v.push_back(columns[14] + " = " + std::to_string(e.unknown20));
v.push_back(columns[12] + " = " + std::to_string(e.size_percentage));
v.push_back(columns[13] + " = " + std::to_string(e.solid_type));
v.push_back(columns[14] + " = " + std::to_string(e.incline));
v.push_back(columns[15] + " = " + std::to_string(e.unknown24));
v.push_back(columns[16] + " = " + std::to_string(e.unknown60));
v.push_back(columns[17] + " = " + std::to_string(e.unknown64));
Expand Down Expand Up @@ -355,9 +357,9 @@ class BaseObjectRepository {
v.push_back("'" + Strings::Escape(e.objectname) + "'");
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.unknown08));
v.push_back(std::to_string(e.unknown10));
v.push_back(std::to_string(e.unknown20));
v.push_back(std::to_string(e.size_percentage));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.unknown24));
v.push_back(std::to_string(e.unknown60));
v.push_back(std::to_string(e.unknown64));
Expand Down Expand Up @@ -414,9 +416,9 @@ class BaseObjectRepository {
v.push_back("'" + Strings::Escape(e.objectname) + "'");
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.unknown08));
v.push_back(std::to_string(e.unknown10));
v.push_back(std::to_string(e.unknown20));
v.push_back(std::to_string(e.size_percentage));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.unknown24));
v.push_back(std::to_string(e.unknown60));
v.push_back(std::to_string(e.unknown64));
Expand Down Expand Up @@ -477,9 +479,9 @@ class BaseObjectRepository {
e.objectname = row[9] ? row[9] : "";
e.type = static_cast<int32_t>(atoi(row[10]));
e.icon = static_cast<int32_t>(atoi(row[11]));
e.unknown08 = static_cast<int32_t>(atoi(row[12]));
e.unknown10 = static_cast<int32_t>(atoi(row[13]));
e.unknown20 = static_cast<int32_t>(atoi(row[14]));
e.size_percentage = strtof(row[12], nullptr);
e.solid_type = static_cast<int32_t>(atoi(row[13]));
e.incline = static_cast<int32_t>(atoi(row[14]));
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
Expand Down Expand Up @@ -531,9 +533,9 @@ class BaseObjectRepository {
e.objectname = row[9] ? row[9] : "";
e.type = static_cast<int32_t>(atoi(row[10]));
e.icon = static_cast<int32_t>(atoi(row[11]));
e.unknown08 = static_cast<int32_t>(atoi(row[12]));
e.unknown10 = static_cast<int32_t>(atoi(row[13]));
e.unknown20 = static_cast<int32_t>(atoi(row[14]));
e.size_percentage = strtof(row[12], nullptr);
e.solid_type = static_cast<int32_t>(atoi(row[13]));
e.incline = static_cast<int32_t>(atoi(row[14]));
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
Expand Down
2 changes: 1 addition & 1 deletion common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/

#define CURRENT_BINARY_DATABASE_VERSION 9244
#define CURRENT_BINARY_DATABASE_VERSION 9245

#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9040

Expand Down
10 changes: 10 additions & 0 deletions zone/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10355,6 +10355,16 @@ void Client::SetDoorToolEntityId(uint16 door_tool_entity_id)
Client::m_door_tool_entity_id = door_tool_entity_id;
}

uint16 Client::GetObjectToolEntityId() const
{
return m_object_tool_entity_id;
}

void Client::SetObjectToolEntityId(uint16 object_tool_entity_id)
{
Client::m_object_tool_entity_id = object_tool_entity_id;
}

int Client::GetIPExemption()
{
return database.GetIPExemption(GetIPString());
Expand Down
3 changes: 3 additions & 0 deletions zone/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1814,9 +1814,12 @@ class Client : public Mob
bool dev_tools_enabled;

uint16 m_door_tool_entity_id;
uint16 m_object_tool_entity_id;
public:
uint16 GetDoorToolEntityId() const;
void SetDoorToolEntityId(uint16 door_tool_entity_id);
uint16 GetObjectToolEntityId() const;
void SetObjectToolEntityId(uint16 object_tool_entity_id);
private:

int32 max_end;
Expand Down
15 changes: 15 additions & 0 deletions zone/client_packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/shared_tasks.h"
#include "gm_commands/door_manipulation.h"
#include "gm_commands/object_manipulation.h"
#include "client.h"
#include "../common/repositories/account_repository.h"

Expand Down Expand Up @@ -4650,6 +4651,20 @@ void Client::Handle_OP_ClickObject(const EQApplicationPacket *app)
std::vector<std::any> args = { object };
parse->EventPlayer(EVENT_CLICK_OBJECT, this, std::to_string(click_object->drop_id), GetID(), &args);
}

if (IsDevToolsEnabled()) {
SetObjectToolEntityId(entity->GetID());
ObjectManipulation::CommandHeader(this);
Message(
Chat::White,
fmt::format(
"Object ({}) [{}] [{}]",
entity->CastToObject()->GetDBID(),
Saylink::Silent("#object edit", "Edit"),
Saylink::Silent("#object delete", "Delete")
).c_str()
);
}
}

// Observed in RoF after OP_ClickObjectAction:
Expand Down
1 change: 1 addition & 0 deletions zone/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ void command_bot(Client *c, const Seperator *sep)
#include "gm_commands/nukebuffs.cpp"
#include "gm_commands/nukeitem.cpp"
#include "gm_commands/object.cpp"
#include "gm_commands/object_manipulation.cpp"
#include "gm_commands/path.cpp"
#include "gm_commands/peqzone.cpp"
#include "gm_commands/petitems.cpp"
Expand Down
1 change: 0 additions & 1 deletion zone/gm_commands/door.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "../client.h"
#include "door_manipulation.h"
#include "../doors.h"

void command_door(Client *c, const Seperator *sep)
{
Expand Down
Loading

0 comments on commit b03f52d

Please sign in to comment.