Add TiltX and TiltY manipulation to objects (Perl)

Translate OP_GroundSpawn for Titanium

#perl plugin http://wiki.eqemulator.org/i?Module=Pastebin&Paste=u9IbA6Ql
This commit is contained in:
Natedog2012
2016-08-26 06:34:51 -07:00
parent 385823461b
commit 4de9b2c53e
13 changed files with 232 additions and 29 deletions
+47 -4
View File
@@ -63,6 +63,9 @@ Object::Object(uint32 id, uint32 type, uint32 icon, const Object_Struct& object,
// Set drop_id to zero - it will be set when added to zone with SetID()
m_data.drop_id = 0;
m_data.size = object.size;
m_data.tilt_x = object.tilt_x;
m_data.tilt_y = object.tilt_y;
}
//creating a re-ocurring ground spawn.
@@ -653,10 +656,12 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec
// Save new record for object
std::string query = StringFormat("UPDATE object SET "
"zoneid = %i, xpos = %f, ypos = %f, zpos = %f, heading = %f, "
"itemid = %i, charges = %i, objectname = '%s', type = %i, icon = %i "
"itemid = %i, charges = %i, objectname = '%s', type = %i, icon = %i, "
"size = %f, tilt_x = %f, tilt_y = %f "
"WHERE id = %i",
object.zone_id, object.x, object.y, object.z, object.heading,
item_id, charges, object_name, type, icon, id);
item_id, charges, object_name, type, icon,
object.size, object.tilt_x, object.tilt_y, id);
safe_delete_array(object_name);
auto results = QueryDatabase(query);
if (!results.Success()) {
@@ -750,6 +755,16 @@ float Object::GetHeadingData()
return this->m_data.heading;
}
float Object::GetTiltX()
{
return this->m_data.tilt_x;
}
float Object::GetTiltY()
{
return this->m_data.tilt_y;
}
void Object::SetX(float pos)
{
this->m_data.x = pos;
@@ -778,6 +793,34 @@ void Object::SetY(float pos)
safe_delete(app2);
}
void Object::SetTiltX(float pos)
{
this->m_data.tilt_x = pos;
auto app = new EQApplicationPacket();
auto app2 = new EQApplicationPacket();
this->CreateDeSpawnPacket(app);
this->CreateSpawnPacket(app2);
entity_list.QueueClients(0, app);
entity_list.QueueClients(0, app2);
safe_delete(app);
safe_delete(app2);
}
void Object::SetTiltY(float pos)
{
this->m_data.tilt_y = pos;
auto app = new EQApplicationPacket();
auto app2 = new EQApplicationPacket();
this->CreateDeSpawnPacket(app);
this->CreateSpawnPacket(app2);
entity_list.QueueClients(0, app);
entity_list.QueueClients(0, app2);
safe_delete(app);
safe_delete(app2);
}
void Object::Depop()
{
auto app = new EQApplicationPacket();
@@ -828,7 +871,7 @@ void Object::SetModelName(const char* modelname)
safe_delete(app2);
}
void Object::SetSize(uint16 size)
void Object::SetSize(float size)
{
m_data.size = size;
auto app = new EQApplicationPacket();
@@ -854,7 +897,7 @@ void Object::SetSolidType(uint16 solidtype)
safe_delete(app2);
}
uint16 Object::GetSize()
float Object::GetSize()
{
return m_data.size;
}
+6 -2
View File
@@ -154,10 +154,14 @@ public:
void SetX(float pos);
void SetY(float pos);
void SetZ(float pos);
void SetTiltX(float pos);
void SetTiltY(float pos);
float GetTiltX();
float GetTiltY();
void SetModelName(const char* modelname);
const char* GetModelName();
uint16 GetSize();
void SetSize(uint16 size);
float GetSize();
void SetSize(float size);
uint16 GetSolidType();
void SetSolidType(uint16 size);
+107 -3
View File
@@ -968,7 +968,7 @@ XS(XS_Object_GetSize)
Perl_croak(aTHX_ "Usage: Object::GetSize(THIS)");
{
Object * THIS;
uint16 RETVAL;
float RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Object")) {
@@ -981,7 +981,7 @@ XS(XS_Object_GetSize)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetSize();
XSprePUSH; PUSHu((UV)RETVAL);
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
}
@@ -995,7 +995,7 @@ XS(XS_Object_SetSize)
Perl_croak(aTHX_ "Usage: Object::SetSize(THIS, type)");
{
Object * THIS;
uint16 size = (uint16)SvUV(ST(1));
float size = (float)SvNV(ST(1));
if (sv_derived_from(ST(0), "Object")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
@@ -1011,6 +1011,106 @@ XS(XS_Object_SetSize)
XSRETURN_EMPTY;
}
XS(XS_Object_SetTiltX); /* prototype to pass -Wmissing-prototypes */
XS(XS_Object_SetTiltX)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetTiltX(THIS, pos)");
{
Object * THIS;
float pos = (float)SvNV(ST(1));
if (sv_derived_from(ST(0), "Object")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Object *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Object");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
THIS->SetTiltX(pos);
}
XSRETURN_EMPTY;
}
XS(XS_Object_SetTiltY); /* prototype to pass -Wmissing-prototypes */
XS(XS_Object_SetTiltY)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetTiltY(THIS, pos)");
{
Object * THIS;
float pos = (float)SvNV(ST(1));
if (sv_derived_from(ST(0), "Object")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Object *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Object");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
THIS->SetTiltY(pos);
}
XSRETURN_EMPTY;
}
XS(XS_Object_GetTiltX); /* prototype to pass -Wmissing-prototypes */
XS(XS_Object_GetTiltX)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Object::GetSize(THIS)");
{
Object * THIS;
float RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Object")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Object *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Object");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetTiltX();
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
}
XS(XS_Object_GetTiltY); /* prototype to pass -Wmissing-prototypes */
XS(XS_Object_GetTiltY)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Object::GetSize(THIS)");
{
Object * THIS;
float RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "Object")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Object *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Object");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetTiltY();
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
@@ -1066,6 +1166,10 @@ XS(boot_Object)
newXSproto(strcpy(buf, "GetSolidType"),XS_Object_GetSolidType, file, "$");
newXSproto(strcpy(buf, "SetSize"),XS_Object_SetSize, file, "$$");
newXSproto(strcpy(buf, "GetSize"),XS_Object_GetSize, file, "$");
newXSproto(strcpy(buf, "SetTiltX"),XS_Object_SetTiltX, file, "$$");
newXSproto(strcpy(buf, "SetTiltY"),XS_Object_SetTiltY, file, "$");
newXSproto(strcpy(buf, "GetTiltX"),XS_Object_GetTiltX, file, "$$");
newXSproto(strcpy(buf, "GetTiltY"),XS_Object_GetTiltY, file, "$");
XSRETURN_YES;
}
#endif //EMBPERL_XS_CLASSES
+6 -2
View File
@@ -161,7 +161,8 @@ bool Zone::LoadZoneObjects() {
std::string query = StringFormat("SELECT id, zoneid, xpos, ypos, zpos, heading, "
"itemid, charges, objectname, type, icon, unknown08, "
"unknown10, unknown20, unknown24, unknown76 fROM object "
"unknown10, unknown20, unknown24, unknown76, size, tilt_x, "
"tilt_y FROM object "
"WHERE zoneid = %i AND (version = %u OR version = -1)",
zoneid, instanceversion);
auto results = database.QueryDatabase(query);
@@ -241,11 +242,14 @@ bool Zone::LoadZoneObjects() {
data.object_type = type;
data.linked_list_addr[0] = 0;
data.linked_list_addr[1] = 0;
data.size = (uint32)atoi(row[11]);
data.solidtype = (uint32)atoi(row[12]);
data.unknown020 = (uint32)atoi(row[13]);
data.unknown024 = (uint32)atoi(row[14]);
data.unknown076 = (uint32)atoi(row[15]);
data.size = atof(row[16]);
data.tilt_x = atof(row[17]);
data.tilt_y = atof(row[18]);
data.unknown084 = 0;
ItemInst* inst = nullptr;