Skip to content

Commit

Permalink
Fixed negative parameter in fire() (issue colobot#305)
Browse files Browse the repository at this point in the history
Also fixed checking parameter count and type for ants, spiders and shooters
  • Loading branch information
krzys-h committed Jun 26, 2014
1 parent 2b9abf2 commit bc3b7ef
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/script/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2862,31 +2862,32 @@ 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;

type = pThis->GetType();

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)".
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit bc3b7ef

Please sign in to comment.