refactor: Refactorized whole project structure

This commit is contained in:
AURUMVORXX
2025-01-24 22:36:25 +03:00
parent d50f55086b
commit a479b5f85d
321 changed files with 288 additions and 219 deletions

View File

@@ -0,0 +1,17 @@
target_sources(${PYG2O_MODULE_NAME}
PRIVATE
squirrel/Daedalus.cpp
squirrel/DamageDescription.cpp
squirrel/ItemGround.cpp
squirrel/ItemsGround.cpp
squirrel/Mds.cpp
squirrel/Packet.cpp
squirrel/Sky.cpp
squirrel/Way.cpp
)
target_include_directories(${PYG2O_MODULE_NAME}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/
)

View File

@@ -0,0 +1,19 @@
#ifndef _PYDAEDALUS_H_
#define _PYDAEDALUS_H_
#include <pybind11/embed.h>
#include "squirrel/Daedalus.h"
namespace py = pybind11;
class PyDaedalus
{
public:
static nonut::Int index(nonut::String value) { return nonut::Daedalus::get()->index(value); }
static py::dict symbol(nonut::String value) { return nonut::Daedalus::get()->symbol(value).data; }
static py::dict instance(nonut::String value) { return nonut::Daedalus::get()->instance(value).data; }
};
#endif

View File

@@ -0,0 +1,32 @@
#ifndef _PYDAMAGEDESCRIPTION_H
#define _PYDAMAGEDESCRIPTION_H
#include "squirrel/DamageDescription.h"
class PyDamageDescription
{
private:
nonut::DamageDescription *sqobj;
public:
PyDamageDescription(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqobj = new nonut::DamageDescription(obj); }
nonut::Int getFlags() { return sqobj->flags; }
nonut::Int getDamage() { return sqobj->damage; }
nonut::String getItemInstance() { return sqobj->item_instance; }
nonut::Int getDistance() { return sqobj->distance; }
nonut::Int getSpellId() { return sqobj->spell_id; }
nonut::Int getSpellLevel() { return sqobj->spell_level; }
nonut::String getNode() { return sqobj->node; }
void setFlags(nonut::Int value) { sqobj->flags = value; }
void setDamage(nonut::Int value) { sqobj->damage = value; }
void setDistance(nonut::Int value) { sqobj->distance = value; }
void setSpellId(nonut::Int value) { sqobj->spell_id = value; }
void setSpellLevel(nonut::Int value) { sqobj->spell_level = value; }
void setNode(nonut::String value) { sqobj->node = value; }
void del() { delete sqobj; }
};
#endif

View File

@@ -0,0 +1,32 @@
#ifndef _PY_ITEMGROUND_H_
#define _PY_ITEMGROUND_H_
#include <pybind11/embed.h>
#include "squirrel/ItemGround.h"
namespace py = pybind11;
class PyItemGround
{
private:
nonut::ItemGround *sqobj;
public:
PyItemGround(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqobj = new nonut::ItemGround(obj); }
PyItemGround(nonut::ItemGround obj) { if (obj.isNull()) throw py::type_error("Presented ItemGround doesn't exist (type: null)"); sqobj = &obj; }
py::tuple getPosition() { return py::make_tuple(sqobj->getPosition().toTuple()); }
py::tuple getRotation() { return py::make_tuple(sqobj->getRotation().toTuple()); }
nonut::Int getId() { return sqobj->id; }
nonut::String getInstance() { return sqobj->instance; }
nonut::Int getAmount() { return sqobj->amount; }
nonut::String getWorld() { return sqobj->world; }
nonut::Int getVirtualWorld() { return sqobj->virtualWorld; }
void setVirtualWorld(nonut::Int value) { sqobj->virtualWorld = value; }
void del() { delete sqobj; }
};
#endif

View File

@@ -0,0 +1,24 @@
#ifndef _PYITEMSGROUND_H_
#define _PYITEMSGROUND_H_
#include "squirrel/ItemsGround.h"
#include "squirrel/ItemGround.h"
#include "Dictionary.h"
class PyItemsGround
{
public:
static PyItemGround getById(nonut::Int value) { return PyItemGround(nonut::ItemsGround::get()->getById(value)); }
static nonut::Int create(py::dict value)
{
Sqrat::Table* pTable = PyDictionary::toSqObject(value);
nonut::Int result = nonut::ItemsGround::get()->create(pTable->GetObject());
delete pTable;
return result;
}
static void destroy(nonut::Int value) { nonut::ItemsGround::get()->destroy(value); }
};
#endif

View File

@@ -0,0 +1,17 @@
#ifndef _PYMDS_H
#define _PYMDS_H
#include <pybind11/embed.h>
#include "squirrel/Mds.h"
namespace py = pybind11;
class PyMds
{
public:
static int id(std::string mdsName) { return nonut::Mds::get()->id(mdsName); }
static std::string name(int mdsId) { return nonut::Mds::get()->name(mdsId); }
};
#endif

View File

@@ -0,0 +1,47 @@
#ifndef _PYPACKET_H_
#define _PYPACKET_H_
#include "squirrel/Packet.h"
class PyPacket
{
private:
nonut::Packet *sqpacket;
public:
PyPacket() { sqpacket = new nonut::Packet(); };
PyPacket(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqpacket = new nonut::Packet(obj); }
void reset() { sqpacket->reset(); }
void send(nonut::Int id, nonut::Int value) { sqpacket->send(id, value); }
void sendToAll(nonut::Int value) { sqpacket->sendToAll(value); };
void writeInt8(nonut::Int value) { sqpacket->writeInt8(value); }
void writeUInt8(nonut::Int value) { sqpacket->writeUInt8(value); }
void writeInt16(nonut::Int value) { sqpacket->writeInt16(value); }
void writeUInt16(nonut::Int value) { sqpacket->writeUInt16(value); }
void writeInt32(nonut::Int value) { sqpacket->writeInt32(value); }
void writeUInt32(nonut::Int value) { sqpacket->writeUInt32(value); }
void writeBool(nonut::Bool value) { sqpacket->writeBool(value); }
void writeFloat(nonut::Float value) { sqpacket->writeFloat(value); }
void writeString(nonut::String value) { sqpacket->writeString(value); }
nonut::Int readInt8() { return sqpacket->readInt8(); }
nonut::Int readUInt8() { return sqpacket->readUInt8(); }
nonut::Int readInt16() { return sqpacket->readInt16(); }
nonut::Int readUInt16() { return sqpacket->readUInt16(); }
nonut::Int readInt32() { return sqpacket->readInt32(); }
nonut::Int readUInt32() { return sqpacket->readUInt32(); }
nonut::Bool readBool() { return sqpacket->readBool(); }
nonut::Float readFloat() { return sqpacket->readFloat(); }
nonut::String readString() { return sqpacket->readString(); }
nonut::Int getBitsUsed() { return sqpacket->bitsUsed; }
nonut::Int getBytesUsed() { return sqpacket->bytesUsed; }
void del() { delete sqpacket; }
};
#endif

View File

@@ -0,0 +1,31 @@
#ifndef _PYSKY_H_
#define _PYSKY_H_
#include <pybind11/embed.h>
#include "squirrel/Sky.h"
namespace py = pybind11;
class PySky
{
public:
static void setWeather(nonut::Int value) { nonut::Sky::get()->weather = value; }
static nonut::Int getWeather() { return nonut::Sky::get()->weather; }
static void setRaining(nonut::Bool value) { nonut::Sky::get()->raining = value; }
static nonut::Bool getRaining() { return nonut::Sky::get()->raining; }
static void setRenderLightning(nonut::Bool value) { nonut::Sky::get()->renderLightning = value; }
static nonut::Bool getRenderLightning() { return nonut::Sky::get()->renderLightning; }
static void setWindScale(nonut::Float value) { nonut::Sky::get()->windScale = value; }
static nonut::Float getWindScale() { return nonut::Sky::get()->windScale; }
static void setDontRain(nonut::Bool value) { nonut::Sky::get()->dontRain = value; }
static nonut::Bool getDontRain() { return nonut::Sky::get()->dontRain; }
static void setRainStartTime(nonut::Int h, nonut::Int m) { nonut::Sky::get()->setRainStartTime(h, m); }
static void setRainStopTime(nonut::Int h, nonut::Int m) { nonut::Sky::get()->setRainStopTime(h, m); }
static py::dict getRainStartTime() { return nonut::Sky::get()->getRainStartTime().data; }
static py::dict getRainStopTime() { return nonut::Sky::get()->getRainStopTime().data; }
};
#endif

View File

@@ -0,0 +1,24 @@
#ifndef _PYWAY_H_
#define _PYWAY_H_
#include "squirrel/Way.h"
class PyWay
{
private:
nonut::Way *sqway;
public:
PyWay(std::string world, std::string start, std::string end) { sqway = new nonut::Way(world, start, end); };
PyWay(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqway = new nonut::Way(obj); }
py::list getWaypoints() { return sqway->getWaypoints().data; }
int getCountWaypoints() { return sqway->getCountWaypoints(); }
std::string getStart() { return sqway->start; }
std::string getEnd() { return sqway->end; }
void del() { delete sqway; }
};
#endif

View File

@@ -0,0 +1,23 @@
#include <CommonHeader.h>
#include "Daedalus.h"
namespace nonut
{
Daedalus* Daedalus::get()
{
if (inst == nullptr)
{
inst = new Daedalus();
}
return inst;
}
Daedalus::Daedalus() :
StaticClass("Daedalus"),
METHOD_CTOR(index),
METHOD_CTOR(symbol),
METHOD_CTOR(instance)
{
}
}

View File

@@ -0,0 +1,27 @@
#ifndef _DAEDALUS_H_
#define _DAEDALUS_H_
#include <string>
#include <StaticClass.h>
#include <CustomTypes.h>
namespace nonut
{
class Daedalus : public StaticClass
{
public:
static Daedalus* get();
Function<Int, String> index;
Function<SqDict, String> symbol;
Function<SqDict, String> instance;
private:
static inline Daedalus* inst = nullptr;
Daedalus();
};
}
#endif

View File

@@ -0,0 +1,18 @@
#include "CommonHeader.h"
#include "DamageDescription.h"
namespace nonut
{
DamageDescription::DamageDescription(SQObject object) :
Class("DamageDescription", object),
PROPERTY_CTOR(flags),
PROPERTY_CTOR(damage),
PROPERTY_CTOR(item_instance),
PROPERTY_CTOR(distance),
PROPERTY_CTOR(spell_id),
PROPERTY_CTOR(spell_level),
PROPERTY_CTOR(node)
{
}
}

View File

@@ -0,0 +1,25 @@
#ifndef _DAMAGEDESCRIPTION_H_
#define _DAMAGEDESCRIPTION_H_
#include <string>
#include <Class.h>
#include <CustomTypes.h>
namespace nonut
{
class DamageDescription : public Class
{
public:
DamageDescription(SQObject object);
Property<Int> flags;
Property<Int> damage;
Property<String> item_instance;
Property<Int> distance;
Property<Int> spell_id;
Property<Int> spell_level;
Property<String> node;
};
}
#endif

View File

@@ -0,0 +1,19 @@
#include <CommonHeader.h>
#include "ItemGround.h"
namespace nonut
{
ItemGround::ItemGround(SQObject object) :
Class("ItemGround", object),
METHOD_CTOR(getPosition),
METHOD_CTOR(getRotation),
PROPERTY_CTOR(id),
PROPERTY_CTOR(instance),
PROPERTY_CTOR(amount),
PROPERTY_CTOR(world),
PROPERTY_CTOR(virtualWorld)
{
}
}

View File

@@ -0,0 +1,27 @@
#ifndef _ITEMGROUND_H
#define _ITEMGROUND_H
#include <string>
#include <Class.h>
#include <CustomTypes.h>
namespace nonut
{
class ItemGround : public Class
{
public:
ItemGround(SQObject object);
Function<nonut::Position3d> getPosition;
Function<nonut::Position3d> getRotation;
// Properties
Property<Int> id;
Property<String> instance;
Property<Int> amount;
Property<String> world;
Property<Int> virtualWorld;
};
}
#endif

View File

@@ -0,0 +1,23 @@
#include <CommonHeader.h>
#include "ItemsGround.h"
namespace nonut
{
ItemsGround* ItemsGround::get()
{
if (inst == nullptr)
{
inst = new ItemsGround();
}
return inst;
}
ItemsGround::ItemsGround() :
StaticClass("ItemsGround"),
METHOD_CTOR(getById),
METHOD_CTOR(create),
METHOD_CTOR(destroy)
{
}
}

View File

@@ -0,0 +1,30 @@
#ifndef _ITEMSGROUND_H_
#define _ITEMSGROUND_H_
#include <string>
#include <StaticClass.h>
#include <CustomTypes.h>
#include "ItemGround.h"
#include <pybind11/embed.h>
namespace py = pybind11;
namespace nonut
{
class ItemsGround : public StaticClass
{
public:
static ItemsGround* get();
Function<ItemGround, Int> getById;
Function<Int, SQObject> create;
Function<void, Int> destroy;
private:
static inline ItemsGround* inst = nullptr;
ItemsGround();
};
}
#endif

View File

@@ -0,0 +1,22 @@
#include <CommonHeader.h>
#include "Mds.h"
namespace nonut
{
Mds* Mds::get()
{
if (inst == nullptr)
{
inst = new Mds();
}
return inst;
}
Mds::Mds() :
StaticClass("Mds"),
METHOD_CTOR(id),
METHOD_CTOR(name)
{
}
}

View File

@@ -0,0 +1,26 @@
#ifndef _MDS_H
#define _MDS_H
#include <string>
#include <StaticClass.h>
#include <CustomTypes.h>
namespace nonut
{
class Mds : public StaticClass
{
public:
static Mds* get();
Function<Int, String> id;
Function<String, Int> name;
private:
static inline Mds* inst = nullptr;
Mds();
};
}
#endif

View File

@@ -0,0 +1,64 @@
#include <CommonHeader.h>
#include "Packet.h"
namespace nonut
{
Packet::Packet() :
Class("Packet"),
METHOD_CTOR(reset),
METHOD_CTOR(send),
METHOD_CTOR(sendToAll),
METHOD_CTOR(writeBool),
METHOD_CTOR(writeInt8),
METHOD_CTOR(writeUInt8),
METHOD_CTOR(writeInt16),
METHOD_CTOR(writeUInt16),
METHOD_CTOR(writeInt32),
METHOD_CTOR(writeUInt32),
METHOD_CTOR(writeFloat),
METHOD_CTOR(writeString),
METHOD_CTOR(readBool),
METHOD_CTOR(readInt8),
METHOD_CTOR(readUInt8),
METHOD_CTOR(readInt16),
METHOD_CTOR(readUInt16),
METHOD_CTOR(readInt32),
METHOD_CTOR(readUInt32),
METHOD_CTOR(readFloat),
METHOD_CTOR(readString),
PROPERTY_CTOR(bitsUsed),
PROPERTY_CTOR(bytesUsed)
{
classCtor();
}
Packet::Packet(SQObject object) :
Class("Packet", object),
METHOD_CTOR(reset),
METHOD_CTOR(send),
METHOD_CTOR(sendToAll),
METHOD_CTOR(writeBool),
METHOD_CTOR(writeInt8),
METHOD_CTOR(writeUInt8),
METHOD_CTOR(writeInt16),
METHOD_CTOR(writeUInt16),
METHOD_CTOR(writeInt32),
METHOD_CTOR(writeUInt32),
METHOD_CTOR(writeFloat),
METHOD_CTOR(writeString),
METHOD_CTOR(readBool),
METHOD_CTOR(readInt8),
METHOD_CTOR(readUInt8),
METHOD_CTOR(readInt16),
METHOD_CTOR(readUInt16),
METHOD_CTOR(readInt32),
METHOD_CTOR(readUInt32),
METHOD_CTOR(readFloat),
METHOD_CTOR(readString),
PROPERTY_CTOR(bitsUsed),
PROPERTY_CTOR(bytesUsed)
{
}
}

View File

@@ -0,0 +1,43 @@
#ifndef _PACKET_H_
#define _PACKET_H_
#include <string>
#include <Class.h>
#include <CustomTypes.h>
namespace nonut
{
class Packet : public Class
{
public:
Packet();
explicit Packet(SQObject object);
Function<void> reset;
Function<void, Int, Int> send;
Function<void, Int> sendToAll;
Function<void, Bool> writeBool;
Function<void, Int> writeInt8;
Function<void, Int> writeUInt8;
Function<void, Int> writeInt16;
Function<void, Int> writeUInt16;
Function<void, Int> writeInt32;
Function<void, Int> writeUInt32;
Function<void, Float> writeFloat;
Function<void, String&> writeString;
Function<Bool> readBool;
Function<Int> readInt8;
Function<Int> readUInt8;
Function<Int> readInt16;
Function<Int> readUInt16;
Function<Int> readInt32;
Function<Int> readUInt32;
Function<Float> readFloat;
Function<String> readString;
Property<Int> bitsUsed;
Property<Int> bytesUsed;
};
}
#endif

View File

@@ -0,0 +1,30 @@
#include <CommonHeader.h>
#include "Sky.h"
namespace nonut
{
Sky* Sky::get()
{
if (inst == nullptr)
{
inst = new Sky();
}
return inst;
}
Sky::Sky() :
StaticClass("Sky"),
PROPERTY_CTOR(weather),
PROPERTY_CTOR(raining),
PROPERTY_CTOR(renderLightning),
PROPERTY_CTOR(windScale),
PROPERTY_CTOR(dontRain),
METHOD_CTOR(getRainStartTime),
METHOD_CTOR(getRainStopTime),
METHOD_CTOR(setRainStartTime),
METHOD_CTOR(setRainStopTime)
{
}
}

View File

@@ -0,0 +1,34 @@
#ifndef _SKY_H_
#define _SKY_H_
#include <string>
#include <StaticClass.h>
#include <CustomTypes.h>
namespace nonut
{
class Sky : public StaticClass
{
public:
static Sky* get();
Function<void, Int, Int> setRainStartTime;
Function<SqDict> getRainStartTime;
Function<void, Int, Int> setRainStopTime;
Function<SqDict> getRainStopTime;
Property<Int> weather;
Property<Bool> raining;
Property<Bool> renderLightning;
Property<Float> windScale;
Property<Bool> dontRain;
private:
static inline Sky* inst = nullptr;
Sky();
};
}
#endif

View File

@@ -0,0 +1,26 @@
#include <CommonHeader.h>
#include "Way.h"
namespace nonut
{
Way::Way(String world, String startWp, String endWp) :
Class("Way"),
METHOD_CTOR(getWaypoints),
METHOD_CTOR(getCountWaypoints),
PROPERTY_CTOR(start),
PROPERTY_CTOR(end)
{
classCtor(world, startWp, endWp);
}
Way::Way(SQObject object) :
Class("Way", object),
METHOD_CTOR(getWaypoints),
METHOD_CTOR(getCountWaypoints),
PROPERTY_CTOR(start),
PROPERTY_CTOR(end)
{
}
}

View File

@@ -0,0 +1,24 @@
#ifndef _WAY_H
#define _WAY_H
#include <string>
#include <Class.h>
#include <CustomTypes.h>
namespace nonut
{
class Way : public Class
{
public:
Way(String, String, String);
explicit Way(SQObject object);
Property<String> start;
Property<String> end;
Function<SqList> getWaypoints;
Function<Int> getCountWaypoints;
};
}
#endif