1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

code formatting

This commit is contained in:
greye 2012-08-29 21:35:06 +04:00
parent 75fa0288a3
commit a90547bbbe
12 changed files with 184 additions and 177 deletions

View file

@ -61,10 +61,10 @@ namespace MWClass
data->mCreatureStats.setLevel(ref->base->data.level);
data->mCreatureStats.setHello(ref->base->AI.hello);
data->mCreatureStats.setFight(ref->base->AI.fight);
data->mCreatureStats.setFlee(ref->base->AI.flee);
data->mCreatureStats.setAlarm(ref->base->AI.alarm);
data->mCreatureStats.setHello(ref->base->mAiData.mHello);
data->mCreatureStats.setFight(ref->base->mAiData.mFight);
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
// store
ptr.getRefData().setCustomData (data.release());

View file

@ -100,10 +100,10 @@ namespace MWClass
/// \todo do something with npdt12 maybe:p
}
data->mCreatureStats.setHello(ref->base->AI.hello);
data->mCreatureStats.setFight(ref->base->AI.fight);
data->mCreatureStats.setFlee(ref->base->AI.flee);
data->mCreatureStats.setAlarm(ref->base->AI.alarm);
data->mCreatureStats.setHello(ref->base->mAiData.mHello);
data->mCreatureStats.setFight(ref->base->mAiData.mFight);
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
// store
ptr.getRefData().setCustomData (data.release());

View file

@ -769,14 +769,14 @@ namespace MWDialogue
if (mActor.getTypeName() == typeid(ESM::NPC).name())
{
MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>();
if (ref->base->hasAI)
services = ref->base->AI.services;
if (ref->base->mHasAI)
services = ref->base->mAiData.mServices;
}
else if (mActor.getTypeName() == typeid(ESM::Creature).name())
{
MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>();
if (ref->base->hasAI)
services = ref->base->AI.services;
if (ref->base->mHasAI)
services = ref->base->mAiData.mServices;
}
if (services & ESM::NPC::Weapon

View file

@ -291,14 +291,14 @@ namespace MWGui
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
{
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
if (ref->base->hasAI)
services = ref->base->AI.services;
if (ref->base->mHasAI)
services = ref->base->mAiData.mServices;
}
else if (mPtr.getTypeName() == typeid(ESM::Creature).name())
{
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
if (ref->base->hasAI)
services = ref->base->AI.services;
if (ref->base->mHasAI)
services = ref->base->mAiData.mServices;
}
/// \todo what about potions, there doesn't seem to be a flag for them??

View file

@ -43,7 +43,7 @@ add_component_dir (esm
loadclas loadclot loadcont loadcrea loadcrec loaddial loaddoor loadench loadfact loadglob loadgmst
loadinfo loadingr loadland loadlevlist loadligh loadlocks loadltex loadmgef loadmisc loadnpcc
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
loadweap records
loadweap records aipackage
)
add_component_dir (misc

View file

@ -0,0 +1,37 @@
#include "aipackage.hpp"
namespace ESM
{
void AIPackageList::load(ESMReader &esm)
{
while (esm.hasMoreSubs()) {
// initialize every iteration
AIPackage pack;
esm.getSubName();
if (esm.retSubName() == 0x54444e43) { // CNDT
mList.back().mCellName = esm.getHString();
} else if (esm.retSubName() == AI_Wander) {
pack.mType = AI_Wander;
esm.getHExact(&pack.mWander, 14);
mList.push_back(pack);
} else if (esm.retSubName() == AI_Travel) {
pack.mType = AI_Travel;
esm.getHExact(&pack.mTravel, 16);
mList.push_back(pack);
} else if (esm.retSubName() == AI_Escort ||
esm.retSubName() == AI_Follow)
{
pack.mType =
(esm.retSubName() == AI_Escort) ? AI_Escort : AI_Follow;
esm.getHExact(&pack.mTarget, 48);
mList.push_back(pack);
} else if (esm.retSubName() == AI_Activate) {
pack.mType = AI_Activate;
esm.getHExact(&pack.mActivate, 33);
mList.push_back(pack);
} else { // not AI package related data, so leave
return;
}
}
}
}

View file

@ -0,0 +1,95 @@
#ifndef OPENMW_ESM_AIPACKAGE_H
#define OPENMW_ESM_AIPACKAGE_H
#include "esm_reader.hpp"
#include <vector>
namespace ESM
{
#pragma pack(push)
#pragma pack(1)
struct AIData
{
// These are probabilities
char mHello, mU1, mFight, mFlee, mAlarm, mU2, mU3, mU4;
// The last u's might be the skills that this NPC can train you
// in?
int mServices; // See the Services enum
}; // 12 bytes
struct AIWander
{
short mDistance;
short mDuration;
unsigned char mTimeOfDay;
unsigned char mIdle[8];
unsigned char mUnk;
};
struct AITravel
{
float mX, mY, mZ;
long mUnk;
};
struct AITarget
{
float mX, mY, mZ;
short mDuration;
NAME32 mId;
short mUnk;
};
struct AIActivate
{
NAME32 mName;
unsigned char mUnk;
};
#pragma pack(pop)
enum
{
AI_Wander = 0x575f4941,
AI_Travel = 0x545f4941,
AI_Follow = 0x465f4941,
AI_Escort = 0x455f4941,
AI_Activate = 0x415f4941,
};
/// \note Used for storaging packages in a single container
/// w/o manual memory allocation accordingly to policy standards
struct AIPackage
{
int mType;
// Anonymous union
union
{
AIWander mWander;
AITravel mTravel;
AITarget mTarget;
AIActivate mActivate;
};
/// \note for AITarget only, placed here to stick with union,
/// overhead should be not so awful
std::string mCellName;
};
struct AIPackageList
{
std::vector<AIPackage> mList;
/// \note This breaks consistency of subrecords reading:
/// after calling it subrecord name is already read, so
/// it needs to use retSubName() if needed. But, hey, there
/// is only one field left (XSCL) and only two records uses AI
void load(ESMReader &esm);
};
}
#endif

View file

@ -1,127 +0,0 @@
#ifndef _ESM_DEFS_AI_H
#define _ESM_DEFS_AI_H
#include "esm_reader.hpp"
#include <vector>
namespace ESM
{
#pragma pack(push)
#pragma pack(1)
struct AIDTstruct
{
// These are probabilities
char hello, u1, fight, flee, alarm, u2, u3, u4;
// The last u's might be the skills that this NPC can train you
// in?
int services; // See the Services enum
}; // 12 bytes
struct AIWander
{
short distance;
short duration;
char timeOfDay;
char idle[8];
char unk;
};
struct AITravel
{
float x, y, z;
long unk;
};
struct AITarget
{
float x, y, z;
short duration;
NAME32 id;
short unk;
};
struct AIActivate
{
NAME32 name;
char unk;
};
#pragma pack(pop)
enum
{
AI_Wander = 0x575f4941,
AI_Travel = 0x545f4941,
AI_Follow = 0x465f4941,
AI_Escort = 0x455f4941,
AI_Activate = 0x415f4941,
};
/// \note Used for storaging packages in a single container
/// w/o manual memory allocation accordingly to policy standards
struct AIPackage
{
int type;
// Anonymous union
union
{
AIWander wander;
AITravel travel;
AITarget target;
AIActivate activate;
};
/// \note for AITarget only, placed here to stick with union,
/// overhead should be not so awful
std::string cellName;
};
struct AIPackageList
{
std::vector<AIPackage> list;
/// \note This breaks consistency of subrecords reading:
/// after calling it subrecord name is already read, so
/// it needs to use retSubName() if needed. But, hey, there
/// is only one field left (XSCL) and only two records uses AI
void load(ESMReader &esm) {
while (esm.hasMoreSubs()) {
// initialize every iteration
AIPackage pack;
esm.getSubName();
if (esm.retSubName() == 0x54444e43) { // CNDT
list.back().cellName = esm.getHString();
} else if (esm.retSubName() == AI_Wander) {
pack.type = AI_Wander;
esm.getHExact(&pack.wander, 14);
list.push_back(pack);
} else if (esm.retSubName() == AI_Travel) {
pack.type = AI_Travel;
esm.getHExact(&pack.travel, 16);
list.push_back(pack);
} else if (esm.retSubName() == AI_Escort ||
esm.retSubName() == AI_Follow)
{
pack.type =
(esm.retSubName() == AI_Escort) ? AI_Escort : AI_Follow;
esm.getHExact(&pack.target, 48);
list.push_back(pack);
} else if (esm.retSubName() == AI_Activate) {
pack.type = AI_Activate;
esm.getHExact(&pack.activate, 33);
list.push_back(pack);
} else { // not AI package related data, so leave
return;
}
}
}
};
}
#endif

View file

@ -18,17 +18,17 @@ void Creature::load(ESMReader &esm, const std::string& id)
esm.getHNOT(scale, "XSCL");
inventory.load(esm);
spells.load(esm);
mSpells.load(esm);
if (esm.isNextSub("AIDT"))
{
esm.getHExact(&AI, sizeof(AI));
hasAI = true;
esm.getHExact(&mAiData, sizeof(mAiData));
mHasAI = true;
}
else
hasAI = false;
mHasAI = false;
aiPack.load(esm);
mAiPackage.load(esm);
esm.skipRecord();
}

View file

@ -4,7 +4,7 @@
#include "esm_reader.hpp"
#include "loadcont.hpp"
#include "defs.hpp"
#include "defs_ai.hpp"
#include "aipackage.hpp"
namespace ESM
{
@ -62,11 +62,11 @@ struct Creature
// Defined in loadcont.hpp
InventoryList inventory;
SpellList spells;
SpellList mSpells;
bool hasAI;
AIDTstruct AI;
AIPackageList aiPack;
bool mHasAI;
AIData mAiData;
AIPackageList mAiPackage;
std::string mId;

View file

@ -36,22 +36,22 @@ void NPC::load(ESMReader &esm, const std::string& id)
if (esm.isNextSub("AIDT"))
{
esm.getHExact(&AI, sizeof(AI));
hasAI = true;
esm.getHExact(&mAiData, sizeof(mAiData));
mHasAI= true;
}
else
hasAI = false;
mHasAI = false;
while (esm.isNextSub("DODT") || esm.isNextSub("DNAM")) {
if (esm.retSubName() == 0x54444f44) { // DODT struct
Dest dodt;
esm.getHExact(&dodt.pos, 24);
dest.push_back(dodt);
esm.getHExact(&dodt.mPos, 24);
mTransport.push_back(dodt);
} else if (esm.retSubName() == 0x4d414e44) { // DNAM struct
dest.back().cellName = esm.getHString();
mTransport.back().mCellName = esm.getHString();
}
}
aiPack.load(esm);
mAiPackage.load(esm);
esm.skipRecord();
}

View file

@ -4,7 +4,7 @@
#include "esm_reader.hpp"
#include "loadcont.hpp"
#include "defs.hpp"
#include "defs_ai.hpp"
#include "aipackage.hpp"
namespace ESM {
@ -76,8 +76,8 @@ struct NPC
struct Dest
{
Position pos;
std::string cellName;
Position mPos;
std::string mCellName;
};
NPDTstruct52 npdt52;
@ -88,14 +88,16 @@ struct NPC
InventoryList inventory;
SpellList spells;
AIDTstruct AI;
bool hasAI;
AIData mAiData;
bool mHasAI;
std::vector<Dest> dest;
AIPackageList aiPack;
std::vector<Dest> mTransport;
AIPackageList mAiPackage;
std::string name, model, race, cls, faction, script,
hair, head; // body parts
std::string name, model, race, cls, faction, script;
// body parts
std::string hair, head;
std::string mId;