Several bugfixes related to the new Monster version

git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@101 ea6a568a-9f4f-0410-981a-c910a81bb256
actorid
nkorslund 16 years ago
parent cc1f7f02e9
commit fd79223cf7

@ -148,21 +148,26 @@ template LoadTT(T)
void makeProto(char[] clsName = null)
{
// Use the template type name as the Monster class name if none
// is specified.
if(clsName == "")
// Set up a prototype object
if(mc is null)
{
clsName = typeid(T).toString;
// Remove the module name
int i = clsName.rfind('.');
if(i != -1)
clsName = clsName[i+1..$];
// Use the template type name as the Monster class name if
// none is specified.
if(clsName == "")
{
clsName = typeid(T).toString;
// Remove the module name
int i = clsName.rfind('.');
if(i != -1)
clsName = clsName[i+1..$];
}
// All the game objects are in the 'game' package
clsName = "game." ~ clsName;
mc = vm.load(clsName);
}
// Set up a prototype object
if(mc is null)
mc = vm.load(clsName);
proto = mc.createObject();
proto.setString8("id", id);

@ -36,7 +36,7 @@ import esm.imports;
struct Activator
{
mixin LoadT!();
mixin LoadT;
Script *script;
MeshIndex model;

@ -1097,6 +1097,9 @@ class PackageImpHolder : ImportHolder
{
sc = psc;
assert(sc !is null);
type = psc.type;
assert(type !is null);
}
override:

@ -520,7 +520,7 @@ class DotOperator : OperatorExpr
owner.resolve(sc);
Type ot = owner.type;
assert(ot !is null);
assert(ot !is null, "owner " ~ owner.toString ~ " has no type!");
ot.getMemberScope();

@ -613,6 +613,11 @@ class MemberExpr : Expression
if(isType)
return true;
// Singletons are also static members (of packages), even if the
// type is not a meta type
if(singCls != -1)
return true;
// Ditto for packages
if(isPackage)
return true;
@ -911,7 +916,7 @@ class MemberExpr : Expression
// only push the index.
tasm.pushFarClass(var.number, var.sc.getClass().getTreeIndex(), s);
else assert(0);
else assert(0, "called evalAsm on " ~ toString());
}
// Push the address of the variable rather than its value

@ -952,7 +952,7 @@ final class MonsterClass
void createScope()
{
// Since debugging self inheritance can be a little icky, add an
// explisit recursion check.
// explicit recursion check.
assert(!flags.has(CFlags.InScope), "createScope called recursively");
flags.set(CFlags.InScope);
@ -968,9 +968,15 @@ final class MonsterClass
parents.length = parentNames.length;
foreach(int i, pName; parentNames)
{
// Find the class. vm.load() returns the existing class if
// it has already been loaded.
MonsterClass mc = vm.load(pName.str);
// Find the parent class.
assert(pack !is null);
auto sl = pack.lookupClass(pName);
if(!sl.isClass)
fail("Cannot inherit from " ~ pName.str ~ ": No such class.",
pName.loc);
auto mc = sl.mc;
assert(mc !is null);
//MonsterClass mc = vm.load(pName.str);
mc.requireScope();
assert(mc !is null);

@ -345,7 +345,7 @@ struct VM
fail(format("Invalid class name %s (file %s)", cname, fname));
// At this point, check if the class already exists.
if(global.ciInList(cname, mc))
if(pack.ciInList(cname, mc))
{
// Match!
assert(mc !is null);

@ -35,6 +35,8 @@ float mouseSensX;
float mouseSensY;
bool flipMouseY;
import sound;
// TODO: This could be replaced by some sort of hook placed on
// mainVolume. Writing to the variable would automatically update
// everything.

@ -27,8 +27,8 @@ class Apparatus : InventoryItem;
enum AppaType : char[] altName
{
MortarPestle = 0 : "Mortar and Pestle",
Albemic = 1,
Calcinator = 2
Albemic = 1 : "Albemic"
Calcinator = 2 : "Calcinator"
}
float quality;

@ -49,7 +49,7 @@ char[] name, id;
char[] owner;
// A global variable? Don't know what it's used for.
char[] global;
char[] glob;
// Reference to a soul trapped creature?
char[] soulID;
@ -61,10 +61,8 @@ int indx;
// Magic value / health / uses of an item?
float xchg;
// ?? See comment below
// These depend on the item in question
int intv, nam9;
// ??
int fltv;
int unam;

@ -37,8 +37,6 @@ void initMonsterScripts()
{
// Add the script directories
vm.addPath("mscripts/");
vm.addPath("mscripts/gameobjects/");
vm.addPath("mscripts/sound/");
// Import some modules into the global scope, so we won't have to
// import them manually in each script.

@ -4,7 +4,7 @@
Email: < korslund@gmail.com >
WWW: http://openmw.snaptoad.com/
This file (jukebox.mn) is part of the OpenMW package.
This file (music.mn) is part of the OpenMW package.
OpenMW is distributed as free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License

@ -163,6 +163,7 @@ struct MeshLoader
auto pc = cast(NiPathController)data.controller;
if(kc !is null)
{
/*
writefln("Found keyframe controller");
writefln(" Node name was: %s", data.name);
assert(cont.target is data);
@ -170,6 +171,7 @@ struct MeshLoader
auto kcd = kc.data;
writefln(" Types: %s %s %s",
kcd.rotType, kcd.traType, kcd.scaleType);
*/
/*
Adding keyframes:
@ -189,7 +191,7 @@ struct MeshLoader
}
else if(pc !is null)
{
writefln("Found path controller");
//writefln("Found path controller");
assert(cont.target is data);
}
else writefln("Other controller (%s)", cont);

@ -465,24 +465,24 @@ class CellData
else fail(format(" UNKNOWN REFERENCE! Type ", cast(int)it.i.type));
// Now that the object has found it's place, load data
// into base.
// into the object.
with(*mo)
{
// Scale. Multiply with the existing scale value.
float scale = getFloat("scale");
setFloat("scale", scale*getHNOFloat("XSCL", 1.0));
float *scale = getFloatPtr("scale");
*scale *= getHNOFloat("XSCL", 1.0);
// Statics only need the position data. Skip the
// unneeded calls to isNextSub() as an optimization.
// Statics only need the position data. Skip the rest
// as an optimization.
if(stat) goto readpos;
// An NPC that owns this object (and will get angry if
// you steal it)
// The NPC that owns this object (and will get angry
// if you steal it)
setString8("owner", getHNOString("ANAM"));
// I have no idea, link to a global variable perhaps?
setString8("global", getHNOString("BNAM"));
setString8("glob", getHNOString("BNAM"));
// ID of creature trapped in a soul gem (?)
setString8("soulID", getHNOString("XSOL"));

@ -68,7 +68,7 @@ struct Music
assert(controlC is null);
assert(controlM is null);
jukeC = vm.load("Jukebox");
jukeC = vm.load("sound.Jukebox");
jukeC.bind("waitUntilFinished",
new Idle_waitUntilFinished);
@ -79,7 +79,7 @@ struct Music
jukeC.bindConst({new Jukebox(params.obj()); });
controlC = vm.load("Music");
controlC = vm.load("sound.Music");
controlM = controlC.getSing();
controlM.call("setup");
}

Loading…
Cancel
Save