clang format some stuff in zone/command.cpp

This commit is contained in:
Michael Cook (mackal) 2015-01-30 18:31:58 -05:00
parent 9a664476b0
commit b592d2e786

View File

@ -8475,7 +8475,8 @@ void command_object(Client *c, const Seperator *sep)
if (strcasecmp(sep->arg[1], "list") == 0) { if (strcasecmp(sep->arg[1], "list") == 0) {
// Insufficient or invalid args // Insufficient or invalid args
if ((sep->argnum < 2) || (sep->arg[2][0] < '0') || ((sep->arg[2][0] > '9') && ((sep->arg[2][0] & 0xDF) != 'A'))) { if ((sep->argnum < 2) || (sep->arg[2][0] < '0') ||
((sep->arg[2][0] > '9') && ((sep->arg[2][0] & 0xDF) != 'A'))) {
c->Message(0, "Usage: #object List All|(radius)"); c->Message(0, "Usage: #object List All|(radius)");
return; return;
} }
@ -8492,7 +8493,8 @@ void command_object(Client *c, const Seperator *sep)
std::string query; std::string query;
if (radius) if (radius)
query = StringFormat("SELECT id, xpos, ypos, zpos, heading, itemid, " query = StringFormat(
"SELECT id, xpos, ypos, zpos, heading, itemid, "
"objectname, type, icon, unknown08, unknown10, unknown20 " "objectname, type, icon, unknown08, unknown10, unknown20 "
"FROM object WHERE zoneid = %u AND version = %u " "FROM object WHERE zoneid = %u AND version = %u "
"AND (xpos BETWEEN %.1f AND %.1f) " "AND (xpos BETWEEN %.1f AND %.1f) "
@ -8502,10 +8504,7 @@ void command_object(Client *c, const Seperator *sep)
zone->GetZoneID(), zone->GetInstanceVersion(), zone->GetZoneID(), zone->GetInstanceVersion(),
c->GetX() - radius, // Yes, we're actually using a bounding box instead of a radius. c->GetX() - radius, // Yes, we're actually using a bounding box instead of a radius.
c->GetX() + radius, // Much less processing power used this way. c->GetX() + radius, // Much less processing power used this way.
c->GetY() - radius, c->GetY() - radius, c->GetY() + radius, c->GetZ() - radius, c->GetZ() + radius);
c->GetY() + radius,
c->GetZ() - radius,
c->GetZ() + radius);
else else
query = StringFormat("SELECT id, xpos, ypos, zpos, heading, itemid, " query = StringFormat("SELECT id, xpos, ypos, zpos, heading, itemid, "
"objectname, type, icon, unknown08, unknown10, unknown20 " "objectname, type, icon, unknown08, unknown10, unknown20 "
@ -8527,7 +8526,8 @@ void command_object(Client *c, const Seperator *sep)
od.heading = atof(row[4]); od.heading = atof(row[4]);
itemid = atoi(row[5]); itemid = atoi(row[5]);
strn0cpy(od.object_name, row[6], sizeof(od.object_name)); strn0cpy(od.object_name, row[6], sizeof(od.object_name));
od.object_name[sizeof(od.object_name) - 1] = '\0'; // Required if strlen(row[col++]) exactly == sizeof(object_name) od.object_name[sizeof(od.object_name) - 1] =
'\0'; // Required if strlen(row[col++]) exactly == sizeof(object_name)
od.object_type = atoi(row[7]); od.object_type = atoi(row[7]);
icon = atoi(row[8]); icon = atoi(row[8]);
@ -8535,22 +8535,28 @@ void command_object(Client *c, const Seperator *sep)
od.unknown010 = atoi(row[10]); od.unknown010 = atoi(row[10]);
od.unknown020 = atoi(row[11]); od.unknown020 = atoi(row[11]);
switch (od.object_type) switch (od.object_type) {
{
case 0: // Static Object case 0: // Static Object
case staticType: // Static Object unlocked for changes case staticType: // Static Object unlocked for changes
if (od.unknown008 == 0) // Unknown08 field is optional Size parameter for static objects if (od.unknown008 == 0) // Unknown08 field is optional Size parameter for static objects
od.unknown008 = 100; // Static object default Size is 100% od.unknown008 = 100; // Static object default Size is 100%
c->Message(0,"- STATIC Object (%s): id %u, x %.1f, y %.1f, z %.1f, h %.1f, model %s, size %u, solidtype %u, incline %u", (od.object_type == 0) ? "locked" : "unlocked", id, od.x, od.y, od.z, od.heading, od.object_name, od.unknown008, od.unknown010, od.unknown020); c->Message(0, "- STATIC Object (%s): id %u, x %.1f, y %.1f, z %.1f, h %.1f, model %s, "
"size %u, solidtype %u, incline %u",
(od.object_type == 0) ? "locked" : "unlocked", id, od.x, od.y, od.z,
od.heading, od.object_name, od.unknown008, od.unknown010, od.unknown020);
break; break;
case OT_DROPPEDITEM: // Ground Spawn case OT_DROPPEDITEM: // Ground Spawn
c->Message(0,"- TEMPORARY Object: id %u, x %.1f, y %.1f, z %.1f, h %.1f, itemid %u, model %s, icon %u", id, od.x, od.y, od.z, od.heading, itemid, od.object_name, icon); c->Message(0, "- TEMPORARY Object: id %u, x %.1f, y %.1f, z %.1f, h %.1f, itemid %u, "
"model %s, icon %u",
id, od.x, od.y, od.z, od.heading, itemid, od.object_name, icon);
break; break;
default: // All others == Tradeskill Objects default: // All others == Tradeskill Objects
c->Message(0, "- TRADESKILL Object: id %u, x %.1f, y %.1f, z %.1f, h %.1f, model %s, type %u, icon %u", id, od.x, od.y, od.z, od.heading, od.object_name, od.object_type, icon); c->Message(0, "- TRADESKILL Object: id %u, x %.1f, y %.1f, z %.1f, h %.1f, model %s, "
"type %u, icon %u",
id, od.x, od.y, od.z, od.heading, od.object_name, od.object_type, icon);
break; break;
} }
} }
@ -8561,10 +8567,13 @@ void command_object(Client *c, const Seperator *sep)
if (strcasecmp(sep->arg[1], "add") == 0) { if (strcasecmp(sep->arg[1], "add") == 0) {
// Insufficient or invalid arguments // Insufficient or invalid arguments
if ((sep->argnum < 3) || ((sep->arg[3][0] == '\0') && (sep->arg[4][0] < '0') && (sep->arg[4][0] > '9'))) { if ((sep->argnum < 3) ||
c->Message(0, "Usage: (Static Object): #object Add [ObjectID] 0 Model [SizePercent] [SolidType] [Incline]"); ((sep->arg[3][0] == '\0') && (sep->arg[4][0] < '0') && (sep->arg[4][0] > '9'))) {
c->Message(0, "Usage: (Static Object): #object Add [ObjectID] 0 Model [SizePercent] "
"[SolidType] [Incline]");
c->Message(0, "Usage: (Tradeskill Object): #object Add [ObjectID] TypeNum Model Icon"); c->Message(0, "Usage: (Tradeskill Object): #object Add [ObjectID] TypeNum Model Icon");
c->Message(0, "- Notes: Model must start with a letter, max length 16. SolidTypes = 0 (Solid), 1 (Sometimes Non-Solid)"); c->Message(0, "- Notes: Model must start with a letter, max length 16. SolidTypes = 0 (Solid), "
"1 (Sometimes Non-Solid)");
return; return;
} }
@ -8575,14 +8584,12 @@ void command_object(Client *c, const Seperator *sep)
// Nope, user must have specified ObjectID. Extract it. // Nope, user must have specified ObjectID. Extract it.
id = atoi(sep->arg[2]); id = atoi(sep->arg[2]);
col = 1; // Bump all other arguments one to the right. Model is in arg4. col = 1; // Bump all other arguments one to the right. Model is in arg4.
} } else {
else {
// Yep, arg3 is non-numeric, ObjectID must be omitted and model must be arg3 // Yep, arg3 is non-numeric, ObjectID must be omitted and model must be arg3
id = 0; id = 0;
col = 0; col = 0;
} }
} } else {
else {
// Nope, only 3 args. Object ID must be omitted and arg3 must be model. // Nope, only 3 args. Object ID must be omitted and arg3 must be model.
id = 0; id = 0;
col = 0; col = 0;
@ -8607,7 +8614,9 @@ void command_object(Client *c, const Seperator *sep)
break; break;
case 1: // Ground Spawn case 1: // Ground Spawn
c->Message(0, "ERROR: Object Type 1 is used for temporarily spawned ground spawns and dropped items, which are not supported with #object. See the 'ground_spawns' table in the database."); c->Message(0, "ERROR: Object Type 1 is used for temporarily spawned ground spawns and dropped "
"items, which are not supported with #object. See the 'ground_spawns' table in "
"the database.");
return; return;
default: // Everything else == Tradeskill Object default: // Everything else == Tradeskill Object
@ -8650,12 +8659,13 @@ void command_object(Client *c, const Seperator *sep)
int objectsFound = 0; int objectsFound = 0;
// Verify no other objects already in this spot (accidental double-click of Hotkey?) // Verify no other objects already in this spot (accidental double-click of Hotkey?)
query = StringFormat("SELECT COUNT(*) FROM object WHERE zoneid = %u " query = StringFormat(
"SELECT COUNT(*) FROM object WHERE zoneid = %u "
"AND version=%u AND (posx BETWEEN %.1f AND %.1f) " "AND version=%u AND (posx BETWEEN %.1f AND %.1f) "
"AND (posy BETWEEN %.1f AND %.1f) " "AND (posy BETWEEN %.1f AND %.1f) "
"AND (posz BETWEEN %.1f AND %.1f)", "AND (posz BETWEEN %.1f AND %.1f)",
zone->GetZoneID(), zone->GetInstanceVersion(), zone->GetZoneID(), zone->GetInstanceVersion(), od.x - 0.2f,
od.x - 0.2f, od.x + 0.2f, // Yes, we're actually using a bounding box instead of a radius. od.x + 0.2f, // Yes, we're actually using a bounding box instead of a radius.
od.y - 0.2f, od.y + 0.2f, // Much less processing power used this way. od.y - 0.2f, od.y + 0.2f, // Much less processing power used this way.
od.z - 0.2f, od.z + 0.2f); // It's pretty forgiving, though, allowing for close-proximity objects od.z - 0.2f, od.z + 0.2f); // It's pretty forgiving, though, allowing for close-proximity objects
@ -8697,7 +8707,8 @@ void command_object(Client *c, const Seperator *sep)
if (id == 0) { if (id == 0) {
// No ID specified. Get a best-guess next number from the database // No ID specified. Get a best-guess next number from the database
// If there's a problem retrieving an ID from the database, it'll end up being object # 1. No biggie. // If there's a problem retrieving an ID from the database, it'll end up being object # 1. No
// biggie.
query = "SELECT MAX(id) FROM object"; query = "SELECT MAX(id) FROM object";
results = database.QueryDatabase(query); results = database.QueryDatabase(query);
@ -8727,16 +8738,21 @@ void command_object(Client *c, const Seperator *sep)
// Bump player back to avoid getting stuck inside new object // Bump player back to avoid getting stuck inside new object
// GetHeading() returns half of the actual heading, for some reason, so we'll double it here for computation // GetHeading() returns half of the actual heading, for some reason, so we'll double it here for
// computation
x2 = 10.0f * sin(c->GetHeading() * 2.0f / 256.0f * 3.14159265f); x2 = 10.0f * sin(c->GetHeading() * 2.0f / 256.0f * 3.14159265f);
y2 = 10.0f * cos(c->GetHeading() * 2.0f / 256.0f * 3.14159265f); y2 = 10.0f * cos(c->GetHeading() * 2.0f / 256.0f * 3.14159265f);
c->MovePC(c->GetX() - x2, c->GetY() - y2, c->GetZ(), c->GetHeading() * 2); c->MovePC(c->GetX() - x2, c->GetY() - y2, c->GetZ(), c->GetHeading() * 2);
c->Message(0, "Spawning object with tentative id %u at location (%.1f, %.1f, %.1f heading %.1f). Use '#object Save' to save to database when satisfied with placement.", id, od.x, od.y, od.z, od.heading); c->Message(0, "Spawning object with tentative id %u at location (%.1f, %.1f, %.1f heading %.1f). Use "
"'#object Save' to save to database when satisfied with placement.",
id, od.x, od.y, od.z, od.heading);
// Temporary Static Object // Temporary Static Object
if (od.object_type == staticType) if (od.object_type == staticType)
c->Message(0, "- Note: Static Object will act like a tradeskill container and will not reflect size, solidtype, or incline values until you commit with '#object Save', after which it will be unchangeable until you use '#object Edit' and zone back in."); c->Message(0, "- Note: Static Object will act like a tradeskill container and will not reflect "
"size, solidtype, or incline values until you commit with '#object Save', after "
"which it will be unchangeable until you use '#object Edit' and zone back in.");
return; return;
} }
@ -8761,8 +8777,7 @@ void command_object(Client *c, const Seperator *sep)
c->Message(0, "Note: Object %u already unlocked and ready for changes", id); c->Message(0, "Note: Object %u already unlocked and ready for changes", id);
return; return;
} }
} } else {
else {
// Object not found in-zone in a modifiable form. Check for valid matching circumstances. // Object not found in-zone in a modifiable form. Check for valid matching circumstances.
std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id); std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
@ -8789,25 +8804,33 @@ void command_object(Client *c, const Seperator *sep)
return; return;
} }
switch (od.object_type) switch (od.object_type) {
{
case 0: // Static object needing unlocking case 0: // Static object needing unlocking
// Convert to tradeskill object temporarily for changes // Convert to tradeskill object temporarily for changes
query = StringFormat("UPDATE object SET type = %u WHERE id = %u", staticType, id); query = StringFormat("UPDATE object SET type = %u WHERE id = %u", staticType, id);
database.QueryDatabase(query); database.QueryDatabase(query);
c->Message(0, "Static Object %u unlocked for editing. You must zone out and back in to make your changes, then commit them with '#object Save'.", id); c->Message(0, "Static Object %u unlocked for editing. You must zone out and back in to "
"make your changes, then commit them with '#object Save'.",
id);
if (sep->argnum >= 4) if (sep->argnum >= 4)
c->Message(0, "NOTE: The change you specified has not been applied, since the static object had not been unlocked for editing yet."); c->Message(0, "NOTE: The change you specified has not been applied, since the "
"static object had not been unlocked for editing yet.");
return; return;
case OT_DROPPEDITEM: case OT_DROPPEDITEM:
c->Message(0, "ERROR: Object %u is a temporarily spawned ground spawn or dropped item, which cannot be manipulated with #object. See the 'ground_spawns' table in the database.", id); c->Message(0, "ERROR: Object %u is a temporarily spawned ground spawn or dropped item, "
"which cannot be manipulated with #object. See the 'ground_spawns' table "
"in the database.",
id);
return; return;
case staticType: case staticType:
c->Message(0, "ERROR: Object %u has been unlocked for editing, but you must zone out and back in for your client to refresh its object table before you can make changes to it.", id); c->Message(0, "ERROR: Object %u has been unlocked for editing, but you must zone out "
"and back in for your client to refresh its object table before you can "
"make changes to it.",
id);
return; return;
default: default:
@ -8838,8 +8861,7 @@ void command_object(Client *c, const Seperator *sep)
o->SetObjectData(&od); o->SetObjectData(&od);
c->Message(0, "Object %u now being rendered with model '%s'", id, od.object_name); c->Message(0, "Object %u now being rendered with model '%s'", id, od.object_name);
} } else if (strcmp(sep->arg[3], "type") == 0) {
else if (strcmp(sep->arg[3], "type") == 0) {
if ((sep->arg[4][0] < '0') || (sep->arg[4][0] > '9')) { if ((sep->arg[4][0] < '0') || (sep->arg[4][0] > '9')) {
c->Message(0, "ERROR: Invalid type number"); c->Message(0, "ERROR: Invalid type number");
return; return;
@ -8851,11 +8873,16 @@ void command_object(Client *c, const Seperator *sep)
case 0: case 0:
// Convert Static Object to temporary changeable type // Convert Static Object to temporary changeable type
od.object_type = staticType; od.object_type = staticType;
c->Message(0, "Note: Static Object will still act like tradeskill object and will not reflect size, solidtype, or incline settings until committed to the database with '#object Save', after which it will be unchangeable until it is unlocked again with '#object Edit'."); c->Message(0, "Note: Static Object will still act like tradeskill object and will not "
"reflect size, solidtype, or incline settings until committed to the "
"database with '#object Save', after which it will be unchangeable until "
"it is unlocked again with '#object Edit'.");
break; break;
case OT_DROPPEDITEM: case OT_DROPPEDITEM:
c->Message(0, "ERROR: Object Type 1 is used for temporarily spawned ground spawns and dropped items, which are not supported with #object. See the 'ground_spawns' table in the database."); c->Message(0, "ERROR: Object Type 1 is used for temporarily spawned ground spawns and "
"dropped items, which are not supported with #object. See the "
"'ground_spawns' table in the database.");
return; return;
default: default:
@ -8864,10 +8891,11 @@ void command_object(Client *c, const Seperator *sep)
} }
o->SetType(od.object_type); o->SetType(od.object_type);
} } else if (strcmp(sep->arg[3], "size") == 0) {
else if (strcmp(sep->arg[3], "size") == 0) {
if (od.object_type != staticType) { if (od.object_type != staticType) {
c->Message(0, "ERROR: Object %u is not a Static Object and does not support the Size property", id); c->Message(
0, "ERROR: Object %u is not a Static Object and does not support the Size property",
id);
return; return;
} }
@ -8882,12 +8910,16 @@ void command_object(Client *c, const Seperator *sep)
if (od.unknown008 == 0) // 0 == unspecified == 100% if (od.unknown008 == 0) // 0 == unspecified == 100%
od.unknown008 = 100; od.unknown008 = 100;
c->Message(0, "Static Object %u set to %u%% size. Size will take effect when you commit to the database with '#object Save', after which the object will be unchangeable until you unlock it again with '#object Edit' and zone out and back in.", id, od.unknown008); c->Message(0, "Static Object %u set to %u%% size. Size will take effect when you commit to the "
} "database with '#object Save', after which the object will be unchangeable until "
else if (strcmp(sep->arg[3], "solidtype") == 0) { "you unlock it again with '#object Edit' and zone out and back in.",
id, od.unknown008);
} else if (strcmp(sep->arg[3], "solidtype") == 0) {
if (od.object_type != staticType) { if (od.object_type != staticType) {
c->Message(0, "ERROR: Object %u is not a Static Object and does not support the SolidType property", id); c->Message(0, "ERROR: Object %u is not a Static Object and does not support the "
"SolidType property",
id);
return; return;
} }
@ -8899,12 +8931,16 @@ void command_object(Client *c, const Seperator *sep)
od.unknown010 = atoi(sep->arg[4]); od.unknown010 = atoi(sep->arg[4]);
o->SetObjectData(&od); o->SetObjectData(&od);
c->Message(0, "Static Object %u set to SolidType %u. Change will take effect when you commit to the database with '#object Save'. Support for this property is on a per-model basis, mostly seen in smaller objects such as chests and tables.", id, od.unknown010); c->Message(0, "Static Object %u set to SolidType %u. Change will take effect when you commit "
} "to the database with '#object Save'. Support for this property is on a "
else if (strcmp(sep->arg[3], "icon") == 0) { "per-model basis, mostly seen in smaller objects such as chests and tables.",
id, od.unknown010);
} else if (strcmp(sep->arg[3], "icon") == 0) {
if ((od.object_type < 2) || (od.object_type == staticType)) { if ((od.object_type < 2) || (od.object_type == staticType)) {
c->Message(0, "ERROR: Object %u is not a Tradeskill Object and does not support the Icon property", id); c->Message(0, "ERROR: Object %u is not a Tradeskill Object and does not support the "
"Icon property",
id);
return; return;
} }
@ -8915,24 +8951,30 @@ void command_object(Client *c, const Seperator *sep)
o->SetIcon(icon); o->SetIcon(icon);
c->Message(0, "Tradeskill Object %u icon set to %u", id, icon); c->Message(0, "Tradeskill Object %u icon set to %u", id, icon);
} } else if (strcmp(sep->arg[3], "incline") == 0) {
else if (strcmp(sep->arg[3], "incline") == 0) {
if (od.object_type != staticType) { if (od.object_type != staticType) {
c->Message(0, "ERROR: Object %u is not a Static Object and does not support the Incline property", id); c->Message(
0,
"ERROR: Object %u is not a Static Object and does not support the Incline property",
id);
return; return;
} }
if ((sep->arg[4][0] < '0') || (sep->arg[4][0] > '9')) { if ((sep->arg[4][0] < '0') || (sep->arg[4][0] > '9')) {
c->Message(0, "ERROR: Invalid Incline specified. Please enter a number. Normal range is 0-512."); c->Message(
0,
"ERROR: Invalid Incline specified. Please enter a number. Normal range is 0-512.");
return; return;
} }
od.unknown020 = atoi(sep->arg[4]); od.unknown020 = atoi(sep->arg[4]);
o->SetObjectData(&od); o->SetObjectData(&od);
c->Message(0, "Static Object %u set to %u incline. Incline will take effect when you commit to the database with '#object Save', after which the object will be unchangeable until you unlock it again with '#object Edit' and zone out and back in.", id, od.unknown020); c->Message(0, "Static Object %u set to %u incline. Incline will take effect when you commit to "
} "the database with '#object Save', after which the object will be unchangeable "
else { "until you unlock it again with '#object Edit' and zone out and back in.",
id, od.unknown020);
} else {
c->Message(0, "ERROR: Unrecognized property name: %s", sep->arg[3]); c->Message(0, "ERROR: Unrecognized property name: %s", sep->arg[3]);
return; return;
} }
@ -8954,8 +8996,7 @@ void command_object(Client *c, const Seperator *sep)
if ((sep->argnum < 2) || // Not enough arguments if ((sep->argnum < 2) || // Not enough arguments
((id = atoi(sep->arg[2])) == 0) || // ID not specified ((id = atoi(sep->arg[2])) == 0) || // ID not specified
(((sep->arg[3][0] < '0') || (sep->arg[3][0] > '9')) && (((sep->arg[3][0] < '0') || (sep->arg[3][0] > '9')) && ((sep->arg[3][0] & 0xDF) != 'T') &&
((sep->arg[3][0] & 0xDF) != 'T') &&
(sep->arg[3][0] != '-') && (sep->arg[3][0] != '.'))) { // Location argument not specified correctly (sep->arg[3][0] != '-') && (sep->arg[3][0] != '.'))) { // Location argument not specified correctly
c->Message(0, "Usage: #object Move (ObjectID) ToMe|(x y z [h])"); c->Message(0, "Usage: #object Move (ObjectID) ToMe|(x y z [h])");
return; return;
@ -8974,7 +9015,6 @@ void command_object(Client *c, const Seperator *sep)
od.zone_instance = atoi(row[1]); od.zone_instance = atoi(row[1]);
od.object_type = atoi(row[2]); od.object_type = atoi(row[2]);
if (od.zone_id != zone->GetZoneID()) { if (od.zone_id != zone->GetZoneID()) {
c->Message(0, "ERROR: Object %u is not in this zone", id); c->Message(0, "ERROR: Object %u is not in this zone", id);
return; return;
@ -8987,15 +9027,23 @@ void command_object(Client *c, const Seperator *sep)
switch (od.object_type) { switch (od.object_type) {
case 0: case 0:
c->Message(0, "ERROR: Object %u is not yet unlocked for editing. Use '#object Edit' then zone out and back in to move it.", id); c->Message(0, "ERROR: Object %u is not yet unlocked for editing. Use '#object Edit' "
"then zone out and back in to move it.",
id);
return; return;
case staticType: case staticType:
c->Message(0, "ERROR: Object %u has been unlocked for editing, but you must zone out and back in before your client sees the change and will allow you to move it.", id); c->Message(0, "ERROR: Object %u has been unlocked for editing, but you must zone out "
"and back in before your client sees the change and will allow you to "
"move it.",
id);
return; return;
case 1: case 1:
c->Message(0, "ERROR: Object %u is a temporary spawned object and cannot be manipulated with #object. See the 'ground_spawns' table in the database.", id); c->Message(0, "ERROR: Object %u is a temporary spawned object and cannot be "
"manipulated with #object. See the 'ground_spawns' table in the "
"database.",
id);
return; return;
default: default:
@ -9008,7 +9056,9 @@ void command_object(Client *c, const Seperator *sep)
if ((sep->arg[3][0] & 0xDF) == 'T') { if ((sep->arg[3][0] & 0xDF) == 'T') {
od.x = c->GetX(); od.x = c->GetX();
od.y = c->GetY(); od.y = c->GetY();
od.z = c->GetZ() - (c->GetSize() * 0.625f); // Compensate for #loc bumping up Z coordinate by 62.5% of character's size. od.z = c->GetZ() -
(c->GetSize() *
0.625f); // Compensate for #loc bumping up Z coordinate by 62.5% of character's size.
o->SetHeading(c->GetHeading() * 2.0f); // Compensate for GetHeading() returning half of actual o->SetHeading(c->GetHeading() * 2.0f); // Compensate for GetHeading() returning half of actual
@ -9058,7 +9108,9 @@ void command_object(Client *c, const Seperator *sep)
} }
if ((o = entity_list.FindObject(id)) == nullptr) { if ((o = entity_list.FindObject(id)) == nullptr) {
c->Message(0, "ERROR: Object %u not found in zone, or is a static object not yet unlocked with '#object Edit' for editing.", id); c->Message(0, "ERROR: Object %u not found in zone, or is a static object not yet unlocked with "
"'#object Edit' for editing.",
id);
return; return;
} }
@ -9123,12 +9175,17 @@ void command_object(Client *c, const Seperator *sep)
} }
if (od.object_type == 0) { if (od.object_type == 0) {
c->Message(0, "ERROR: Static Object %u has already been committed. Use '#object Edit %u' and zone out and back in to make changes.", id, id); c->Message(0, "ERROR: Static Object %u has already been committed. Use '#object Edit "
"%u' and zone out and back in to make changes.",
id, id);
return; return;
} }
if (od.object_type == 1) { if (od.object_type == 1) {
c->Message(0, "ERROR: Object %u is a temporarily spawned ground spawn or dropped item, which is not supported with #object. See the 'ground_spawns' table in the database.", id); c->Message(0, "ERROR: Object %u is a temporarily spawned ground spawn or dropped item, "
"which is not supported with #object. See the 'ground_spawns' table in "
"the database.",
id);
return; return;
} }
@ -9163,28 +9220,25 @@ void command_object(Client *c, const Seperator *sep)
"objectname = '%s', type = %u, icon = %u, " "objectname = '%s', type = %u, icon = %u, "
"unknown08 = %u, unknown10 = %u, unknown20 = %u " "unknown08 = %u, unknown10 = %u, unknown20 = %u "
"WHERE ID = %u", "WHERE ID = %u",
zone->GetZoneID(), zone->GetInstanceVersion(), zone->GetZoneID(), zone->GetInstanceVersion(), od.x, od.y, od.z,
od.x, od.y, od.z, od.heading, od.heading, od.object_name, od.object_type, icon, od.unknown008,
od.object_name, od.object_type, icon, od.unknown010, od.unknown020, id);
od.unknown008, od.unknown010, od.unknown020, id);
else if (id == 0) else if (id == 0)
query = StringFormat("INSERT INTO object " query = StringFormat("INSERT INTO object "
"(zoneid, version, xpos, ypos, zpos, heading, objectname, " "(zoneid, version, xpos, ypos, zpos, heading, objectname, "
"type, icon, unknown08, unknown10, unknown20) " "type, icon, unknown08, unknown10, unknown20) "
"VALUES (%u, %u, %.1f, %.1f, %.1f, %.1f, '%s', %u, %u, %u, %u, %u)", "VALUES (%u, %u, %.1f, %.1f, %.1f, %.1f, '%s', %u, %u, %u, %u, %u)",
zone->GetZoneID(), zone->GetInstanceVersion(), zone->GetZoneID(), zone->GetInstanceVersion(), od.x, od.y, od.z,
od.x, od.y, od.z, od.heading, od.heading, od.object_name, od.object_type, icon, od.unknown008,
od.object_name, od.object_type, icon, od.unknown010, od.unknown020);
od.unknown008, od.unknown010, od.unknown020);
else else
query = StringFormat("INSERT INTO object " query = StringFormat("INSERT INTO object "
"(id, zoneid, version, xpos, ypos, zpos, heading, objectname, " "(id, zoneid, version, xpos, ypos, zpos, heading, objectname, "
"type, icon, unknown08, unknown10, unknown20) " "type, icon, unknown08, unknown10, unknown20) "
"VALUES (%u, %u, %u, %.1f, %.1f, %.1f, %.1f, '%s', %u, %u, %u, %u, %u)", "VALUES (%u, %u, %u, %.1f, %.1f, %.1f, %.1f, '%s', %u, %u, %u, %u, %u)",
id, zone->GetZoneID(), zone->GetInstanceVersion(), id, zone->GetZoneID(), zone->GetInstanceVersion(), od.x, od.y, od.z,
od.x, od.y, od.z, od.heading, od.heading, od.object_name, od.object_type, icon, od.unknown008,
od.object_name, od.object_type, icon, od.unknown010, od.unknown020);
od.unknown008, od.unknown010, od.unknown020);
results = database.QueryDatabase(query); results = database.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
@ -9245,7 +9299,9 @@ void command_object(Client *c, const Seperator *sep)
if ((door.size = od.unknown008) == 0) // unknown08 = optional size percentage if ((door.size = od.unknown008) == 0) // unknown08 = optional size percentage
door.size = 100; door.size = 100;
switch (door.opentype = od.unknown010) // unknown10 = optional request_nonsolid (0 or 1 or experimental number) switch (
door.opentype =
od.unknown010) // unknown10 = optional request_nonsolid (0 or 1 or experimental number)
{ {
case 0: case 0:
door.opentype = 31; door.opentype = 31;
@ -9254,7 +9310,6 @@ void command_object(Client *c, const Seperator *sep)
case 1: case 1:
door.opentype = 9; door.opentype = 9;
break; break;
} }
door.incline = od.unknown020; // unknown20 = optional incline value door.incline = od.unknown020; // unknown20 = optional incline value
@ -9282,14 +9337,18 @@ void command_object(Client *c, const Seperator *sep)
entity_list.QueueClients(0, app); entity_list.QueueClients(0, app);
safe_delete(app); safe_delete(app);
c->Message(0, "NOTE: Object %u is now a static object, and is unchangeable. To make future changes, use '#object Edit' to convert it to a changeable form, then zone out and back in.", id); c->Message(0, "NOTE: Object %u is now a static object, and is unchangeable. To make future "
"changes, use '#object Edit' to convert it to a changeable form, then zone out "
"and back in.",
id);
} }
return; return;
} }
if (strcasecmp(sep->arg[1], "copy") == 0) { if (strcasecmp(sep->arg[1], "copy") == 0) {
// Insufficient or invalid arguments // Insufficient or invalid arguments
if ((sep->argnum < 3) || (((sep->arg[2][0] & 0xDF) != 'A') && ((sep->arg[2][0] < '0') || (sep->arg[2][0] > '9')))) { if ((sep->argnum < 3) ||
(((sep->arg[2][0] & 0xDF) != 'A') && ((sep->arg[2][0] < '0') || (sep->arg[2][0] > '9')))) {
c->Message(0, "Usage: #object Copy All|(ObjectID) (InstanceVersion)"); c->Message(0, "Usage: #object Copy All|(ObjectID) (InstanceVersion)");
c->Message(0, "- Note: Only objects saved in the database can be copied to another instance."); c->Message(0, "- Note: Only objects saved in the database can be copied to another instance.");
return; return;
@ -9305,7 +9364,8 @@ void command_object(Client *c, const Seperator *sep)
if ((sep->arg[2][0] & 0xDF) == 'A') { if ((sep->arg[2][0] & 0xDF) == 'A') {
// Copy All // Copy All
std::string query = StringFormat("INSERT INTO object " std::string query =
StringFormat("INSERT INTO object "
"(zoneid, version, xpos, ypos, zpos, heading, itemid, " "(zoneid, version, xpos, ypos, zpos, heading, itemid, "
"objectname, type, icon, unknown08, unknown10, unknown20) " "objectname, type, icon, unknown08, unknown10, unknown20) "
"SELECT zoneid, %u, xpos, ypos, zpos, heading, itemid, " "SELECT zoneid, %u, xpos, ypos, zpos, heading, itemid, "
@ -9318,7 +9378,8 @@ void command_object(Client *c, const Seperator *sep)
return; return;
} }
c->Message(0, "Copied %u object%s into instance version %u", results.RowCount(), (results.RowCount() == 1) ? "" : "s", od.zone_instance); c->Message(0, "Copied %u object%s into instance version %u", results.RowCount(),
(results.RowCount() == 1) ? "" : "s", od.zone_instance);
return; return;
} }
@ -9371,14 +9432,16 @@ void command_object(Client *c, const Seperator *sep)
} }
// Well, NO clue at this point. Just let 'em know something screwed up. // Well, NO clue at this point. Just let 'em know something screwed up.
c->Message(0, "ERROR: Unknown database error copying Object %u to instance version %u", id, od.zone_instance); c->Message(0, "ERROR: Unknown database error copying Object %u to instance version %u", id,
od.zone_instance);
return; return;
} }
if (strcasecmp(sep->arg[1], "delete") == 0) { if (strcasecmp(sep->arg[1], "delete") == 0) {
if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) <= 0)) { if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) <= 0)) {
c->Message(0, "Usage: #object Delete (ObjectID) -- NOTE: Object deletions are permanent and cannot be undone!"); c->Message(0, "Usage: #object Delete (ObjectID) -- NOTE: Object deletions are permanent and "
"cannot be undone!");
return; return;
} }
@ -9405,7 +9468,6 @@ void command_object(Client *c, const Seperator *sep)
return; return;
} }
// Object not found in zone. // Object not found in zone.
std::string query = StringFormat("SELECT type FROM object " std::string query = StringFormat("SELECT type FROM object "
"WHERE id = %u AND zoneid = %u " "WHERE id = %u AND zoneid = %u "
@ -9429,13 +9491,16 @@ void command_object(Client *c, const Seperator *sep)
id, zone->GetZoneID(), zone->GetInstanceVersion()); id, zone->GetZoneID(), zone->GetInstanceVersion());
results = database.QueryDatabase(query); results = database.QueryDatabase(query);
c->Message(0, "Object %u deleted. NOTE: This static object will remain for anyone currently in the zone until they next zone out and in.", id); c->Message(0, "Object %u deleted. NOTE: This static object will remain for anyone currently in "
"the zone until they next zone out and in.",
id);
return; return;
case 1: // Temporary Spawn case 1: // Temporary Spawn
c->Message(0, "ERROR: Object %u is a temporarily spawned ground spawn or dropped item, which is not supported with #object. See the 'ground_spawns' table in the database.", id); c->Message(0, "ERROR: Object %u is a temporarily spawned ground spawn or dropped item, which "
"is not supported with #object. See the 'ground_spawns' table in the database.",
id);
return; return;
} }
return; return;
@ -9444,19 +9509,23 @@ void command_object(Client *c, const Seperator *sep)
if (strcasecmp(sep->arg[1], "undo") == 0) { if (strcasecmp(sep->arg[1], "undo") == 0) {
// Insufficient or invalid arguments // Insufficient or invalid arguments
if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) == 0)) { if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) == 0)) {
c->Message(0, "Usage: #object Undo (ObjectID) -- Reload object from database, undoing any changes you have made"); c->Message(0, "Usage: #object Undo (ObjectID) -- Reload object from database, undoing any "
"changes you have made");
return; return;
} }
o = entity_list.FindObject(id); o = entity_list.FindObject(id);
if (!o) { if (!o) {
c->Message(0, "ERROR: Object %u not found in zone in a manipulable form. No changes to undo.", id); c->Message(0, "ERROR: Object %u not found in zone in a manipulable form. No changes to undo.",
id);
return; return;
} }
if (o->GetType() == OT_DROPPEDITEM) { if (o->GetType() == OT_DROPPEDITEM) {
c->Message(0, "ERROR: Object %u is a temporary spawned item and cannot be manipulated with #object. See the 'ground_spawns' table in the database.", id); c->Message(0, "ERROR: Object %u is a temporary spawned item and cannot be manipulated with "
"#object. See the 'ground_spawns' table in the database.",
id);
return; return;
} }
@ -9470,7 +9539,8 @@ void command_object(Client *c, const Seperator *sep)
std::string query = StringFormat("SELECT xpos, ypos, zpos, " std::string query = StringFormat("SELECT xpos, ypos, zpos, "
"heading, objectname, type, icon, " "heading, objectname, type, icon, "
"unknown08, unknown10, unknown20 " "unknown08, unknown10, unknown20 "
"FROM object WHERE id = %u", id); "FROM object WHERE id = %u",
id);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
if (!results.Success() || results.RowCount() == 0) { if (!results.Success() || results.RowCount() == 0) {
c->Message(0, "Database Error: %s", results.ErrorMessage().c_str()); c->Message(0, "Database Error: %s", results.ErrorMessage().c_str());