/*
* AIM save_loader
* Copyright (C) 2016 lzwdgc
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#pragma once
#include
#include
#include
#include
#include
// possible save operations
struct changes
{
buffer out;
std::string mech_org;
float money = 0;
bool upgrade_equ_for_player = false;
void rewrite_mech_org(const buffer &b, std::string &org);
void rewrite_money(const buffer &b);
void rewrite_upgrade_equ_for_player(const buffer &b, uint32_t value);
};
extern changes save_changes;
// common structs
struct int_variable
{
std::string name;
uint32_t value;
void load(const buffer &b);
};
template
struct single_int
{
T val;
void load(const buffer &b)
{
READ(b, val);
}
};
struct single_string
{
std::string name;
void load(const buffer &b);
};
struct string_variable
{
std::string name;
std::string value;
void load(const buffer &b);
};
// segments
struct segment
{
virtual void load(const buffer &) = 0;
};
struct header_segment : public segment
{
uint32_t unk1[3];
std::string save_name;
vector3f position;
std::string mmp_file;
std::string location_name;
Common camera;
uint32_t unk2[7];
void load(const buffer &b);
};
struct string_segment : public segment
{
std::string s;
void load(const buffer &b);
};
struct screen_segment : public segment
{
mat screenshot{ 128, 128 };
void load(const buffer &b);
};
struct scripts_segment : public segment
{
struct script_entry
{
std::string name;
std::string path;
void load(const buffer &b);
};
struct script_entry_ext : public script_entry
{
uint32_t unk0[10];
void load(const buffer &b);
};
std::vector bases;
std::vector events;
std::vector unk0;
std::vector int_variables;
std::vector str_variables;
void load(const buffer &b);
};
// todo
struct radar_segment : public segment
{
struct radar
{
char unk0[0x1C4];
void load(const buffer &b);
};
struct mechanoid5
{
std::string name;
float unk0[6];
void load(const buffer &b);
};
std::vector radars;
uint16_t unk0;
std::vector mechanoid5s;
std::vector orgs;
void load(const buffer &b);
};
struct gamedata_segment : public segment
{
struct loc
{
float unk0;
uint32_t unk1[2];
std::string name;
void load(const buffer &b)
{
READ(b, unk0);
READ(b, unk1);
READ_STRING(b, name);
}
};
struct org
{
std::string name;
uint32_t unk0; // flags?
void load(const buffer &b)
{
READ_STRING(b, name);
READ(b, unk0);
}
};
struct unk0s
{
float unk0[2];
uint32_t unk1;
void load(const buffer &b)
{
READ(b, unk0);
READ(b, unk1);
}
};
struct unk1s
{
std::string name; // loc part?
char unk0[0xE0];
uint32_t unk1;
uint32_t unk2;
std::string location; // loc
void load(const buffer &b)
{
READ_STRING(b, name);
READ(b, unk0);
READ(b, unk1);
READ(b, unk2);
READ_STRING(b, location);
}
};
char unk00[0x5C];
std::vector locs;
std::vector orgs;
//uint32_t unk0;
std::vector unk1;
std::string base_name;
uint32_t unk2;
std::string user_name; // mech name?
std::vector unk3;
std::string icon; // clan icon?
uint32_t unk4;
void load(const buffer &b);
};
struct questlog_segment : public segment
{
struct record
{
std::string name;
std::string name_journal;
uint32_t unk0[2];
std::string endtime;
void load(const buffer &b);
};
uint32_t unk0;
std::vector int_variables;
std::vector events;
std::vector story_quests;
void load(const buffer &b);
};
struct trade_segment : public segment
{
struct Price
{
std::string tov_name;
uint32_t unk0;
float mass;
float price;
uint32_t notrade;
uint32_t type;
float unk1;
void load(const buffer &b);
};
struct BuildingPrice
{
std::string name;
std::vector prices;
uint32_t unk0;
void load(const buffer &b);
};
uint32_t unk0 = 0;
std::vector buildingPrices;
void load(const buffer &b);
};
struct env_segment : public segment
{
char unk0[0x151];
weather w;
void load(const buffer &b);
};
struct orgrel_segment : public segment
{
struct org_rep
{
char unk0[0x8];
bool unk1;
void load(const buffer &b);
};
std::vector org_reps;
void load(const buffer &b);
};
struct others_segment : public segment
{
uint32_t unk0;
uint32_t unk1;
void load(const buffer &b);
};
struct mech_segment : public segment
{
struct equipment
{
uint8_t id;
std::string name;
uint32_t unk0;
uint32_t unk1;
void load(const buffer &b);
};
struct moddable_equipment
{
std::string name;
ModificatorMask mask;
void load(const buffer &b);
};
struct moddable_equipment2
{
uint8_t id;
std::string name;
uint32_t unk0; // health?
ModificatorMask mask;
void load(const buffer &b);
};
struct hold_item
{
enum class Type : uint32_t
{
Good = 0,
Mechanoid = 2,
};
Type type;
std::string name;
uint32_t count;
uint32_t unk0;
uint32_t unk1;
void load(const buffer &b);
};
struct ammo
{
std::string name;
void load(const buffer &b);
};
struct ammo_count
{
std::string name;
uint32_t count;
void load(const buffer &b);
};
enum class MechFlags : uint32_t
{
unk0 = 0x00000001,
unk1 = 0x00000100,
Dead = 0x00010000,
Dead2 = 0x01000000,
};
struct mech
{
struct glider_desc
{
uint32_t unk15_1; // size of segment (glider_desc struct)
std::vector equipments;
float unk40;
uint32_t unk4[7];
// glider
// g_unk = glider unknown
// mask works only for weapons
moddable_equipment glider;
moddable_equipment weapon1;
moddable_equipment weapon2;
moddable_equipment reactor1;
moddable_equipment reactor2;
moddable_equipment engine1;
moddable_equipment engine2;
moddable_equipment energy_shield;
moddable_equipment armor;
uint32_t g_unk0;
uint32_t g_unk1 = 0;
uint32_t g_unk2;
std::vector ammos;
std::vector ammos1;
std::vector ammos2;
uint32_t g_unk3 = 0;
// mask works for all except uarmor
moddable_equipment2 ureactor1;
moddable_equipment2 ureactor2;
moddable_equipment2 uengine1;
moddable_equipment2 uengine2;
moddable_equipment2 uenergy_shield;
moddable_equipment2 uarmor;
//
moddable_equipment g_unk4;
ModificatorMask glider_mask;
std::vector ammos3;
float money;
std::vector items;
uint32_t g_unk6[28][3] = { 0 };
void load(const buffer &b);
};
uint8_t id;
std::string name;
std::string name2;
std::string org;
std::string building;
MechFlags flags;
uint8_t unk11;
float unk12[3];
uint32_t unk13[3];
uint8_t unk14;
uint32_t unk15;
uint32_t unk16 = 0;
glider_desc gl;
void load(const buffer &b);
bool isPlayer() const;
};
std::vector mechs;
void load(const buffer &b);
};
// todo
struct groups_segment : public segment
{
struct mech
{
std::string name;
uint32_t unk0;
float unk1[4];
uint32_t unk2[2];
float unk3;
void load(const buffer &b);
};
struct group
{
vector3f pos;
std::string org;
std::string base;
std::vector mechs;
void load(const buffer &b);
};
std::vector groups;
void load(const buffer &b);
};
struct orgdata_segment : public segment
{
struct org_config
{
std::vector names;
void load(const buffer &b);
};
struct orgdata
{
uint32_t unk0;
std::string org;
float unk1[4];
uint32_t unk2[2];
float rep[50];
std::vector configs;
void load(const buffer &b);
};
std::vector orgdatas;
void load(const buffer &b);
};
struct builds_segment : public segment
{
struct build
{
std::string bld;
std::string org;
float unk1;
void load(const buffer &b);
};
std::vector builds;
void load(const buffer &b);
};
struct orgs_segment : public segment
{
struct org
{
struct base
{
struct mech
{
std::string name;
void load(const buffer &b);
};
std::string name;
float unk2;
u8 unk3;
uint32_t unk4[2];
std::vector mechs;
// u32 n;
// u32 unk0[n];
std::string org;
u32 unk5;
f32 unk6;
void load(const buffer &b);
};
uint32_t unk0[9];
base base;
void load(const buffer &b);
};
std::vector orgs;
void load(const buffer &b);
};
struct tradeeqp_segment : public segment
{
struct Good
{
std::string tov_name;
uint32_t unk0;
uint32_t mask;
float price;
int32_t count;
float probability;
void load(const buffer &b);
};
struct bld
{
std::string name;
std::vector prices;
void load(const buffer &b);
};
uint32_t unk0 = 0;
std::vector prices;
std::vector blds;
void load(const buffer &b);
};
struct objects_segment : public segment
{
struct object
{
std::string owner; // empty for outdoor and outmech
u32 type;
u8 unk1;
u32 unk01;
vector3f coords;
u32 len0;
void load(const buffer &b);
};
std::vector