summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-06-26 20:41:18 +0200
committerkrzys-h <krzys_h@interia.pl>2014-06-26 21:06:53 +0200
commitbc3b7ef283d5a4f84af352f693a50182571909e7 (patch)
treec893c74236458f2a87d0914d1d803ad19de63525 /src/script
parent2b9abf2a4843d7324de50d1b3d52fa9fcb00b185 (diff)
downloadcolobot-bc3b7ef283d5a4f84af352f693a50182571909e7.tar.gz
colobot-bc3b7ef283d5a4f84af352f693a50182571909e7.tar.bz2
colobot-bc3b7ef283d5a4f84af352f693a50182571909e7.zip
Fixed negative parameter in fire() (issue #305)
Also fixed checking parameter count and type for ants, spiders and shooters
Diffstat (limited to 'src/script')
-rw-r--r--src/script/script.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/script/script.cpp b/src/script/script.cpp
index f97ed08..2299fbf 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -2862,7 +2862,6 @@ bool CScript::rShield(CBotVar* var, CBotVar* result, int& exception, void* user)
CBotTypResult CScript::cFire(CBotVar* &var, void* user)
{
-#if 0
CObject* pThis = static_cast<CObject *>(user);
ObjectType type;
@@ -2870,23 +2869,25 @@ CBotTypResult CScript::cFire(CBotVar* &var, void* user)
if ( type == OBJECT_ANT )
{
- return cOnePoint(var, user);
+ if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
+ CBotTypResult ret = cPoint(var, user);
+ if ( ret.GetType() != 0 ) return ret;
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
}
else if ( type == OBJECT_SPIDER )
{
- return cNull(var, user);
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
}
else
{
- if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GetNext();
- if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
- return CBotTypResult(CBotTypFloat);
+ if ( var != 0 )
+ {
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
+ }
}
-#else
return CBotTypResult(CBotTypFloat);
-#endif
}
// Instruction "fire(delay)".
@@ -2922,6 +2923,7 @@ bool CScript::rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
{
if ( var == 0 ) delay = 0.0f;
else delay = var->GetValFloat();
+ if ( delay < 0.0f ) delay = -delay;
err = script->m_primaryTask->StartTaskFire(delay);
}