- the Manifest can now change kilo/grams goods when carrying specialCargo

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3283 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Eric Walch 2010-05-04 18:57:41 +00:00
parent 33c2214bea
commit 525bd1a234

View File

@ -3,7 +3,7 @@
OOJSManifest.m
Oolite
Copyright (C) 2004-2009 Giles C Williams and contributors
Copyright (C) 2004-2010 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -348,6 +348,7 @@ static JSBool ManifestSetProperty(JSContext *context, JSObject *this, jsval name
BOOL OK = NO;
PlayerEntity *entity = OOPlayerForScripting();
int32 iValue;
int commodity;
if (JSVAL_IS_STRING(name)) // Is it a case insensitive commodity identifier?
{
@ -366,13 +367,15 @@ static JSBool ManifestSetProperty(JSContext *context, JSObject *this, jsval name
if (!JSVAL_IS_INT(name)) return YES;
//if (EXPECT_NOT(!JSShipGetShipEntity(context, this, &entity))) return NO;
if ([entity specialCargo])
commodity = JSVAL_TO_INT(name);
if ([entity specialCargo] && (commodity < kManifest_gold || commodity > kManifest_gemStones))
{
OOReportJSWarning(context, @"PlayerShip.manifest['foo'] - cannot modify cargo when Special Cargo is in use.");
return YES;
}
switch (JSVAL_TO_INT(name))
switch (commodity)
{
case kManifest_food:
if (JS_ValueToInt32(context, *value, &iValue))