Merged in JavaScript branch, but haven't got it to do anything yet.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@852 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2007-03-11 17:41:38 +00:00
parent 31c5de5763
commit 64f80b08cb
12 changed files with 2003 additions and 285 deletions

View File

@ -253,6 +253,59 @@
1AD9AFB60B91E24C00FB704E /* PlayerEntityContracts.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AD9AFAE0B91E24C00FB704E /* PlayerEntityContracts.m */; };
1ADF5CEC0B9DF59A00FDB2A3 /* OOCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A231A170B9D8B1B00EF0852 /* OOCacheManager.m */; };
1ADF5F130B9E374B00FDB2A3 /* JoystickHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ADF5F110B9E374B00FDB2A3 /* JoystickHandler.h */; };
1AEAAB8F0BA45248000705D0 /* libjs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AEAAB8E0BA45248000705D0 /* libjs.a */; };
1AEAAC9E0BA457E7000705D0 /* jsarena.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC6F0BA457E6000705D0 /* jsarena.h */; };
1AEAAC9F0BA457E7000705D0 /* jsarray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC700BA457E6000705D0 /* jsarray.h */; };
1AEAACA00BA457E7000705D0 /* jsatom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC710BA457E6000705D0 /* jsatom.h */; };
1AEAACA10BA457E7000705D0 /* jsbit.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC720BA457E6000705D0 /* jsbit.h */; };
1AEAACA20BA457E7000705D0 /* jsbool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC730BA457E6000705D0 /* jsbool.h */; };
1AEAACA30BA457E7000705D0 /* jsclist.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC740BA457E6000705D0 /* jsclist.h */; };
1AEAACA40BA457E7000705D0 /* jscntxt.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC750BA457E6000705D0 /* jscntxt.h */; };
1AEAACA50BA457E7000705D0 /* jscompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC760BA457E6000705D0 /* jscompat.h */; };
1AEAACA60BA457E7000705D0 /* jsconfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC770BA457E6000705D0 /* jsconfig.h */; };
1AEAACA70BA457E7000705D0 /* jscpucfg.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC780BA457E6000705D0 /* jscpucfg.h */; };
1AEAACA80BA457E7000705D0 /* jsdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC790BA457E6000705D0 /* jsdate.h */; };
1AEAACA90BA457E7000705D0 /* jsdbgapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC7A0BA457E6000705D0 /* jsdbgapi.h */; };
1AEAACAA0BA457E7000705D0 /* jsdhash.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC7B0BA457E6000705D0 /* jsdhash.h */; };
1AEAACAB0BA457E7000705D0 /* jsdtoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC7C0BA457E6000705D0 /* jsdtoa.h */; };
1AEAACAC0BA457E7000705D0 /* jsemit.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC7D0BA457E6000705D0 /* jsemit.h */; };
1AEAACAD0BA457E7000705D0 /* jsexn.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC7E0BA457E6000705D0 /* jsexn.h */; };
1AEAACAE0BA457E7000705D0 /* jsfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC7F0BA457E6000705D0 /* jsfile.h */; };
1AEAACAF0BA457E7000705D0 /* jsfun.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC800BA457E6000705D0 /* jsfun.h */; };
1AEAACB00BA457E7000705D0 /* jsgc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC810BA457E6000705D0 /* jsgc.h */; };
1AEAACB10BA457E7000705D0 /* jshash.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC820BA457E6000705D0 /* jshash.h */; };
1AEAACB20BA457E7000705D0 /* jsinterp.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC830BA457E6000705D0 /* jsinterp.h */; };
1AEAACB30BA457E7000705D0 /* jslibmath.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC840BA457E6000705D0 /* jslibmath.h */; };
1AEAACB40BA457E7000705D0 /* jslock.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC850BA457E6000705D0 /* jslock.h */; };
1AEAACB50BA457E7000705D0 /* jslong.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC860BA457E6000705D0 /* jslong.h */; };
1AEAACB60BA457E7000705D0 /* jsmath.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC870BA457E6000705D0 /* jsmath.h */; };
1AEAACB70BA457E7000705D0 /* jsnum.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC880BA457E6000705D0 /* jsnum.h */; };
1AEAACB80BA457E7000705D0 /* jsobj.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC890BA457E6000705D0 /* jsobj.h */; };
1AEAACB90BA457E7000705D0 /* jsopcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC8A0BA457E6000705D0 /* jsopcode.h */; };
1AEAACBA0BA457E7000705D0 /* jsosdep.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC8B0BA457E6000705D0 /* jsosdep.h */; };
1AEAACBB0BA457E7000705D0 /* jsotypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC8C0BA457E6000705D0 /* jsotypes.h */; };
1AEAACBC0BA457E7000705D0 /* jsparse.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC8D0BA457E6000705D0 /* jsparse.h */; };
1AEAACBD0BA457E7000705D0 /* jsprf.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC8E0BA457E6000705D0 /* jsprf.h */; };
1AEAACBE0BA457E7000705D0 /* jsprvtd.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC8F0BA457E6000705D0 /* jsprvtd.h */; };
1AEAACBF0BA457E7000705D0 /* jspubtd.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC900BA457E6000705D0 /* jspubtd.h */; };
1AEAACC00BA457E7000705D0 /* jsregexp.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC910BA457E6000705D0 /* jsregexp.h */; };
1AEAACC10BA457E7000705D0 /* jsscan.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC920BA457E6000705D0 /* jsscan.h */; };
1AEAACC20BA457E7000705D0 /* jsscope.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC930BA457E6000705D0 /* jsscope.h */; };
1AEAACC30BA457E7000705D0 /* jsscript.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC940BA457E6000705D0 /* jsscript.h */; };
1AEAACC40BA457E7000705D0 /* jsstddef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC950BA457E6000705D0 /* jsstddef.h */; };
1AEAACC50BA457E7000705D0 /* jsstr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC960BA457E6000705D0 /* jsstr.h */; };
1AEAACC60BA457E7000705D0 /* jstypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC970BA457E6000705D0 /* jstypes.h */; };
1AEAACC70BA457E7000705D0 /* jsutil.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC980BA457E6000705D0 /* jsutil.h */; };
1AEAACC80BA457E7000705D0 /* jsxdrapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC990BA457E6000705D0 /* jsxdrapi.h */; };
1AEAACC90BA457E7000705D0 /* jsxml.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC9A0BA457E7000705D0 /* jsxml.h */; };
1AEAACCA0BA457E7000705D0 /* prmjtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC9B0BA457E7000705D0 /* prmjtime.h */; };
1AEAACCB0BA457E7000705D0 /* resource.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC9C0BA457E7000705D0 /* resource.h */; };
1AEAACCC0BA457E7000705D0 /* jsapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC9D0BA457E7000705D0 /* jsapi.h */; };
1AEAACDD0BA45895000705D0 /* OXPScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAACD80BA45895000705D0 /* OXPScript.h */; };
1AEAACDE0BA45895000705D0 /* ScriptEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AEAACD90BA45895000705D0 /* ScriptEngine.m */; };
1AEAACDF0BA45895000705D0 /* JSUniverse.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAACDA0BA45895000705D0 /* JSUniverse.h */; };
1AEAACE00BA45895000705D0 /* OXPScript.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AEAACDB0BA45895000705D0 /* OXPScript.m */; };
1AEAACE10BA45895000705D0 /* ScriptEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAACDC0BA45895000705D0 /* ScriptEngine.h */; };
2512833E09BA27C100F43D55 /* Octree.m in Sources */ = {isa = PBXBuildFile; fileRef = 2512833C09BA27C100F43D55 /* Octree.m */; };
2512833F09BA27C100F43D55 /* Octree.h in Headers */ = {isa = PBXBuildFile; fileRef = 2512833D09BA27C100F43D55 /* Octree.h */; };
2512834209BA27EC00F43D55 /* Geometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 2512834009BA27EC00F43D55 /* Geometry.h */; };
@ -896,6 +949,59 @@
1AD9AFAD0B91E24C00FB704E /* PlayerEntityControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerEntityControls.h; sourceTree = "<group>"; };
1AD9AFAE0B91E24C00FB704E /* PlayerEntityContracts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayerEntityContracts.m; sourceTree = "<group>"; };
1ADF5F110B9E374B00FDB2A3 /* JoystickHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoystickHandler.h; sourceTree = "<group>"; };
1AEAAB8E0BA45248000705D0 /* libjs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjs.a; path = "deps/Cocoa-deps/js/libjs.a"; sourceTree = "<group>"; };
1AEAAC6F0BA457E6000705D0 /* jsarena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsarena.h; sourceTree = "<group>"; };
1AEAAC700BA457E6000705D0 /* jsarray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsarray.h; sourceTree = "<group>"; };
1AEAAC710BA457E6000705D0 /* jsatom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsatom.h; sourceTree = "<group>"; };
1AEAAC720BA457E6000705D0 /* jsbit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsbit.h; sourceTree = "<group>"; };
1AEAAC730BA457E6000705D0 /* jsbool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsbool.h; sourceTree = "<group>"; };
1AEAAC740BA457E6000705D0 /* jsclist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsclist.h; sourceTree = "<group>"; };
1AEAAC750BA457E6000705D0 /* jscntxt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jscntxt.h; sourceTree = "<group>"; };
1AEAAC760BA457E6000705D0 /* jscompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jscompat.h; sourceTree = "<group>"; };
1AEAAC770BA457E6000705D0 /* jsconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsconfig.h; sourceTree = "<group>"; };
1AEAAC780BA457E6000705D0 /* jscpucfg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jscpucfg.h; sourceTree = "<group>"; };
1AEAAC790BA457E6000705D0 /* jsdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsdate.h; sourceTree = "<group>"; };
1AEAAC7A0BA457E6000705D0 /* jsdbgapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsdbgapi.h; sourceTree = "<group>"; };
1AEAAC7B0BA457E6000705D0 /* jsdhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsdhash.h; sourceTree = "<group>"; };
1AEAAC7C0BA457E6000705D0 /* jsdtoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsdtoa.h; sourceTree = "<group>"; };
1AEAAC7D0BA457E6000705D0 /* jsemit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsemit.h; sourceTree = "<group>"; };
1AEAAC7E0BA457E6000705D0 /* jsexn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsexn.h; sourceTree = "<group>"; };
1AEAAC7F0BA457E6000705D0 /* jsfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsfile.h; sourceTree = "<group>"; };
1AEAAC800BA457E6000705D0 /* jsfun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsfun.h; sourceTree = "<group>"; };
1AEAAC810BA457E6000705D0 /* jsgc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsgc.h; sourceTree = "<group>"; };
1AEAAC820BA457E6000705D0 /* jshash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jshash.h; sourceTree = "<group>"; };
1AEAAC830BA457E6000705D0 /* jsinterp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsinterp.h; sourceTree = "<group>"; };
1AEAAC840BA457E6000705D0 /* jslibmath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jslibmath.h; sourceTree = "<group>"; };
1AEAAC850BA457E6000705D0 /* jslock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jslock.h; sourceTree = "<group>"; };
1AEAAC860BA457E6000705D0 /* jslong.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jslong.h; sourceTree = "<group>"; };
1AEAAC870BA457E6000705D0 /* jsmath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsmath.h; sourceTree = "<group>"; };
1AEAAC880BA457E6000705D0 /* jsnum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsnum.h; sourceTree = "<group>"; };
1AEAAC890BA457E6000705D0 /* jsobj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsobj.h; sourceTree = "<group>"; };
1AEAAC8A0BA457E6000705D0 /* jsopcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsopcode.h; sourceTree = "<group>"; };
1AEAAC8B0BA457E6000705D0 /* jsosdep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsosdep.h; sourceTree = "<group>"; };
1AEAAC8C0BA457E6000705D0 /* jsotypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsotypes.h; sourceTree = "<group>"; };
1AEAAC8D0BA457E6000705D0 /* jsparse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsparse.h; sourceTree = "<group>"; };
1AEAAC8E0BA457E6000705D0 /* jsprf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsprf.h; sourceTree = "<group>"; };
1AEAAC8F0BA457E6000705D0 /* jsprvtd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsprvtd.h; sourceTree = "<group>"; };
1AEAAC900BA457E6000705D0 /* jspubtd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jspubtd.h; sourceTree = "<group>"; };
1AEAAC910BA457E6000705D0 /* jsregexp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsregexp.h; sourceTree = "<group>"; };
1AEAAC920BA457E6000705D0 /* jsscan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsscan.h; sourceTree = "<group>"; };
1AEAAC930BA457E6000705D0 /* jsscope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsscope.h; sourceTree = "<group>"; };
1AEAAC940BA457E6000705D0 /* jsscript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsscript.h; sourceTree = "<group>"; };
1AEAAC950BA457E6000705D0 /* jsstddef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsstddef.h; sourceTree = "<group>"; };
1AEAAC960BA457E6000705D0 /* jsstr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsstr.h; sourceTree = "<group>"; };
1AEAAC970BA457E6000705D0 /* jstypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jstypes.h; sourceTree = "<group>"; };
1AEAAC980BA457E6000705D0 /* jsutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsutil.h; sourceTree = "<group>"; };
1AEAAC990BA457E6000705D0 /* jsxdrapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsxdrapi.h; sourceTree = "<group>"; };
1AEAAC9A0BA457E7000705D0 /* jsxml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsxml.h; sourceTree = "<group>"; };
1AEAAC9B0BA457E7000705D0 /* prmjtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prmjtime.h; sourceTree = "<group>"; };
1AEAAC9C0BA457E7000705D0 /* resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resource.h; sourceTree = "<group>"; };
1AEAAC9D0BA457E7000705D0 /* jsapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsapi.h; sourceTree = "<group>"; };
1AEAACD80BA45895000705D0 /* OXPScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OXPScript.h; path = JavaScript/OXPScript.h; sourceTree = "<group>"; };
1AEAACD90BA45895000705D0 /* ScriptEngine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ScriptEngine.m; path = JavaScript/ScriptEngine.m; sourceTree = "<group>"; };
1AEAACDA0BA45895000705D0 /* JSUniverse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSUniverse.h; path = JavaScript/JSUniverse.h; sourceTree = "<group>"; };
1AEAACDB0BA45895000705D0 /* OXPScript.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OXPScript.m; path = JavaScript/OXPScript.m; sourceTree = "<group>"; };
1AEAACDC0BA45895000705D0 /* ScriptEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptEngine.h; path = JavaScript/ScriptEngine.h; sourceTree = "<group>"; };
2512833C09BA27C100F43D55 /* Octree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Octree.m; sourceTree = "<group>"; };
2512833D09BA27C100F43D55 /* Octree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Octree.h; sourceTree = "<group>"; };
2512834009BA27EC00F43D55 /* Geometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Geometry.h; sourceTree = "<group>"; };
@ -1009,6 +1115,7 @@
1A472922096B5468000E78D8 /* AudioUnit.framework in Frameworks */,
25F3E8EB099502BB002F25FD /* libOgg.a in Frameworks */,
25F3E8EC099502BB002F25FD /* libVorbisAll.a in Frameworks */,
1AEAAB8F0BA45248000705D0 /* libjs.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1018,6 +1125,7 @@
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
1AEAAB8E0BA45248000705D0 /* libjs.a */,
25F3E8E9099502BB002F25FD /* libOgg.a */,
25F3E8EA099502BB002F25FD /* libVorbisAll.a */,
0878FD2F086EF845004CB752 /* Carbon.framework */,
@ -1352,6 +1460,7 @@
25161110099544390037C2E1 /* OOTrumble.h */,
25161108099544390037C2E1 /* OOTrumble.m */,
25161116099544390037C2E1 /* OOSound.h */,
1AEAAB870BA4515E000705D0 /* JavaScript */,
);
name = Source;
path = src/Core;
@ -1560,6 +1669,74 @@
path = Doc;
sourceTree = "<group>";
};
1AEAAB870BA4515E000705D0 /* JavaScript */ = {
isa = PBXGroup;
children = (
1AEAAC6C0BA457C3000705D0 /* SpiderMonkey headers */,
1AEAACDA0BA45895000705D0 /* JSUniverse.h */,
1AEAACD80BA45895000705D0 /* OXPScript.h */,
1AEAACDB0BA45895000705D0 /* OXPScript.m */,
1AEAACDC0BA45895000705D0 /* ScriptEngine.h */,
1AEAACD90BA45895000705D0 /* ScriptEngine.m */,
);
name = JavaScript;
sourceTree = "<group>";
};
1AEAAC6C0BA457C3000705D0 /* SpiderMonkey headers */ = {
isa = PBXGroup;
children = (
1AEAAC6F0BA457E6000705D0 /* jsarena.h */,
1AEAAC700BA457E6000705D0 /* jsarray.h */,
1AEAAC710BA457E6000705D0 /* jsatom.h */,
1AEAAC720BA457E6000705D0 /* jsbit.h */,
1AEAAC730BA457E6000705D0 /* jsbool.h */,
1AEAAC740BA457E6000705D0 /* jsclist.h */,
1AEAAC750BA457E6000705D0 /* jscntxt.h */,
1AEAAC760BA457E6000705D0 /* jscompat.h */,
1AEAAC770BA457E6000705D0 /* jsconfig.h */,
1AEAAC780BA457E6000705D0 /* jscpucfg.h */,
1AEAAC790BA457E6000705D0 /* jsdate.h */,
1AEAAC7A0BA457E6000705D0 /* jsdbgapi.h */,
1AEAAC7B0BA457E6000705D0 /* jsdhash.h */,
1AEAAC7C0BA457E6000705D0 /* jsdtoa.h */,
1AEAAC7D0BA457E6000705D0 /* jsemit.h */,
1AEAAC7E0BA457E6000705D0 /* jsexn.h */,
1AEAAC7F0BA457E6000705D0 /* jsfile.h */,
1AEAAC800BA457E6000705D0 /* jsfun.h */,
1AEAAC810BA457E6000705D0 /* jsgc.h */,
1AEAAC820BA457E6000705D0 /* jshash.h */,
1AEAAC830BA457E6000705D0 /* jsinterp.h */,
1AEAAC840BA457E6000705D0 /* jslibmath.h */,
1AEAAC850BA457E6000705D0 /* jslock.h */,
1AEAAC860BA457E6000705D0 /* jslong.h */,
1AEAAC870BA457E6000705D0 /* jsmath.h */,
1AEAAC880BA457E6000705D0 /* jsnum.h */,
1AEAAC890BA457E6000705D0 /* jsobj.h */,
1AEAAC8A0BA457E6000705D0 /* jsopcode.h */,
1AEAAC8B0BA457E6000705D0 /* jsosdep.h */,
1AEAAC8C0BA457E6000705D0 /* jsotypes.h */,
1AEAAC8D0BA457E6000705D0 /* jsparse.h */,
1AEAAC8E0BA457E6000705D0 /* jsprf.h */,
1AEAAC8F0BA457E6000705D0 /* jsprvtd.h */,
1AEAAC900BA457E6000705D0 /* jspubtd.h */,
1AEAAC910BA457E6000705D0 /* jsregexp.h */,
1AEAAC920BA457E6000705D0 /* jsscan.h */,
1AEAAC930BA457E6000705D0 /* jsscope.h */,
1AEAAC940BA457E6000705D0 /* jsscript.h */,
1AEAAC950BA457E6000705D0 /* jsstddef.h */,
1AEAAC960BA457E6000705D0 /* jsstr.h */,
1AEAAC970BA457E6000705D0 /* jstypes.h */,
1AEAAC980BA457E6000705D0 /* jsutil.h */,
1AEAAC990BA457E6000705D0 /* jsxdrapi.h */,
1AEAAC9A0BA457E7000705D0 /* jsxml.h */,
1AEAAC9B0BA457E7000705D0 /* prmjtime.h */,
1AEAAC9C0BA457E7000705D0 /* resource.h */,
1AEAAC9D0BA457E7000705D0 /* jsapi.h */,
);
name = "SpiderMonkey headers";
path = "../../deps/Cocoa-deps/js/headers";
sourceTree = "<group>";
};
29B97314FDCFA39411CA2CEA /* Oolite_GUSTO */ = {
isa = PBXGroup;
children = (
@ -1652,6 +1829,56 @@
1A231A180B9D8B1B00EF0852 /* OOCacheManager.h in Headers */,
1ADF5F130B9E374B00FDB2A3 /* JoystickHandler.h in Headers */,
1A29967E0B9F064C002D2149 /* OOCache.h in Headers */,
1AEAAC9E0BA457E7000705D0 /* jsarena.h in Headers */,
1AEAAC9F0BA457E7000705D0 /* jsarray.h in Headers */,
1AEAACA00BA457E7000705D0 /* jsatom.h in Headers */,
1AEAACA10BA457E7000705D0 /* jsbit.h in Headers */,
1AEAACA20BA457E7000705D0 /* jsbool.h in Headers */,
1AEAACA30BA457E7000705D0 /* jsclist.h in Headers */,
1AEAACA40BA457E7000705D0 /* jscntxt.h in Headers */,
1AEAACA50BA457E7000705D0 /* jscompat.h in Headers */,
1AEAACA60BA457E7000705D0 /* jsconfig.h in Headers */,
1AEAACA70BA457E7000705D0 /* jscpucfg.h in Headers */,
1AEAACA80BA457E7000705D0 /* jsdate.h in Headers */,
1AEAACA90BA457E7000705D0 /* jsdbgapi.h in Headers */,
1AEAACAA0BA457E7000705D0 /* jsdhash.h in Headers */,
1AEAACAB0BA457E7000705D0 /* jsdtoa.h in Headers */,
1AEAACAC0BA457E7000705D0 /* jsemit.h in Headers */,
1AEAACAD0BA457E7000705D0 /* jsexn.h in Headers */,
1AEAACAE0BA457E7000705D0 /* jsfile.h in Headers */,
1AEAACAF0BA457E7000705D0 /* jsfun.h in Headers */,
1AEAACB00BA457E7000705D0 /* jsgc.h in Headers */,
1AEAACB10BA457E7000705D0 /* jshash.h in Headers */,
1AEAACB20BA457E7000705D0 /* jsinterp.h in Headers */,
1AEAACB30BA457E7000705D0 /* jslibmath.h in Headers */,
1AEAACB40BA457E7000705D0 /* jslock.h in Headers */,
1AEAACB50BA457E7000705D0 /* jslong.h in Headers */,
1AEAACB60BA457E7000705D0 /* jsmath.h in Headers */,
1AEAACB70BA457E7000705D0 /* jsnum.h in Headers */,
1AEAACB80BA457E7000705D0 /* jsobj.h in Headers */,
1AEAACB90BA457E7000705D0 /* jsopcode.h in Headers */,
1AEAACBA0BA457E7000705D0 /* jsosdep.h in Headers */,
1AEAACBB0BA457E7000705D0 /* jsotypes.h in Headers */,
1AEAACBC0BA457E7000705D0 /* jsparse.h in Headers */,
1AEAACBD0BA457E7000705D0 /* jsprf.h in Headers */,
1AEAACBE0BA457E7000705D0 /* jsprvtd.h in Headers */,
1AEAACBF0BA457E7000705D0 /* jspubtd.h in Headers */,
1AEAACC00BA457E7000705D0 /* jsregexp.h in Headers */,
1AEAACC10BA457E7000705D0 /* jsscan.h in Headers */,
1AEAACC20BA457E7000705D0 /* jsscope.h in Headers */,
1AEAACC30BA457E7000705D0 /* jsscript.h in Headers */,
1AEAACC40BA457E7000705D0 /* jsstddef.h in Headers */,
1AEAACC50BA457E7000705D0 /* jsstr.h in Headers */,
1AEAACC60BA457E7000705D0 /* jstypes.h in Headers */,
1AEAACC70BA457E7000705D0 /* jsutil.h in Headers */,
1AEAACC80BA457E7000705D0 /* jsxdrapi.h in Headers */,
1AEAACC90BA457E7000705D0 /* jsxml.h in Headers */,
1AEAACCA0BA457E7000705D0 /* prmjtime.h in Headers */,
1AEAACCB0BA457E7000705D0 /* resource.h in Headers */,
1AEAACCC0BA457E7000705D0 /* jsapi.h in Headers */,
1AEAACDD0BA45895000705D0 /* OXPScript.h in Headers */,
1AEAACDF0BA45895000705D0 /* JSUniverse.h in Headers */,
1AEAACE10BA45895000705D0 /* ScriptEngine.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1798,6 +2025,8 @@
1A38B4AD0B988532001ED4A0 /* OOLogging.m in Sources */,
1ADF5CEC0B9DF59A00FDB2A3 /* OOCacheManager.m in Sources */,
1A29967F0B9F064C002D2149 /* OOCache.m in Sources */,
1AEAACDE0BA45895000705D0 /* ScriptEngine.m in Sources */,
1AEAACE00BA45895000705D0 /* OXPScript.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1822,13 +2051,18 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = XP_UNIX;
GCC_REUSE_STRINGS = YES;
HEADER_SEARCH_PATHS = "$(HEADER_SEARCH_PATHS_QUOTED_1)";
HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/deps/Cocoa-deps/Ogg Vorbis\"";
INFOPLIST_FILE = "src/Cocoa/Info-OoliteDev.plist";
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)";
LIBRARY_SEARCH_PATHS = (
"$(LIBRARY_SEARCH_PATHS_QUOTED_1)",
"$(LIBRARY_SEARCH_PATHS_QUOTED_2)",
);
LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/deps/Cocoa-deps/Ogg\\ Vorbis\"";
LIBRARY_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)/deps/Cocoa-deps/js\"";
MACOSX_DEPLOYMENT_TARGET = 10.3;
OTHER_CFLAGS = "-DLOADSAVEGUIXX";
OTHER_LDFLAGS = "";
@ -1856,13 +2090,18 @@
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = s;
GCC_PREPROCESSOR_DEFINITIONS = XP_UNIX;
GCC_REUSE_STRINGS = YES;
HEADER_SEARCH_PATHS = "$(HEADER_SEARCH_PATHS_QUOTED_1)";
HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/deps/Cocoa-deps/Ogg Vorbis\"";
INFOPLIST_FILE = "src/Cocoa/Info-Oolite.plist";
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)";
LIBRARY_SEARCH_PATHS = (
"$(LIBRARY_SEARCH_PATHS_QUOTED_1)",
"$(LIBRARY_SEARCH_PATHS_QUOTED_2)",
);
LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/deps/Cocoa-deps/Ogg\\ Vorbis\"";
LIBRARY_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)/deps/Cocoa-deps/js\"";
MACOSX_DEPLOYMENT_TARGET = 10.3;
OTHER_LDFLAGS = "-lSystem";
PREBINDING = NO;

View File

@ -0,0 +1,196 @@
//===========================================================================
// Universe proxy
//===========================================================================
JSClass Universe_class = {
"Universe", JSCLASS_HAS_PRIVATE,
JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};
/*
JSBool UniverseGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
enum Universe_propertyIds {
UNI_PLAYER_ENTITY
};
JSPropertySpec Universe_props[] = {
{ "PlayerEntity", UNI_PLAYER_ENTITY, JSPROP_ENUMERATE },
{ 0 }
};
*/
JSBool UniverseCheckForShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool UniverseAddShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool UniverseAddSystemShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool UniverseAddShipsAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool UniverseAddShipsAtPrecisely(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool UniverseAddShipsWithinRadius(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool UniverseSpawn(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool UniverseSpawnShip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSFunctionSpec Universe_funcs[] = {
{ "CheckForShips", UniverseCheckForShips, 1, 0 },
{ "AddShips", UniverseAddShips, 2, 0 },
{ "AddSystemShips", UniverseAddSystemShips, 3, 0 },
{ "AddShipsAt", UniverseAddShipsAt, 6, 0 },
{ "AddShipsAtPrecisely", UniverseAddShipsAtPrecisely, 6, 0 },
{ "AddShipsWithinRadius", UniverseAddShipsWithinRadius, 7, 0 },
{ "Spawn", UniverseSpawn, 2, 0 },
{ "SpawnShip", UniverseSpawnShip, 1, 0 },
{ 0 }
};
JSBool UniverseCheckForShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 1) {
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *role = JSValToNSString(cx, argv[0]);
int num = [scriptedUniverse countShipsWithRole:role];
*rval = INT_TO_JSVAL(num);
}
return JS_TRUE;
}
JSBool UniverseAddShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 2) {
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *role = JSValToNSString(cx, argv[0]);
int num = JSVAL_TO_INT(argv[1]);
while (num--)
[scriptedUniverse witchspaceShipWithRole:role];
}
return JS_TRUE;
}
JSBool UniverseAddSystemShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 3) {
jsdouble posn;
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *role = JSValToNSString(cx, argv[0]);
int num = JSVAL_TO_INT(argv[1]);
JS_ValueToNumber(cx, argv[2], &posn);
while (num--)
[scriptedUniverse addShipWithRole:role nearRouteOneAt:posn];
}
return JS_TRUE;
}
JSBool UniverseAddShipsAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 6) {
jsdouble x, y, z;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *role = JSValToNSString(cx, argv[0]);
int num = JSVAL_TO_INT(argv[1]);
NSString *coordScheme = JSValToNSString(cx, argv[2]);
JS_ValueToNumber(cx, argv[3], &x);
JS_ValueToNumber(cx, argv[4], &y);
JS_ValueToNumber(cx, argv[5], &z);
NSString *arg = [NSString stringWithFormat:@"%@ %d %@ %f %f %f", role, num, coordScheme, x, y, z];
[playerEntity addShipsAt:arg];
}
return JS_TRUE;
}
JSBool UniverseAddShipsAtPrecisely(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 6) {
jsdouble x, y, z;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *role = JSValToNSString(cx, argv[0]);
int num = JSVAL_TO_INT(argv[1]);
NSString *coordScheme = JSValToNSString(cx, argv[2]);
JS_ValueToNumber(cx, argv[3], &x);
JS_ValueToNumber(cx, argv[4], &y);
JS_ValueToNumber(cx, argv[5], &z);
NSString *arg = [NSString stringWithFormat:@"%@ %d %@ %f %f %f", role, num, coordScheme, x, y, z];
[playerEntity addShipsAtPrecisely:arg];
}
return JS_TRUE;
}
JSBool UniverseAddShipsWithinRadius(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 7) {
jsdouble x, y, z;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *role = JSValToNSString(cx, argv[0]);
int num = JSVAL_TO_INT(argv[1]);
NSString *coordScheme = JSValToNSString(cx, argv[2]);
JS_ValueToNumber(cx, argv[3], &x);
JS_ValueToNumber(cx, argv[4], &y);
JS_ValueToNumber(cx, argv[5], &z);
int rad = JSVAL_TO_INT(argv[6]);
NSString *arg = [NSString stringWithFormat:@"%@ %d %@ %f %f %f %d", role, num, coordScheme, x, y, z, rad];
[playerEntity addShipsAt:arg];
}
return JS_TRUE;
}
JSBool UniverseSpawn(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 2) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *role = JSValToNSString(cx, argv[0]);
int num = JSVAL_TO_INT(argv[1]);
NSString *arg = [NSString stringWithFormat:@"%@ %d", role, num];
[playerEntity spawn:arg];
}
return JS_TRUE;
}
JSBool UniverseSpawnShip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 1) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity spawnShip:JSValToNSString(cx, argv[0])];
}
return JS_TRUE;
}
JSBool UniverseAddMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
JSBool ok;
int32 count;
if (argc != 2)
return JS_FALSE;
ok = JS_ValueToInt32(cx, argv[1], &count);
NSString *str = JSValToNSString(cx, argv[0]);
[scriptedUniverse addMessage: str forCount:(int)count];
//[str dealloc];
return JS_TRUE;
}
JSBool UniverseAddCommsMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
JSBool ok;
int32 count;
if (argc != 2)
return JS_FALSE;
ok = JS_ValueToInt32(cx, argv[1], &count);
NSString *str = JSValToNSString(cx, argv[0]);
[scriptedUniverse addCommsMessage: str forCount:(int)count];
//[str dealloc];
return JS_TRUE;
}
/*
JSBool UniverseGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (JSVAL_IS_INT(id)) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
switch (JSVAL_TO_INT(id)) {
case UNI_PLAYER_ENTITY: {
JSObject *pe = JS_DefineObject(cx, universeObj, "PlayerEntity", &PlayerEntity_class, 0x00, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
if (pe == 0x00) {
return JS_FALSE;
}
JS_DefineProperties(cx, pe, playerEntity_props);
*vp = OBJECT_TO_JSVAL(pe);
break;
}
}
}
return JS_TRUE;
}
*/

View File

@ -0,0 +1,53 @@
/*
OXPScript.h
JavaScript support for Oolite
Copyright (C) 2007 David Taylor
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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#ifndef OXPSCRIPT_H_SEEN
#define OXPSCRIPT_H_SEEN
#include <Foundation/Foundation.h>
#include <jsapi.h>
@interface OXPScript : NSObject
{
JSContext *cx;
JSObject *obj;
NSString *name;
NSString *description;
NSString *version;
}
- (id) initWithContext: (JSContext *) context andFilename: (NSString *) filename;
- (NSString *) name;
- (NSString *) description;
- (NSString *) version;
- (BOOL) doEvent: (NSString *) eventName;
- (BOOL) doEvent: (NSString *) eventName withIntegerArgument:(int)argument;
- (BOOL) doEvent: (NSString *) eventName withStringArgument:(NSString *)argument;
@end
#endif

View File

@ -0,0 +1,196 @@
/*
OXPScript.m
JavaScript support for Oolite
Copyright (C) 2007 David Taylor
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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#import "OXPScript.h"
OXPScript *currentOXPScript;
JSClass OXP_class = {
"OXPScript", JSCLASS_HAS_PRIVATE,
JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};
extern NSString *JSValToNSString(JSContext *cx, jsval val);
@implementation OXPScript
- (id) initWithContext: (JSContext *) context andFilename: (NSString *) filename
{
// Check if file exists before doing anything else
// ...
self = [super init];
//NSLog(@"Attempting to load script: %@", filename);
obj = JS_NewObject(context, &OXP_class, 0x00, JS_GetGlobalObject(context));
JS_AddRoot(context, &obj); // note 2nd arg is a pointer-to-pointer
cx = context;
jsval rval;
JSBool ok;
JSScript *script = JS_CompileFile(context, obj, [filename cString]);
if (script != 0x00) {
ok = JS_ExecuteScript(context, obj, script, &rval);
if (ok) {
ok = JS_GetProperty(context, obj, "Name", &rval);
if (ok) {
name = JSValToNSString(context, rval);
//NSLog(@"Found name property: %@", name);
} else {
// No name given in the script so use the filename
name = [NSString stringWithString:filename];
//NSLog(@"No name property, defaulting to : %@", name);
}
ok = JS_GetProperty(context, obj, "Description", &rval);
if (ok) {
description = JSValToNSString(context, rval);
//NSLog(@"Found description : %@", description);
} else {
description = @"";
//NSLog(@"No description");
}
ok = JS_GetProperty(context, obj, "Version", &rval);
if (ok) {
version = JSValToNSString(context, rval);
//NSLog(@"Found version: %@", version);
} else {
version= @"";
//NSLog(@"No version");
}
NSLog(@"Loaded JavaScript OXP: %@ %@ %@", name, description, version);
/*
* Example code to read the mission variables.
*
* So far, this just gets their names. Need to add code to get their values
* and convert the whole thing to Obj-C friendly NSArray and types.
*
ok = JS_GetProperty(context, obj, "MissionVars", &rval);
if (ok && JSVAL_IS_OBJECT(rval)) {
JSObject *ar = JSVAL_TO_OBJECT(rval);
JSIdArray *ids = JS_Enumerate(context, ar);
int i;
for (i = 0; i < ids->length; i++) {
if (JS_IdToValue(cx, ids->vector[i], &rval) == JS_TRUE) {
if (JSVAL_IS_BOOLEAN(rval)) fprintf(stdout, "a boolean\r\n");
if (JSVAL_IS_DOUBLE(rval)) fprintf(stdout, "a double\r\n");
if (JSVAL_IS_INT(rval)) fprintf(stdout, "an integer\r\n");
if (JSVAL_IS_NUMBER(rval)) fprintf(stdout, "a number\r\n");
if (JSVAL_IS_OBJECT(rval)) fprintf(stdout, "an object\r\n");
if (JSVAL_IS_STRING(rval)) {
fprintf(stdout, "%s\r\n", JS_GetStringBytes(JSVAL_TO_STRING(rval)));
}
}
}
JS_DestroyIdArray(context, ids);
}
*/
}
JS_DestroyScript(context, script);
} else {
NSLog(@"Script compilation failed");
[super dealloc];
return nil;
}
return self;
}
- (NSString *) name
{
return name;
}
- (NSString *) description
{
return description;
}
- (NSString *) version
{
return version;
}
- (BOOL) doEvent: (NSString *) eventName
{
jsval rval;
JSBool ok;
ok = JS_GetProperty(cx, obj, [eventName cString], &rval);
if (ok && !JSVAL_IS_VOID(rval)) {
JSFunction *func = JS_ValueToFunction(cx, rval);
if (func != 0x00) {
currentOXPScript = self;
ok = JS_CallFunction(cx, obj, func, 0, 0x00, &rval);
if (ok)
return YES;
}
}
return NO;
}
- (BOOL) doEvent: (NSString *) eventName withIntegerArgument:(int)argument
{
jsval rval;
JSBool ok;
ok = JS_GetProperty(cx, obj, [eventName cString], &rval);
if (ok && !JSVAL_IS_VOID(rval)) {
JSFunction *func = JS_ValueToFunction(cx, rval);
if (func != 0x00) {
currentOXPScript = self;
jsval args[1];
args[0] = INT_TO_JSVAL(argument);
ok = JS_CallFunction(cx, obj, func, 1, args, &rval);
if (ok)
return YES;
}
}
return NO;
}
- (BOOL) doEvent: (NSString *) eventName withStringArgument:(NSString *)argument
{
jsval rval;
JSBool ok;
ok = JS_GetProperty(cx, obj, [eventName cString], &rval);
if (ok && !JSVAL_IS_VOID(rval)) {
JSFunction *func = JS_ValueToFunction(cx, rval);
if (func != 0x00) {
currentOXPScript = self;
ok = JS_CallFunction(cx, obj, func, 0, 0x00, &rval);
if (ok)
return YES;
}
}
return NO;
}
@end

View File

@ -0,0 +1,49 @@
/*
ScriptEngine.h
JavaScript support for Oolite
Copyright (C) 2007 David Taylor
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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#ifndef SCRIPTENGINE_H_SEEN
#define SCRIPTENGINE_H_SEEN
#import <Foundation/Foundation.h>
#import "Universe.h"
#import "PlayerEntity.h"
#import "PlayerEntityScripting.h"
#import <jsapi.h>
@interface ScriptEngine : NSObject
{
JSRuntime *rt;
JSContext *cx;
JSObject *glob;
JSBool builtins;
}
- (id) initWithUniverse: (Universe *) universe;
- (void) dealloc;
- (JSContext *) context;
@end
#endif

View File

@ -0,0 +1,866 @@
/*
ScriptEngine.h
JavaScript support for Oolite
Copyright (C) 2007 David Taylor
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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#import "ScriptEngine.h"
#import "OXPScript.h"
#include <stdio.h>
#include <string.h>
Universe *scriptedUniverse;
JSObject *xglob, *universeObj, *systemObj, *playerObj, *missionObj;
extern OXPScript *currentOXPScript;
NSString *JSValToNSString(JSContext *cx, jsval val) {
JSString *str = JS_ValueToString(cx, val);
char *chars = JS_GetStringBytes(str);
return [NSString stringWithCString:chars];
}
void NSStringToJSVal(JSContext *cx, NSString *string, jsval *vp) {
const char *strptr = [string cString];
JSString *js_strptr = JS_NewStringCopyZ(cx, strptr);
*vp = STRING_TO_JSVAL(js_strptr);
}
void BOOLToJSVal(JSContext *cx, BOOL b, jsval *vp) {
if (b == YES)
*vp = BOOLEAN_TO_JSVAL(1);
else
*vp = BOOLEAN_TO_JSVAL(0);
}
//===========================================================================
// MissionVars class
//===========================================================================
JSBool MissionVarsGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSBool MissionVarsSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSClass MissionVars_class = {
"MissionVars", JSCLASS_HAS_PRIVATE,
JS_PropertyStub,JS_PropertyStub,MissionVarsGetProperty,MissionVarsSetProperty,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};
JSBool MissionVarsGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSDictionary *mission_variables = [playerEntity mission_variables];
if (JSVAL_IS_STRING(id)) {
NSString *key = JSValToNSString(cx, id);
NSString *value = (NSString *)[mission_variables objectForKey:key];
if (!value)
*vp = JSVAL_VOID;
else
{
int i;
int c = [value length];
BOOL isNumber = YES;
// The point of this code is to try and tell the JS interpreter to treat numeric strings
// as numbers where possible so that standard arithmetic works as you'd expect rather than
// 1+1 == "11". So a JSVAL_DOUBLE is returned if possible, otherwise a JSVAL_STRING is returned.
NSCharacterSet *numberCharSet = [NSCharacterSet characterSetWithCharactersInString:@"1234567890-."];
for (i = 0; i < c; i++) {
if ([numberCharSet characterIsMember:[value characterAtIndex:i]] == NO) {
isNumber = NO;
break;
}
}
if (isNumber) {
jsdouble ds = [value doubleValue];
JSBool ok = JS_NewDoubleValue(cx, ds, vp);
if (ok)
return JS_TRUE;
}
const char *name_str = [value cString];
JSString *js_name = JS_NewStringCopyZ(cx, name_str);
*vp = STRING_TO_JSVAL(js_name);
}
}
return JS_TRUE;
}
JSBool MissionVarsSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSDictionary *mission_variables = [playerEntity mission_variables];
if (JSVAL_IS_STRING(id)) {
NSString *key = JSValToNSString(cx, id);
NSString *value = JSValToNSString(cx, *vp);
[mission_variables setValue:value forKey:key];
}
return JS_TRUE;
}
//===========================================================================
// Global object class
//===========================================================================
JSBool GlobalGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSClass global_class = {
"Oolite",0,
JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};
enum global_propertyIds {
GLOBAL_GALAXY_NUMBER, GLOBAL_PLANET_NUMBER, GLOBAL_DOCKED_AT_MAIN_STATION, GLOBAL_DOCKED_STATION_NAME, GLOBAL_MISSION_VARS,
GLOBAL_GUI_SCREEN, GLOBAL_STATUS_STRING
};
JSPropertySpec Global_props[] = {
{ "GalaxyNumber", GLOBAL_GALAXY_NUMBER, JSPROP_ENUMERATE, GlobalGetProperty },
{ "PlanetNumber", GLOBAL_PLANET_NUMBER, JSPROP_ENUMERATE, GlobalGetProperty },
{ "DockedAtMainStation", GLOBAL_DOCKED_AT_MAIN_STATION, JSPROP_ENUMERATE, GlobalGetProperty },
{ "StationName", GLOBAL_DOCKED_STATION_NAME, JSPROP_ENUMERATE, GlobalGetProperty },
{ "MissionVars", GLOBAL_MISSION_VARS, JSPROP_ENUMERATE, GlobalGetProperty },
{ "GUIScreen", GLOBAL_GUI_SCREEN, JSPROP_ENUMERATE, GlobalGetProperty },
{ "StatusString", GLOBAL_STATUS_STRING, JSPROP_ENUMERATE, GlobalGetProperty },
{ 0 }
};
//JSBool GlobalEnableLogging(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool GlobalLog(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool GlobalListenForKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSFunctionSpec Global_funcs[] = {
// { "EnableLogging", GlobalEnableLogging, 1, 0 },
{ "Log", GlobalLog, 1, 0 },
{ "ListenForKey", GlobalListenForKey, 1, 0 },
{ 0 }
};
JSBool GlobalListenForKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
NSString *key = JSValToNSString(cx, argv[0]);
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity mapKey:key toOXP:currentOXPScript];
return JS_TRUE;
}
/*
JSBool GlobalEnableLogging(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
}
*/
JSBool GlobalLog(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
JSString *str;
str = JS_ValueToString(cx, argv[0]);
NSLog(@"%s", JS_GetStringBytes(str));
return JS_TRUE;
}
JSBool GlobalGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (!JSVAL_IS_INT(id)) return JS_TRUE;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
switch (JSVAL_TO_INT(id)) {
case GLOBAL_GALAXY_NUMBER:
*vp = INT_TO_JSVAL([[playerEntity galaxy_number] intValue]);
break;
case GLOBAL_PLANET_NUMBER:
*vp = INT_TO_JSVAL([[playerEntity planet_number] intValue]);
break;
case GLOBAL_DOCKED_AT_MAIN_STATION:
BOOLToJSVal(cx, [[playerEntity dockedAtMainStation_bool] isEqualToString:@"YES"], vp);
break;
case GLOBAL_DOCKED_STATION_NAME:
NSStringToJSVal(cx, [playerEntity dockedStationName_string], vp);
break;
case GLOBAL_GUI_SCREEN:
NSStringToJSVal(cx, [playerEntity gui_screen_string], vp);
break;
case GLOBAL_STATUS_STRING:
NSStringToJSVal(cx, [playerEntity status_string], vp);
break;
case GLOBAL_MISSION_VARS: {
JSObject *mv = JS_DefineObject(cx, xglob, "MissionVars", &MissionVars_class, 0x00, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
*vp = OBJECT_TO_JSVAL(mv);
break;
}
}
return JS_TRUE;
}
#import "JSUniverse.h"
//===========================================================================
// Player proxy
//===========================================================================
JSBool PlayerGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSBool PlayerSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSClass Player_class = {
"Player", JSCLASS_HAS_PRIVATE,
JS_PropertyStub,JS_PropertyStub,PlayerGetProperty,PlayerSetProperty,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};
enum Player_propertyIds {
PE_SHIP_DESCRIPTION, PE_COMMANDER_NAME, PE_SCORE, PE_CREDITS, PE_LEGAL_STATUS,
PE_FUEL_LEVEL, PE_FUEL_LEAK_RATE, PE_ALERT_CONDITION, PE_ALERT_FLAGS
};
JSPropertySpec Player_props[] = {
{ "ShipDescription", PE_SHIP_DESCRIPTION, JSPROP_ENUMERATE },
{ "Name", PE_COMMANDER_NAME, JSPROP_ENUMERATE },
{ "Score", PE_SCORE, JSPROP_ENUMERATE },
{ "Credits", PE_CREDITS, JSPROP_ENUMERATE },
{ "LegalStatus", PE_LEGAL_STATUS, JSPROP_ENUMERATE },
{ "Fuel", PE_FUEL_LEVEL, JSPROP_ENUMERATE },
{ "FuelLeakRate", PE_FUEL_LEAK_RATE, JSPROP_ENUMERATE },
{ "AlertCondition", PE_ALERT_CONDITION, JSPROP_ENUMERATE },
{ "AlertFlags", PE_ALERT_FLAGS, JSPROP_ENUMERATE },
{ 0 }
};
JSBool PlayerAwardEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool PlayerRemoveEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool PlayerHasEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool PlayerLaunch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool PlayerCall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool PlayerAwardCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool PlayerRemoveAllCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool PlayerUseSpecialCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSFunctionSpec Player_funcs[] = {
{ "AwardEquipment", PlayerAwardEquipment, 1, 0 },
{ "RemoveEquipment", PlayerRemoveEquipment, 1, 0 },
{ "HasEquipment", PlayerHasEquipment, 1, 0 },
{ "Launch", PlayerLaunch, 0, 0 },
{ "Call", PlayerCall, 2, 0 },
{ "AwardCargo", PlayerAwardCargo, 2, 0 },
{ "RemoveAllCargo", PlayerRemoveAllCargo, 0, 0 },
{ "UseSpecialCargo", PlayerUseSpecialCargo, 1, 0 },
{ 0 }
};
JSBool PlayerAwardCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 2) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
NSString *amount_type = [NSString stringWithFormat:@"%@ %@", JSValToNSString(cx, argv[0]), JSValToNSString(cx, argv[1])];
[playerEntity awardCargo:amount_type];
}
return JS_TRUE;
}
JSBool PlayerRemoveAllCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity removeAllCargo];
return JS_TRUE;
}
JSBool PlayerUseSpecialCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
if (argc == 1) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity useSpecialCargo:JSValToNSString(cx, argv[0])];
}
return JS_TRUE;
}
JSBool PlayerAwardEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
JSString *jskey = JS_ValueToString(cx, argv[0]);
[playerEntity awardEquipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
}
return JS_TRUE;
}
JSBool PlayerRemoveEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
JSString *jskey = JS_ValueToString(cx, argv[0]);
[playerEntity removeEquipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
}
return JS_TRUE;
}
JSBool PlayerHasEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
JSString *jskey = JS_ValueToString(cx, argv[0]);
BOOLToJSVal(cx, [playerEntity has_extra_equipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]], rval);
}
return JS_TRUE;
}
JSBool PlayerLaunch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity launchFromStation];
return JS_TRUE;
}
JSBool PlayerCall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0) {
NSString *selectorString = JSValToNSString(cx, argv[0]);
// Check if the selector needs a trailing colon to flag an argument will be sent
if (argc > 1)
selectorString = [NSString stringWithFormat:@"%@:", selectorString];
SEL _selector = NSSelectorFromString(selectorString);
if ([playerEntity respondsToSelector:_selector]) {
if (argc == 1)
[playerEntity performSelector:_selector];
else {
NSString *valueString = JSValToNSString(cx, argv[1]);
[playerEntity performSelector:_selector withObject:valueString];
}
}
}
return JS_TRUE;
}
JSBool PlayerGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (!JSVAL_IS_INT(id)) return JS_TRUE;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
switch (JSVAL_TO_INT(id)) {
case PE_SHIP_DESCRIPTION:
NSStringToJSVal(cx, [playerEntity commanderShip_string], vp);
break;
case PE_COMMANDER_NAME:
NSStringToJSVal(cx, [playerEntity commanderName_string], vp);
break;
case PE_SCORE:
JS_NewDoubleValue(cx, [[playerEntity score_number] doubleValue], vp);
break;
case PE_LEGAL_STATUS:
JS_NewDoubleValue(cx, [[playerEntity legalStatus_number] doubleValue], vp);
break;
case PE_CREDITS:
JS_NewDoubleValue(cx, [[playerEntity credits_number] doubleValue], vp);
break;
case PE_FUEL_LEVEL:
JS_NewDoubleValue(cx, [[playerEntity fuel_level_number] doubleValue], vp);
break;
case PE_FUEL_LEAK_RATE:
JS_NewDoubleValue(cx, [[playerEntity fuel_leak_rate_number] doubleValue], vp);
break;
case PE_ALERT_CONDITION:
*vp = INT_TO_JSVAL([playerEntity alert_condition]);
break;
case PE_ALERT_FLAGS:
*vp = INT_TO_JSVAL([playerEntity alert_flags]);
break;
}
return JS_TRUE;
}
JSBool PlayerSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (!JSVAL_IS_INT(id)) return JS_TRUE;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
switch (JSVAL_TO_INT(id)) {
case PE_SCORE:
[playerEntity setKills:[JSValToNSString(cx, *vp) intValue]];
break;
case PE_LEGAL_STATUS:
[playerEntity setLegalStatus:JSValToNSString(cx, *vp)];
break;
case PE_CREDITS:
[playerEntity setCredits:[JSValToNSString(cx, *vp) intValue]];
break;
case PE_FUEL_LEVEL:
[playerEntity setCredits:(int)([JSValToNSString(cx, *vp) doubleValue] * 10)];
break;
case PE_FUEL_LEAK_RATE:
[playerEntity setLegalStatus:JSValToNSString(cx, *vp)];
break;
}
return JS_TRUE;
}
//===========================================================================
// System (solar system) proxy
//===========================================================================
JSBool SystemGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSBool SystemSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSClass System_class = {
"System", JSCLASS_HAS_PRIVATE,
JS_PropertyStub,JS_PropertyStub,SystemGetProperty,SystemSetProperty,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};
enum System_propertyIds {
SYS_ID, SYS_NAME, SYS_DESCRIPTION, SYS_GOING_NOVA, SYS_GONE_NOVA, SYS_GOVT_STR, SYS_GOVT_ID, SYS_ECONOMY_ID,
SYS_TECH_LVL, SYS_POPULATION, SYS_PRODUCTIVITY, SYS_INHABITANTS
};
JSPropertySpec System_props[] = {
{ "Id", SYS_ID, JSPROP_ENUMERATE },
{ "Name", SYS_NAME, JSPROP_ENUMERATE },
{ "Description", SYS_DESCRIPTION, JSPROP_ENUMERATE },
{ "InhabitantsDescription", SYS_INHABITANTS, JSPROP_ENUMERATE },
{ "GoingNova", SYS_GOING_NOVA, JSPROP_ENUMERATE },
{ "GoneNova", SYS_GONE_NOVA, JSPROP_ENUMERATE },
{ "GovernmentDescription", SYS_GOVT_STR, JSPROP_ENUMERATE },
{ "GovernmentId", SYS_GOVT_ID, JSPROP_ENUMERATE },
{ "EconomyId", SYS_ECONOMY_ID, JSPROP_ENUMERATE },
{ "TechLevel", SYS_TECH_LVL, JSPROP_ENUMERATE },
{ "Population", SYS_POPULATION, JSPROP_ENUMERATE },
{ "Productivity", SYS_PRODUCTIVITY, JSPROP_ENUMERATE },
{ 0 }
};
JSBool SystemAddPlanet(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool SystemAddMoon(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool SystemSendAllShipsAway(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool SystemSetSunNova(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSFunctionSpec System_funcs[] = {
{ "AddPlanet", SystemAddPlanet, 1, 0 },
{ "AddMoon", SystemAddMoon, 1, 0 },
{ "SendAllShipsAway", SystemSendAllShipsAway, 1, 0 },
{ "SetSunNova", SystemSetSunNova, 1, 0 },
{ 0 }
};
JSBool SystemAddPlanet(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
NSString *key = JSValToNSString(cx, argv[0]);
[playerEntity addPlanet:key];
}
return JS_TRUE;
}
JSBool SystemAddMoon(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
NSString *key = JSValToNSString(cx, argv[0]);
[playerEntity addMoon:key];
}
return JS_TRUE;
}
JSBool SystemSendAllShipsAway(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity sendAllShipsAway];
return JS_TRUE;
}
JSBool SystemSetSunNova(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0) {
NSString *key = JSValToNSString(cx, argv[0]);
[playerEntity setSunNovaIn:key];
}
return JS_TRUE;
}
static Random_Seed currentSystem;
static NSDictionary *planetinfo = nil;
JSBool SystemGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (!JSVAL_IS_INT(id)) return JS_TRUE;
NSString *str;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
currentSystem = playerEntity->system_seed;
if (planetinfo)
[planetinfo release];
planetinfo = [[scriptedUniverse generateSystemData:currentSystem] retain];
}
switch (JSVAL_TO_INT(id)) {
case SYS_ID:
*vp = INT_TO_JSVAL([[playerEntity planet_number] intValue]);
break;
case SYS_NAME:
str = (NSString *)[planetinfo objectForKey:KEY_NAME];
if (!str)
str = @"None";
NSStringToJSVal(cx, str, vp);
break;
case SYS_DESCRIPTION:
str = (NSString *)[planetinfo objectForKey:KEY_DESCRIPTION];
if (!str)
str = @"None";
NSStringToJSVal(cx, str, vp);
break;
case SYS_INHABITANTS:
str = (NSString *)[planetinfo objectForKey:KEY_INHABITANTS];
if (!str)
str = @"None";
NSStringToJSVal(cx, str, vp);
break;
case SYS_GOING_NOVA:
BOOLToJSVal(cx, [[playerEntity sunWillGoNova_bool] isEqualToString:@"YES"], vp);
break;
case SYS_GONE_NOVA:
BOOLToJSVal(cx, [[playerEntity sunGoneNova_bool] isEqualToString:@"YES"], vp);
break;
case SYS_GOVT_STR:
NSStringToJSVal(cx, [playerEntity systemGovernment_string], vp);
break;
case SYS_GOVT_ID:
JS_NewDoubleValue(cx, [[playerEntity systemGovernment_number] doubleValue], vp);
break;
case SYS_ECONOMY_ID:
JS_NewDoubleValue(cx, [[playerEntity systemEconomy_number] doubleValue], vp);
break;
case SYS_TECH_LVL:
JS_NewDoubleValue(cx, [[playerEntity systemTechLevel_number] doubleValue], vp);
break;
case SYS_POPULATION:
JS_NewDoubleValue(cx, [[playerEntity systemPopulation_number] doubleValue], vp);
break;
case SYS_PRODUCTIVITY:
JS_NewDoubleValue(cx, [[playerEntity systemProductivity_number] doubleValue], vp);
break;
}
return JS_TRUE;
}
JSBool SystemSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (!JSVAL_IS_INT(id)) return JS_TRUE;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
currentSystem = playerEntity->system_seed;
if (planetinfo)
[planetinfo release];
planetinfo = [[scriptedUniverse generateSystemData:currentSystem] retain];
}
int gn = [[playerEntity galaxy_number] intValue];
int pn = [[playerEntity planet_number] intValue];
switch (JSVAL_TO_INT(id)) {
case SYS_NAME:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_NAME value:JSValToNSString(cx, *vp)];
break;
case SYS_DESCRIPTION:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_DESCRIPTION value:JSValToNSString(cx, *vp)];
break;
case SYS_INHABITANTS:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_INHABITANTS value:JSValToNSString(cx, *vp)];
break;
/*
case SYS_GOING_NOVA:
//BOOLToJSVal(cx, [[playerEntity sunWillGoNova_bool] isEqualToString:@"YES"], vp);
break;
case SYS_GONE_NOVA:
//BOOLToJSVal(cx, [[playerEntity sunGoneNova_bool] isEqualToString:@"YES"], vp);
break;
*/
case SYS_GOVT_ID:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_GOVERNMENT value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
break;
case SYS_ECONOMY_ID:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_ECONOMY value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
break;
case SYS_TECH_LVL:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_TECHLEVEL value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
break;
case SYS_POPULATION:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_POPULATION value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
break;
case SYS_PRODUCTIVITY:
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_PRODUCTIVITY value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
break;
}
return JS_TRUE;
}
//===========================================================================
// Mission class
//===========================================================================
JSBool MissionGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSBool MissionSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JSClass Mission_class = {
"Mission", JSCLASS_HAS_PRIVATE,
JS_PropertyStub,JS_PropertyStub,MissionGetProperty,MissionSetProperty,
JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
};
enum Mission_propertyIds {
MISSION_TEXT, MISSION_MUSIC, MISSION_IMAGE, MISSION_CHOICES, MISSION_CHOICE, MISSION_INSTRUCTIONS
};
JSPropertySpec Mission_props[] = {
{ "MissionScreenTextKey", MISSION_TEXT, JSPROP_ENUMERATE },
{ "MusicFilename", MISSION_MUSIC, JSPROP_ENUMERATE },
{ "ImageFilename", MISSION_IMAGE, JSPROP_ENUMERATE },
{ "ChoicesKey", MISSION_CHOICES, JSPROP_ENUMERATE },
{ "Choice", MISSION_CHOICE, JSPROP_ENUMERATE },
{ "InstructionsKey", MISSION_INSTRUCTIONS, JSPROP_ENUMERATE },
{ 0 }
};
JSBool MissionShowMissionScreen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool MissionShowShipModel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool MissionResetMissionChoice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool MissionMarkSystem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool MissionUnmarkSystem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSFunctionSpec Mission_funcs[] = {
{ "ShowMissionScreen", MissionShowMissionScreen, 0, 0 },
{ "ShowShipModel", MissionShowShipModel, 1, 0 },
{ "ResetMissionChoice", MissionResetMissionChoice, 0, 0 },
{ "MarkSystem", MissionMarkSystem, 1, 0 },
{ "UnmarkSystem", MissionUnmarkSystem, 1, 0 },
{ 0 }
};
JSBool MissionGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (!JSVAL_IS_INT(id)) return JS_TRUE;
NSString *str;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
switch (JSVAL_TO_INT(id)) {
case MISSION_CHOICE:
str = (NSString *)[playerEntity missionChoice_string];
if (!str)
str = @"None";
NSStringToJSVal(cx, str, vp);
break;
}
return JS_TRUE;
}
JSBool MissionSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
if (!JSVAL_IS_INT(id)) return JS_TRUE;
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
switch (JSVAL_TO_INT(id)) {
case MISSION_TEXT: {
if (JSVAL_IS_STRING(*vp)) {
JSString *jskey = JS_ValueToString(cx, *vp);
[playerEntity addMissionText: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
}
break;
}
case MISSION_MUSIC: {
if (JSVAL_IS_STRING(*vp)) {
JSString *jskey = JS_ValueToString(cx, *vp);
[playerEntity setMissionMusic: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
}
break;
}
case MISSION_IMAGE: {
if (JSVAL_IS_STRING(*vp)) {
NSString *str = JSValToNSString(cx, *vp);
if ([str length] == 0)
str = @"none";
[playerEntity setMissionImage:str];
}
break;
}
case MISSION_CHOICES: {
if (JSVAL_IS_STRING(*vp)) {
JSString *jskey = JS_ValueToString(cx, *vp);
[playerEntity setMissionChoices: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
}
break;
}
case MISSION_INSTRUCTIONS: {
if (JSVAL_IS_STRING(*vp)) {
JSString *jskey = JS_ValueToString(cx, *vp);
NSString *ins = [NSString stringWithCString:JS_GetStringBytes(jskey)];
if ([ins length])
[playerEntity setMissionDescription:ins forMission:[currentOXPScript name]];
else
[playerEntity clearMissionDescriptionForMission:[currentOXPScript name]];
}
break;
}
}
return JS_TRUE;
}
JSBool MissionShowMissionScreen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity setGuiToMissionScreen];
return JS_TRUE;
}
JSBool MissionShowShipModel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
JSString *jskey = JS_ValueToString(cx, argv[0]);
[playerEntity showShipModel: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
}
return JS_TRUE;
}
JSBool MissionResetMissionChoice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
[playerEntity resetMissionChoice];
return JS_TRUE;
}
JSBool MissionMarkSystem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
return JS_TRUE;
}
JSBool MissionUnmarkSystem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
return JS_TRUE;
}
void reportJSError(JSContext *cx, const char *message, JSErrorReport *report) {
NSLog(@"JavaScript error: %s", message);
NSLog(@"%s:%d: %s", report->filename, report->lineno, report->linebuf);
}
//===========================================================================
// JavaScript engine initialisation and shutdown
//===========================================================================
@implementation ScriptEngine
- (id) initWithUniverse: (Universe *)universe
{
self = [super init];
scriptedUniverse = universe;
/*set up global JS variables, including global and custom objects */
/* initialize the JS run time, and return result in rt */
rt = JS_NewRuntime(8L * 1024L * 1024L);
/* if rt does not have a value, end the program here */
if (!rt) {
[super dealloc];
exit(1); //return nil;
}
/* create a context and associate it with the JS run time */
cx = JS_NewContext(rt, 8192);
NSLog(@"created context");
/* if cx does not have a value, end the program here */
if (cx == NULL) {
[super dealloc];
exit(1); //return nil;
}
JS_SetErrorReporter(cx, reportJSError);
/* create the global object here */
glob = JS_NewObject(cx, &global_class, NULL, NULL);
xglob = glob;
/* initialize the built-in JS objects and the global object */
builtins = JS_InitStandardClasses(cx, glob);
JS_DefineProperties(cx, glob, Global_props);
JS_DefineFunctions(cx, glob, Global_funcs);
universeObj = JS_DefineObject(cx, glob, "Universe", &Universe_class, NULL, JSPROP_ENUMERATE);
//JS_DefineProperties(cx, universeObj, Universe_props);
JS_DefineFunctions(cx, universeObj, Universe_funcs);
systemObj = JS_DefineObject(cx, glob, "System", &System_class, NULL, JSPROP_ENUMERATE);
JS_DefineProperties(cx, systemObj, System_props);
JS_DefineFunctions(cx, systemObj, System_funcs);
playerObj = JS_DefineObject(cx, glob, "Player", &Player_class, NULL, JSPROP_ENUMERATE);
JS_DefineProperties(cx, playerObj, Player_props);
JS_DefineFunctions(cx, playerObj, Player_funcs);
missionObj = JS_DefineObject(cx, glob, "Mission", &Mission_class, NULL, JSPROP_ENUMERATE);
JS_DefineProperties(cx, missionObj, Mission_props);
JS_DefineFunctions(cx, missionObj, Mission_funcs);
return self;
}
- (void) dealloc
{
// free up the OXPScripts too!
JS_DestroyContext(cx);
/* Before exiting the application, free the JS run time */
JS_DestroyRuntime(rt);
[super dealloc];
}
- (JSContext *) context
{
return cx;
}
@end

View File

@ -229,6 +229,7 @@ enum
NSMutableArray* comm_log;
NSMutableDictionary *oxpKeys;
#ifdef GNUSTEP
SDLImage *missionBackgroundImage;
#else
@ -583,6 +584,7 @@ enum
- (void) tidyMissilePylons;
- (void) clearAlert_flags;
- (int) alert_flags;
- (void) setAlert_flag:(int) flag :(BOOL) value;
- (int) alert_condition;
@ -682,6 +684,8 @@ enum
- (BOOL) selectPreviousTargetFromMemory;
- (void) applyYaw:(GLfloat) yaw;
- (void) setCredits: (int)newCredits;
- (void) setKills: (int)newKills;
/* GILES custom viewpoints */
@ -697,6 +701,8 @@ enum
/* -- */
- (void) sendMessageToScripts:(NSString *)message;
- (BOOL)showInfoFlag;
@end

View File

@ -42,6 +42,7 @@ MA 02110-1301, USA.
#import "OOSound.h"
#import "OOColor.h"
#import "OOCacheManager.h"
#import "OXPScript.h"
#ifndef GNUSTEP
#import "Groolite.h"
@ -2846,6 +2847,11 @@ double scoopSoundPlayTime = 0.0;
alert_flags = 0;
}
- (int) alert_flags
{
return alert_flags;
}
- (void) setAlert_flag:(int) flag :(BOOL) value
{
if (value)
@ -2885,7 +2891,10 @@ double scoopSoundPlayTime = 0.0;
[warningSound play];
#endif
}
if (alert_condition != old_alert_condition)
[self sendMessageToScripts:@"AlertConditionChanged"];
return alert_condition;
}
@ -6802,6 +6811,18 @@ OOSound* burnersound;
return NO;
}
// Start of JavaScript object model helpers
- (void) setCredits: (int)newCredits
{
credits = 10 * newCredits;
}
- (void) setKills: (int)newKills
{
ship_kills = newKills;
}
// End of JavaScript object model helpers
- (Quaternion) customViewQuaternion
{
return customViewQuaternion;
@ -6887,4 +6908,23 @@ OOSound* burnersound;
return show_info_flag;
}
- (void) sendMessageToScripts:(NSString *)message
{
int i;
if (oxpKeys == nil)
oxpKeys = [[NSMutableDictionary alloc] init];
for (i = 0; i < [[script allKeys] count]; i++)
{
NSString *missionTitle = (NSString *)[[script allKeys] objectAtIndex:i];
id obj = [script objectForKey:missionTitle];
if ([obj isKindOfClass:[OXPScript class]])
{
OXPScript *jscript = (OXPScript *)obj;
[jscript doEvent:message];
}
}
}
@end

View File

@ -35,6 +35,10 @@ MA 02110-1301, USA.
// -dajt: black ops
#define COMPARISON_UNDEFINED 010
@class OXPScript;
@interface PlayerEntity (Scripting)
- (void) checkScript;
@ -100,6 +104,8 @@ MA 02110-1301, USA.
- (void) setMissionDescription:(NSString *)textKey;
- (void) clearMissionDescription;
- (void) setMissionDescription:(NSString *)textKey forMission:(NSString *)key;
- (void) clearMissionDescriptionForMission:(NSString *)key;
- (void) commsMessage:(NSString *)valueString;
@ -171,6 +177,7 @@ MA 02110-1301, USA.
- (void) setMissionImage: (NSString *)value;
- (void) setFuelLeak: (NSString *)value;
- (NSNumber *)fuel_leak_rate_number;
- (void) setSunNovaIn: (NSString *)time_value;
- (void) launchFromStation;
- (void) blowUpStation;
@ -187,6 +194,9 @@ MA 02110-1301, USA.
- (void) playSound:(NSString *) soundName;
- (BOOL) mapKey:(NSString *) keycode toOXP:(OXPScript *)oxp;
- (void) targetNearestHostile;
/*-----------------------------------------------------*/
- (void) setGuiToMissionScreen;

View File

@ -28,6 +28,8 @@ MA 02110-1301, USA.
#import "ResourceManager.h"
#import "TextureStore.h"
#import "AI.h"
#import "ShipEntityAI.h"
#import "OXPScript.h"
#import "OOSound.h"
#import "OOColor.h"
@ -97,9 +99,18 @@ static NSString * mission_key;
for (i = 0; i < [[script allKeys] count]; i++)
{
NSString *missionTitle = (NSString *)[[script allKeys] objectAtIndex:i];
NSArray *mission = (NSArray *)[script objectForKey:missionTitle];
mission_key = missionTitle;
[self scriptActions: mission forTarget: self];
id obj = [script objectForKey:missionTitle];
if ([obj isKindOfClass:[NSArray class]])
{
NSArray *mission = (NSArray *)[script objectForKey:missionTitle];
mission_key = missionTitle;
[self scriptActions: mission forTarget: self];
}
else if ([obj isKindOfClass:[OXPScript class]])
{
OXPScript *jscript = (OXPScript *)obj;
[jscript doEvent:[self status_string]];
}
}
OOLogOutdentIf(kOOLogNoteCheckScript);
@ -490,6 +501,22 @@ static NSString * mission_key;
[mission_variables removeObjectForKey:mission_key];
}
- (void) setMissionDescription:(NSString *)textKey forMission:(NSString *)key
{
NSString *old_mission_key = mission_key;
mission_key = key;
[self setMissionDescription:textKey];
mission_key = old_mission_key;
}
- (void) clearMissionDescriptionForMission:(NSString *)key
{
NSString *old_mission_key = mission_key;
mission_key = key;
[self clearMissionDescription];
mission_key = old_mission_key;
}
- (NSString *) mission_string
{
return mission_string_value;
@ -1706,6 +1733,11 @@ static int scriptRandomSeed = -1; // ensure proper random function
}
}
- (NSNumber *) fuel_leak_rate_number
{
return [NSNumber numberWithFloat:fuel_leak_rate];
}
- (void) setSunNovaIn: (NSString *)time_value
{
double time_until_nova = [time_value doubleValue];
@ -2233,4 +2265,31 @@ static int scriptRandomSeed = -1; // ensure proper random function
return NO;
}
- (BOOL) mapKey:(NSString *) keycode toOXP:(OXPScript *)oxp
{
OXPScript *s = [oxpKeys objectForKey:keycode];
if (s == nil)
{
[oxpKeys setObject:oxp forKey:keycode];
return YES;
}
return NO;
}
- (void) targetNearestHostile
{
[self scanForHostiles];
if (found_target != NO_TARGET)
{
Entity *ent = [universe entityForUniversalID:found_target];
if (ent != 0x00)
{
ident_engaged = YES;
missile_status = MISSILE_STATUS_TARGET_LOCKED;
[self addTarget:ent];
}
}
}
@end

View File

@ -121,7 +121,7 @@ MA 02110-1301, USA.
#define OOLITE_EXCEPTION_DATA_NOT_FOUND @"OoliteDataNotFoundException"
#define OOLITE_EXCEPTION_FATAL @"OoliteFatalException"
@class TextureStore, GameController, ShipEntity, CollisionRegion;
@class TextureStore, GameController, ShipEntity, CollisionRegion, ScriptEngine;
extern int debug;
@ -252,7 +252,8 @@ extern int debug;
// experimental proc-genned textures
BOOL doProcedurallyTexturedPlanets;
ScriptEngine *scriptEngine;
}
- (id) init;
@ -507,6 +508,8 @@ NSComparisonResult comparePrice( id dict1, id dict2, void * context);
- (void) handleOoliteException:(NSException*) ooliteException;
- (ScriptEngine *) scriptEngine;
// speech routines
//
- (void) startSpeakingString:(NSString *) text;

File diff suppressed because it is too large Load Diff