feat: Added Packet class and onPacket event

This commit is contained in:
AURUMVORXX
2024-11-05 02:44:38 +03:00
parent 558e607c5f
commit 2657b2c613
15 changed files with 585 additions and 7 deletions

View File

@@ -0,0 +1,111 @@
#include "CustomTypes.h"
#include "Array.h"
#include "Property.h"
namespace nonut::g2o
{
#define GET_SLOT(slot, type) slot = arrayWrapper.get<type>(#slot)
void GameTime::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(day, Int);
GET_SLOT(hour, Int);
GET_SLOT(min, Int);
}
void Position2d::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(x, Int);
GET_SLOT(y, Int);
}
void Position3d::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(x, Float);
GET_SLOT(y, Float);
GET_SLOT(z, Float);
}
void Size2d::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(width, Int);
GET_SLOT(height, Int);
}
void Rect::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(x, Int);
GET_SLOT(y, Int);
GET_SLOT(width, Int);
GET_SLOT(height, Int);
}
void UV::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(x, Float);
GET_SLOT(y, Float);
GET_SLOT(width, Float);
GET_SLOT(height, Float);
}
void Resolution::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(x, Int);
GET_SLOT(y, Int);
GET_SLOT(bpp, Int);
}
void Item::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(instance, Int);
GET_SLOT(amount, Int);
GET_SLOT(name, String);
}
void Color::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(r, Int);
GET_SLOT(g, Int);
GET_SLOT(b, Int);
}
void BodyVisual::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(bodyModel, String);
GET_SLOT(bodyTxt, Int);
GET_SLOT(headModel, String);
GET_SLOT(headTxt, Int);
}
void NetworkStats::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(packetReceived, Int);
GET_SLOT(packetlossTotal, Int);
GET_SLOT(packetlossLastSecond, Int);
GET_SLOT(messagesInResendBuffer, Int);
GET_SLOT(messageInSendBuffer, Int);
GET_SLOT(bytesInResendBuffer, Int);
GET_SLOT(bytesInSendBuffer, Int);
}
void Position3dWithName::convert(SQObject object)
{
Array arrayWrapper(object);
GET_SLOT(name, String);
GET_SLOT(x, Float);
GET_SLOT(y, Float);
GET_SLOT(z, Float);
}
}

View File

@@ -0,0 +1,168 @@
#ifndef NONUT_G2O_SHARED_CUSTOM_TYPES_H
#define NONUT_G2O_SHARED_CUSTOM_TYPES_H
#include <string>
#include "Utils.h"
namespace nonut::g2o
{
struct GameTime : CustomType
{
void convert(SQObject object) override;
Int day{};
Int hour{};
Int min{};
auto toTuple()
{
return std::make_tuple(day, hour, min);
}
};
struct Position2d : CustomType
{
void convert(SQObject object) override;
Int x{};
Int y{};
auto toTuple()
{
return std::make_tuple(x, y);
}
};
struct Position3d : CustomType
{
void convert(SQObject object) override;
Float x{};
Float y{};
Float z{};
auto toTuple()
{
return std::make_tuple(x, y, z);
}
};
struct Size2d : CustomType
{
void convert(SQObject object) override;
Int width{};
Int height{};
auto toTuple()
{
return std::make_tuple(width, height);
}
};
struct Rect : CustomType
{
void convert(SQObject object) override;
Int x;
Int y;
Int width;
Int height;
auto toTuple()
{
return std::make_tuple(x, y, width, height);
}
};
struct UV : CustomType
{
void convert(SQObject object) override;
Float x;
Float y;
Float width;
Float height;
auto toTuple()
{
return std::make_tuple(x, y, width, height);
}
};
struct Resolution : CustomType
{
void convert(SQObject object) override;
Int x{};
Int y{};
Int bpp{};
auto toTuple()
{
return std::make_tuple(x, y, bpp);
}
};
struct Item : CustomType
{
void convert(SQObject object) override;
Int instance{};
Int amount{};
String name{};
auto toTuple()
{
return std::make_tuple(instance, amount, name);
}
};
struct Color : CustomType
{
void convert(SQObject object) override;
Int r{};
Int g{};
Int b{};
auto toTuple()
{
return std::make_tuple(r, g, b);
}
};
struct BodyVisual : CustomType
{
void convert(SQObject object) override;
String bodyModel{};
Int bodyTxt{};
String headModel{};
Int headTxt{};
auto toTuple()
{
return std::make_tuple(bodyModel, bodyTxt, headModel, headTxt);
}
};
struct NetworkStats : CustomType
{
void convert(SQObject object) override;
Int packetReceived{};
Int packetlossTotal{};
Int packetlossLastSecond{};
Int messagesInResendBuffer{};
Int messageInSendBuffer{};
Int bytesInResendBuffer{};
Int bytesInSendBuffer{};
auto toTuple()
{
return std::make_tuple(
packetReceived,
packetlossTotal,
packetlossLastSecond,
messagesInResendBuffer,
messageInSendBuffer,
bytesInResendBuffer,
bytesInSendBuffer);
}
};
struct Position3dWithName : CustomType
{
void convert(SQObject object) override;
String name{};
Float x{};
Float y{};
Float z{};
auto toTuple()
{
return std::make_tuple(name, x, y, z);
}
};
}
#endif // NONUT_G2O_SHARED_CUSTOM_TYPES_H

View File

@@ -1,5 +1,6 @@
#ifndef NONUT_CORE_INSTANCE_H
#define NONUT_CORE_INSTANCE_H
#include <sqapi.h>
namespace nonut
{