1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00

implement getPCRank. Does not work yet.

This commit is contained in:
gugus 2012-04-15 12:05:46 +02:00
parent 6674dabd5a
commit 45a5877b23
2 changed files with 57 additions and 2 deletions

View File

@ -26,8 +26,10 @@ op 0x20009: LoopAnim, explicit reference
op 0x2000a: Choice
op 0x2000b: PCRaiseRank
op 0x2000c: PCLowerRank
op x20000d: PCJoinFaction
opcodes 0x2000e-0x3ffff unused
op 0x2000d: PCJoinFaction
op 0x2000e: PCGetRank implicit
op 0x2000f: PCGetRank explicit
opcodes 0x20010-0x3ffff unused
Segment 4:
(not implemented yet)

View File

@ -435,6 +435,54 @@ namespace MWScript
}
};
template<class R>
class OpGetPCRank : public Interpreter::Opcode1
{
public:
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{
MWWorld::Ptr ptr = R()(runtime);
runtime.pop();
std::string factionID = "";
if(arg0 >0)
{
factionID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
}
else
{
if(MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.empty())
{
//throw exception?
}
else
{
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.begin()->first;
}
}
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer();
if(factionID!="")
{
if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end())
{
runtime.push(MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID]);
}
else
{
runtime.push(-1);
}
}
else
{
runtime.push(-1);
}
}
};
template<class R>
class OpModDisposition : public Interpreter::Opcode0
{
@ -492,6 +540,8 @@ namespace MWScript
const int opcodePCRaiseRank = 0x2000b;
const int opcodePCLowerRank = 0x2000c;
const int opcodePCJoinFaction = 0x2000d;
const int opcodeGetPCRank = 0x2000e;
const int opcodeGetPCRankExplicit = 0x2000f;
const int opcodeModDisposition = 0x200014d;
const int opcodeModDispositionExplicit = 0x200014e;
@ -576,6 +626,7 @@ namespace MWScript
extensions.registerInstruction("pcjoinfaction","/S",opcodePCJoinFaction);
extensions.registerInstruction("moddisposition","l",opcodeModDisposition,
opcodeModDispositionExplicit);
extensions.registerFunction("getpcrank",'l',"/S",opcodeGetPCRank,opcodeGetPCRankExplicit);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
@ -645,6 +696,8 @@ namespace MWScript
interpreter.installSegment3(opcodePCJoinFaction,new OpPCJoinFaction);
interpreter.installSegment5(opcodeModDisposition,new OpModDisposition<ImplicitRef>);
interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition<ExplicitRef>);
interpreter.installSegment3(opcodeGetPCRank,new OpGetPCRank<ImplicitRef>);
interpreter.installSegment3(opcodeGetPCRankExplicit,new OpGetPCRank<ExplicitRef>);
}
}
}