From fd79223cf72eacffa7fadb93f158a0680740e03d Mon Sep 17 00:00:00 2001 From: nkorslund Date: Wed, 6 May 2009 06:39:41 +0000 Subject: [PATCH] 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 --- esm/defs.d | 31 +++++++++++-------- esm/loadacti.d | 2 +- monster/compiler/expression.d | 3 ++ monster/compiler/operators.d | 2 +- monster/compiler/variables.d | 7 ++++- monster/vm/mclass.d | 14 ++++++--- monster/vm/vm.d | 2 +- mscripts/config.mn | 2 ++ mscripts/{gameobjects => game}/activator.mn | 0 mscripts/{gameobjects => game}/actor.mn | 0 mscripts/{gameobjects => game}/apparatus.mn | 4 +-- mscripts/{gameobjects => game}/armor.mn | 0 mscripts/{gameobjects => game}/book.mn | 0 mscripts/{gameobjects => game}/clothing.mn | 0 mscripts/{gameobjects => game}/container.mn | 0 mscripts/{gameobjects => game}/creature.mn | 0 mscripts/{gameobjects => game}/door.mn | 0 mscripts/{gameobjects => game}/enchantitem.mn | 0 mscripts/{gameobjects => game}/gameobject.mn | 6 ++-- mscripts/{gameobjects => game}/ingredient.mn | 0 .../{gameobjects => game}/inventoryitem.mn | 0 mscripts/{gameobjects => game}/light.mn | 0 .../{gameobjects => game}/lockedobject.mn | 0 mscripts/{gameobjects => game}/lockpick.mn | 0 mscripts/{gameobjects => game}/misc.mn | 0 mscripts/{gameobjects => game}/person.mn | 0 mscripts/{gameobjects => game}/potion.mn | 0 mscripts/{gameobjects => game}/probe.mn | 0 mscripts/{gameobjects => game}/repairable.mn | 0 mscripts/{gameobjects => game}/repairitem.mn | 0 mscripts/{gameobjects => game}/static.mn | 0 mscripts/{gameobjects => game}/tool.mn | 0 mscripts/{gameobjects => game}/weapon.mn | 0 mscripts/setup.d | 2 -- mscripts/sound/music.mn | 2 +- ogre/meshloader.d | 4 ++- scene/celldata.d | 16 +++++----- sound/music.d | 4 +-- 38 files changed, 60 insertions(+), 41 deletions(-) rename mscripts/{gameobjects => game}/activator.mn (100%) rename mscripts/{gameobjects => game}/actor.mn (100%) rename mscripts/{gameobjects => game}/apparatus.mn (93%) rename mscripts/{gameobjects => game}/armor.mn (100%) rename mscripts/{gameobjects => game}/book.mn (100%) rename mscripts/{gameobjects => game}/clothing.mn (100%) rename mscripts/{gameobjects => game}/container.mn (100%) rename mscripts/{gameobjects => game}/creature.mn (100%) rename mscripts/{gameobjects => game}/door.mn (100%) rename mscripts/{gameobjects => game}/enchantitem.mn (100%) rename mscripts/{gameobjects => game}/gameobject.mn (97%) rename mscripts/{gameobjects => game}/ingredient.mn (100%) rename mscripts/{gameobjects => game}/inventoryitem.mn (100%) rename mscripts/{gameobjects => game}/light.mn (100%) rename mscripts/{gameobjects => game}/lockedobject.mn (100%) rename mscripts/{gameobjects => game}/lockpick.mn (100%) rename mscripts/{gameobjects => game}/misc.mn (100%) rename mscripts/{gameobjects => game}/person.mn (100%) rename mscripts/{gameobjects => game}/potion.mn (100%) rename mscripts/{gameobjects => game}/probe.mn (100%) rename mscripts/{gameobjects => game}/repairable.mn (100%) rename mscripts/{gameobjects => game}/repairitem.mn (100%) rename mscripts/{gameobjects => game}/static.mn (100%) rename mscripts/{gameobjects => game}/tool.mn (100%) rename mscripts/{gameobjects => game}/weapon.mn (100%) diff --git a/esm/defs.d b/esm/defs.d index b76d167a02..337db02fc3 100644 --- a/esm/defs.d +++ b/esm/defs.d @@ -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 == "") - { - clsName = typeid(T).toString; - - // Remove the module name - int i = clsName.rfind('.'); - if(i != -1) - clsName = clsName[i+1..$]; - } - // Set up a prototype object if(mc is null) - mc = vm.load(clsName); + { + // 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); + } + proto = mc.createObject(); proto.setString8("id", id); diff --git a/esm/loadacti.d b/esm/loadacti.d index 7dd7316782..1bed2a7390 100644 --- a/esm/loadacti.d +++ b/esm/loadacti.d @@ -36,7 +36,7 @@ import esm.imports; struct Activator { - mixin LoadT!(); + mixin LoadT; Script *script; MeshIndex model; diff --git a/monster/compiler/expression.d b/monster/compiler/expression.d index 13dfb93704..0de5fb0723 100644 --- a/monster/compiler/expression.d +++ b/monster/compiler/expression.d @@ -1097,6 +1097,9 @@ class PackageImpHolder : ImportHolder { sc = psc; assert(sc !is null); + + type = psc.type; + assert(type !is null); } override: diff --git a/monster/compiler/operators.d b/monster/compiler/operators.d index 9d3f18b0d8..96db25762b 100644 --- a/monster/compiler/operators.d +++ b/monster/compiler/operators.d @@ -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(); diff --git a/monster/compiler/variables.d b/monster/compiler/variables.d index fa240020fe..623209ec0c 100644 --- a/monster/compiler/variables.d +++ b/monster/compiler/variables.d @@ -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 diff --git a/monster/vm/mclass.d b/monster/vm/mclass.d index 9b8cc397b2..9d93f5d8fb 100644 --- a/monster/vm/mclass.d +++ b/monster/vm/mclass.d @@ -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); diff --git a/monster/vm/vm.d b/monster/vm/vm.d index 818a6d6dcb..c06fd53f11 100644 --- a/monster/vm/vm.d +++ b/monster/vm/vm.d @@ -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); diff --git a/mscripts/config.mn b/mscripts/config.mn index 1973750f90..8c23a48803 100644 --- a/mscripts/config.mn +++ b/mscripts/config.mn @@ -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. diff --git a/mscripts/gameobjects/activator.mn b/mscripts/game/activator.mn similarity index 100% rename from mscripts/gameobjects/activator.mn rename to mscripts/game/activator.mn diff --git a/mscripts/gameobjects/actor.mn b/mscripts/game/actor.mn similarity index 100% rename from mscripts/gameobjects/actor.mn rename to mscripts/game/actor.mn diff --git a/mscripts/gameobjects/apparatus.mn b/mscripts/game/apparatus.mn similarity index 93% rename from mscripts/gameobjects/apparatus.mn rename to mscripts/game/apparatus.mn index ac6bccf06d..3c3b83e29c 100644 --- a/mscripts/gameobjects/apparatus.mn +++ b/mscripts/game/apparatus.mn @@ -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; diff --git a/mscripts/gameobjects/armor.mn b/mscripts/game/armor.mn similarity index 100% rename from mscripts/gameobjects/armor.mn rename to mscripts/game/armor.mn diff --git a/mscripts/gameobjects/book.mn b/mscripts/game/book.mn similarity index 100% rename from mscripts/gameobjects/book.mn rename to mscripts/game/book.mn diff --git a/mscripts/gameobjects/clothing.mn b/mscripts/game/clothing.mn similarity index 100% rename from mscripts/gameobjects/clothing.mn rename to mscripts/game/clothing.mn diff --git a/mscripts/gameobjects/container.mn b/mscripts/game/container.mn similarity index 100% rename from mscripts/gameobjects/container.mn rename to mscripts/game/container.mn diff --git a/mscripts/gameobjects/creature.mn b/mscripts/game/creature.mn similarity index 100% rename from mscripts/gameobjects/creature.mn rename to mscripts/game/creature.mn diff --git a/mscripts/gameobjects/door.mn b/mscripts/game/door.mn similarity index 100% rename from mscripts/gameobjects/door.mn rename to mscripts/game/door.mn diff --git a/mscripts/gameobjects/enchantitem.mn b/mscripts/game/enchantitem.mn similarity index 100% rename from mscripts/gameobjects/enchantitem.mn rename to mscripts/game/enchantitem.mn diff --git a/mscripts/gameobjects/gameobject.mn b/mscripts/game/gameobject.mn similarity index 97% rename from mscripts/gameobjects/gameobject.mn rename to mscripts/game/gameobject.mn index 350d9aae67..564456170e 100644 --- a/mscripts/gameobjects/gameobject.mn +++ b/mscripts/game/gameobject.mn @@ -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; diff --git a/mscripts/gameobjects/ingredient.mn b/mscripts/game/ingredient.mn similarity index 100% rename from mscripts/gameobjects/ingredient.mn rename to mscripts/game/ingredient.mn diff --git a/mscripts/gameobjects/inventoryitem.mn b/mscripts/game/inventoryitem.mn similarity index 100% rename from mscripts/gameobjects/inventoryitem.mn rename to mscripts/game/inventoryitem.mn diff --git a/mscripts/gameobjects/light.mn b/mscripts/game/light.mn similarity index 100% rename from mscripts/gameobjects/light.mn rename to mscripts/game/light.mn diff --git a/mscripts/gameobjects/lockedobject.mn b/mscripts/game/lockedobject.mn similarity index 100% rename from mscripts/gameobjects/lockedobject.mn rename to mscripts/game/lockedobject.mn diff --git a/mscripts/gameobjects/lockpick.mn b/mscripts/game/lockpick.mn similarity index 100% rename from mscripts/gameobjects/lockpick.mn rename to mscripts/game/lockpick.mn diff --git a/mscripts/gameobjects/misc.mn b/mscripts/game/misc.mn similarity index 100% rename from mscripts/gameobjects/misc.mn rename to mscripts/game/misc.mn diff --git a/mscripts/gameobjects/person.mn b/mscripts/game/person.mn similarity index 100% rename from mscripts/gameobjects/person.mn rename to mscripts/game/person.mn diff --git a/mscripts/gameobjects/potion.mn b/mscripts/game/potion.mn similarity index 100% rename from mscripts/gameobjects/potion.mn rename to mscripts/game/potion.mn diff --git a/mscripts/gameobjects/probe.mn b/mscripts/game/probe.mn similarity index 100% rename from mscripts/gameobjects/probe.mn rename to mscripts/game/probe.mn diff --git a/mscripts/gameobjects/repairable.mn b/mscripts/game/repairable.mn similarity index 100% rename from mscripts/gameobjects/repairable.mn rename to mscripts/game/repairable.mn diff --git a/mscripts/gameobjects/repairitem.mn b/mscripts/game/repairitem.mn similarity index 100% rename from mscripts/gameobjects/repairitem.mn rename to mscripts/game/repairitem.mn diff --git a/mscripts/gameobjects/static.mn b/mscripts/game/static.mn similarity index 100% rename from mscripts/gameobjects/static.mn rename to mscripts/game/static.mn diff --git a/mscripts/gameobjects/tool.mn b/mscripts/game/tool.mn similarity index 100% rename from mscripts/gameobjects/tool.mn rename to mscripts/game/tool.mn diff --git a/mscripts/gameobjects/weapon.mn b/mscripts/game/weapon.mn similarity index 100% rename from mscripts/gameobjects/weapon.mn rename to mscripts/game/weapon.mn diff --git a/mscripts/setup.d b/mscripts/setup.d index d1514e0e58..13bcfb883b 100644 --- a/mscripts/setup.d +++ b/mscripts/setup.d @@ -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. diff --git a/mscripts/sound/music.mn b/mscripts/sound/music.mn index 1bdbe980af..c7cf0a92de 100644 --- a/mscripts/sound/music.mn +++ b/mscripts/sound/music.mn @@ -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 diff --git a/ogre/meshloader.d b/ogre/meshloader.d index 3490da08b7..740cf23925 100644 --- a/ogre/meshloader.d +++ b/ogre/meshloader.d @@ -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); diff --git a/scene/celldata.d b/scene/celldata.d index ea3778e58b..f3d57cfbb9 100644 --- a/scene/celldata.d +++ b/scene/celldata.d @@ -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")); diff --git a/sound/music.d b/sound/music.d index 2243e4cae4..8d064ad13c 100644 --- a/sound/music.d +++ b/sound/music.d @@ -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"); }