mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
Switch to CTable class.
This commit is contained in:
parent
e93b472416
commit
f0388c4b33
6 changed files with 82 additions and 61 deletions
|
|
@ -21,8 +21,11 @@ else()
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
|
||||
endif(MSVC)
|
||||
|
||||
include_directories(../DatabaseManager/include)
|
||||
add_subdirectory(../DatabaseManager DatabaseManager)
|
||||
if (NOT DATABASE_MANAGER_DIR)
|
||||
message(FATAL_ERROR "Please, set DATABASE_MANAGER_DIR variable")
|
||||
endif()
|
||||
add_subdirectory(${DATABASE_MANAGER_DIR} DatabaseManager)
|
||||
include_directories(${DATABASE_MANAGER_DIR}/include)
|
||||
set_target_properties(sqlite3 PROPERTIES FOLDER Extern)
|
||||
set_target_properties(DatabaseManager PROPERTIES FOLDER Extern)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
file(GLOB common_src "*.h" "*.cpp")
|
||||
add_library(common ${common_src})
|
||||
add_library(common ${common_src})
|
||||
add_dependencies(common version)
|
||||
|
|
@ -7,7 +7,11 @@ import subprocess
|
|||
|
||||
banned_ext = [
|
||||
'.obj',
|
||||
'.txt'
|
||||
'.mtl',
|
||||
'.txt',
|
||||
'.tm',
|
||||
'.TM',
|
||||
'.tga',
|
||||
]
|
||||
|
||||
def main():
|
||||
|
|
@ -22,7 +26,7 @@ def run(dir):
|
|||
for file in sorted(os.listdir(dir)):
|
||||
if os.path.isdir(file) or os.path.splitext(file)[1] in banned_ext:
|
||||
continue
|
||||
p = subprocess.Popen(['mod_converter.exe', dir + '/' + file])
|
||||
p = subprocess.Popen(['mod_converter.exe', '-m', dir + '/' + file])
|
||||
p.communicate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
#include "objects.h"
|
||||
#include "other.h"
|
||||
|
||||
|
|
@ -31,6 +34,8 @@
|
|||
|
||||
#include <common.h>
|
||||
|
||||
#define RAD2GRAD(x) (x) = (x) / M_PI * 100.0
|
||||
|
||||
using namespace std;
|
||||
|
||||
std::string prefix;
|
||||
|
|
@ -40,10 +45,10 @@ struct storage
|
|||
{
|
||||
string name;
|
||||
Objects objects;
|
||||
MechGroups mgs;
|
||||
MapGoods mg;
|
||||
MapMusic mm;
|
||||
MapSounds ms;
|
||||
MechGroups mechGroups;
|
||||
MapGoods mapGoods;
|
||||
MapMusic mapMusic;
|
||||
MapSounds mapSounds;
|
||||
// aim2
|
||||
Organizations orgs;
|
||||
OrganizationBases orgsBases;
|
||||
|
|
@ -52,12 +57,12 @@ struct storage
|
|||
void load(buffer &b)
|
||||
{
|
||||
objects.load(b);
|
||||
mgs.load(b);
|
||||
mechGroups.load(b);
|
||||
if (b.eof()) // custom maps
|
||||
return;
|
||||
mg.load(b);
|
||||
mm.load(b);
|
||||
ms.load(b);
|
||||
mapGoods.load(b);
|
||||
mapMusic.load(b);
|
||||
mapSounds.load(b);
|
||||
if (gameType == GameType::Aim2)
|
||||
{
|
||||
orgs.load(b);
|
||||
|
|
@ -144,7 +149,7 @@ void write_mmo(string db, const storage &s)
|
|||
bld_ids[o] = bld->getId();
|
||||
}
|
||||
else
|
||||
bld_ids[o] = iter->second->getId();
|
||||
bld_ids[o] = iter->getId();
|
||||
}
|
||||
for (auto &object : segment->objects)
|
||||
{
|
||||
|
|
@ -155,9 +160,13 @@ void write_mmo(string db, const storage &s)
|
|||
mb.x = object.position.x;
|
||||
mb.y = object.position.y;
|
||||
mb.z = object.position.z;
|
||||
mb.yaw = atan2(object.m_rotate_z[1].x, object.m_rotate_z[0].x);
|
||||
mb.pitch = atan2(-object.m_rotate_z[2].x, sqrt(object.m_rotate_z[2].y * object.m_rotate_z[2].y + object.m_rotate_z[2].z * object.m_rotate_z[2].z));
|
||||
mb.roll = atan2(object.m_rotate_z[2].y, object.m_rotate_z[2].z);
|
||||
mb.pitch = atan2(-object.m_rotate_z[2].x, sqrt(object.m_rotate_z[2].y * object.m_rotate_z[2].y + object.m_rotate_z[2].z * object.m_rotate_z[2].z));
|
||||
mb.yaw = atan2(object.m_rotate_z[1].x, object.m_rotate_z[0].x);
|
||||
// to grad
|
||||
RAD2GRAD(mb.roll);
|
||||
RAD2GRAD(mb.pitch);
|
||||
RAD2GRAD(mb.yaw);
|
||||
auto i = find_if(storage->mapBuildings.begin(), storage->mapBuildings.end(), [&](const decltype(Storage::mapBuildings)::value_type &p)
|
||||
{
|
||||
return *p.second.get() == mb;
|
||||
|
|
@ -192,7 +201,7 @@ void write_mmo(string db, const storage &s)
|
|||
bld_ids[o] = bld->getId();
|
||||
}
|
||||
else
|
||||
bld_ids[o] = iter->second->getId();
|
||||
bld_ids[o] = iter->getId();
|
||||
}
|
||||
for (auto &object : segment->objects)
|
||||
{
|
||||
|
|
@ -203,9 +212,13 @@ void write_mmo(string db, const storage &s)
|
|||
mb.x = object.position.x;
|
||||
mb.y = object.position.y;
|
||||
mb.z = object.position.z;
|
||||
mb.yaw = atan2(object.m_rotate_z[1].x, object.m_rotate_z[0].x);
|
||||
mb.pitch = atan2(-object.m_rotate_z[2].x, sqrt(object.m_rotate_z[2].y * object.m_rotate_z[2].y + object.m_rotate_z[2].z * object.m_rotate_z[2].z));
|
||||
mb.roll = atan2(object.m_rotate_z[2].y, object.m_rotate_z[2].z);
|
||||
mb.pitch = atan2(-object.m_rotate_z[2].x, sqrt(object.m_rotate_z[2].y * object.m_rotate_z[2].y + object.m_rotate_z[2].z * object.m_rotate_z[2].z));
|
||||
mb.yaw = atan2(object.m_rotate_z[1].x, object.m_rotate_z[0].x);
|
||||
// to grad
|
||||
RAD2GRAD(mb.roll);
|
||||
RAD2GRAD(mb.pitch);
|
||||
RAD2GRAD(mb.yaw);
|
||||
auto i = find_if(storage->mapObjects.begin(), storage->mapObjects.end(), [&](const decltype(Storage::mapObjects)::value_type &p)
|
||||
{
|
||||
return *p.second.get() == mb;
|
||||
|
|
@ -227,7 +240,7 @@ try
|
|||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
cout << "Usage:\n" << argv[0] << " db.sqlite file.mmo" << "\n";
|
||||
cout << "Usage:\n" << argv[0] << " db.sqlite file.mmo prefix" << "\n";
|
||||
return 1;
|
||||
}
|
||||
prefix = argv[3];
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ enum class SegmentType : uint32_t
|
|||
struct Segment
|
||||
{
|
||||
SegmentType segment_type;
|
||||
uint32_t segment_len;
|
||||
uint32_t n_objects;
|
||||
uint32_t segment_len = 0;
|
||||
uint32_t n_objects = 0;
|
||||
|
||||
virtual ~Segment(){}
|
||||
static Segment *create_segment(buffer &b);
|
||||
|
|
@ -92,10 +92,10 @@ struct SegmentObjects : public Segment
|
|||
|
||||
struct Vector4
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
float w = 0;
|
||||
};
|
||||
|
||||
struct Common
|
||||
|
|
@ -126,7 +126,7 @@ struct MapObject : public Common
|
|||
|
||||
struct MapObjectWithArray : public MapObject
|
||||
{
|
||||
uint32_t len;
|
||||
uint32_t len = 0;
|
||||
vector<uint32_t> unk7;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -179,7 +179,7 @@ UNKNOWN_OBJECT(unk1);
|
|||
|
||||
struct Objects
|
||||
{
|
||||
uint32_t n_segments;
|
||||
uint32_t n_segments = 0;
|
||||
vector<Segment *> segments;
|
||||
|
||||
void load(buffer &b);
|
||||
|
|
|
|||
|
|
@ -40,19 +40,19 @@ struct MechGroup
|
|||
{
|
||||
char name[0x20];
|
||||
char org[0x20];
|
||||
uint32_t type1;
|
||||
uint32_t len1;
|
||||
uint32_t type1 = 0;
|
||||
uint32_t len1 = 0;
|
||||
char name1[0x70];
|
||||
//{3,4
|
||||
uint32_t unk30;
|
||||
uint32_t unk30 = 0;
|
||||
//}
|
||||
//{2
|
||||
uint32_t len;
|
||||
uint32_t len = 0;
|
||||
vector<uint32_t> unk11;
|
||||
//}
|
||||
//{1,0
|
||||
uint32_t unk20;
|
||||
uint32_t unk21;
|
||||
uint32_t unk20 = 0;
|
||||
uint32_t unk21 = 0;
|
||||
//}
|
||||
vector<string> configs;
|
||||
char unk100;
|
||||
|
|
@ -91,8 +91,8 @@ struct MechGroup
|
|||
|
||||
struct MechGroups
|
||||
{
|
||||
uint32_t length;
|
||||
uint32_t n;
|
||||
uint32_t length = 0;
|
||||
uint32_t n = 0;
|
||||
char prefix[0x30];
|
||||
|
||||
vector<MechGroup> mgs;
|
||||
|
|
@ -117,8 +117,8 @@ struct Good
|
|||
{
|
||||
char name[0x20];
|
||||
char unk1[0x40];
|
||||
uint32_t unk1_2;
|
||||
float price;
|
||||
uint32_t unk1_2 = 0;
|
||||
float price = 0;
|
||||
float unk2[10];
|
||||
float unk2_2[4];
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ struct Good
|
|||
struct BuildingGoods
|
||||
{
|
||||
char name[0x20];
|
||||
uint32_t n;
|
||||
uint32_t n = 0;
|
||||
|
||||
vector<Good> goods;
|
||||
|
||||
|
|
@ -160,10 +160,10 @@ struct BuildingGoods
|
|||
|
||||
struct MapGoods
|
||||
{
|
||||
uint32_t length;
|
||||
uint32_t unk2;
|
||||
uint32_t unk3;
|
||||
uint32_t n;
|
||||
uint32_t length = 0;
|
||||
uint32_t unk2 = 0;
|
||||
uint32_t unk3 = 0;
|
||||
uint32_t n = 0;
|
||||
|
||||
vector<BuildingGoods> bgs;
|
||||
|
||||
|
|
@ -188,14 +188,14 @@ struct MapGoods
|
|||
|
||||
struct MapMusic
|
||||
{
|
||||
uint32_t unk1;
|
||||
uint32_t unk1 = 0;
|
||||
char name1[0x20];
|
||||
char name2[0x20];
|
||||
|
||||
uint32_t n1;
|
||||
uint32_t n1 = 0;
|
||||
vector<string> names1;
|
||||
|
||||
uint32_t n2;
|
||||
uint32_t n2 = 0;
|
||||
vector<string> names2;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -226,7 +226,7 @@ struct MapSound
|
|||
{
|
||||
char name[0x20];
|
||||
float unk1[4];
|
||||
uint32_t unk2;
|
||||
uint32_t unk2 = 0;
|
||||
float unk3[4];
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -240,7 +240,7 @@ struct MapSound
|
|||
|
||||
struct MapSounds
|
||||
{
|
||||
uint32_t n;
|
||||
uint32_t n = 0;
|
||||
vector<MapSound> sounds;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -257,7 +257,7 @@ struct MapSounds
|
|||
|
||||
struct OrganizationConfig
|
||||
{
|
||||
uint32_t n_configs;
|
||||
uint32_t n_configs = 0;
|
||||
vector<string> configs;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -271,7 +271,7 @@ struct OrganizationConfig
|
|||
|
||||
struct Organization
|
||||
{
|
||||
uint32_t unk0;
|
||||
uint32_t unk0 = 0;
|
||||
char name[0x20];
|
||||
char unk1[0xE0];
|
||||
OrganizationConfig configs[3];
|
||||
|
|
@ -288,8 +288,8 @@ struct Organization
|
|||
|
||||
struct Organizations
|
||||
{
|
||||
uint32_t len;
|
||||
uint32_t n;
|
||||
uint32_t len = 0;
|
||||
uint32_t n = 0;
|
||||
vector<Organization> organizations;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -309,7 +309,7 @@ struct OrganizationBase
|
|||
{
|
||||
char base_name[0x20];
|
||||
char org_name[0x20];
|
||||
uint32_t unk0;
|
||||
uint32_t unk0 = 0;
|
||||
|
||||
void load(buffer &b)
|
||||
{
|
||||
|
|
@ -321,7 +321,7 @@ struct OrganizationBase
|
|||
|
||||
struct OrganizationBases
|
||||
{
|
||||
uint32_t n;
|
||||
uint32_t n = 0;
|
||||
vector<OrganizationBase> organizationBases;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -339,8 +339,8 @@ struct OrganizationBases
|
|||
struct Price
|
||||
{
|
||||
char tov_name[0x20];
|
||||
uint32_t unk0;
|
||||
uint32_t unk1;
|
||||
uint32_t unk0 = 0;
|
||||
uint32_t unk1 = 0;
|
||||
float unk2[3];
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -355,7 +355,7 @@ struct Price
|
|||
struct BuildingPrice
|
||||
{
|
||||
char name[0x20];
|
||||
uint32_t n_tov;
|
||||
uint32_t n_tov = 0;
|
||||
vector<Price> prices;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -373,9 +373,9 @@ struct BuildingPrice
|
|||
|
||||
struct BuildingPrices
|
||||
{
|
||||
uint32_t n_tov;
|
||||
uint32_t n_tov = 0;
|
||||
vector<Price> prices;
|
||||
uint32_t n_bases;
|
||||
uint32_t n_bases = 0;
|
||||
vector<BuildingPrice> buildingPrices;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
@ -399,8 +399,8 @@ struct BuildingPrices
|
|||
|
||||
struct Prices
|
||||
{
|
||||
uint32_t len;
|
||||
uint32_t unk0;
|
||||
uint32_t len = 0;
|
||||
uint32_t unk0 = 0;
|
||||
BuildingPrices buildingPrices;
|
||||
|
||||
void load(buffer &b)
|
||||
|
|
|
|||
Loading…
Reference in a new issue