Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy

This commit is contained in:
Simon Robertshaw 2013-04-07 12:46:09 +01:00
commit 8d312ecdfa
7 changed files with 66 additions and 7 deletions

View File

@ -1 +1,2 @@
SConscript('SConscript', variant_dir='build', duplicate=0)
AddOption('--builddir',dest="builddir",default="build",help="Directory to build to.")
SConscript('SConscript', variant_dir=GetOption('builddir'), duplicate=0)

View File

@ -16,11 +16,11 @@
#endif
#ifndef MINOR_VERSION
#define MINOR_VERSION 1
#define MINOR_VERSION 2
#endif
#ifndef BUILD_NUM
#define BUILD_NUM 262
#define BUILD_NUM 263
#endif
#ifndef SNAPSHOT_ID

View File

@ -85,10 +85,22 @@ ValueType TPTScriptInterface::testType(std::string word)
{
if(rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
goto parsePoint;
else if((rawWord[i] == '#' || rawWord[i] == 'x') &&
((rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
|| (rawWord[i+1] >= 'a' && rawWord[i+1] <= 'f')
|| (rawWord[i+1] >= 'A' && rawWord[i+1] <= 'F')))
goto parseNumberHex;
else
goto parseString;
}
}
parseNumberHex:
i++;
for(; i < word.length(); i++)
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
{
goto parseString;
}
return TypeNumber;
parsePoint:
i++;
@ -102,6 +114,50 @@ ValueType TPTScriptInterface::testType(std::string word)
return TypeString;
}
int TPTScriptInterface::parseNumber(char * stringData)
{
char cc;
int base = 10;
int currentNumber = 0;
if(stringData[0] == '#')
{
stringData++;
base = 16;
}
else if(stringData[0] == '0' && stringData[1] == 'x')
{
stringData+=2;
base = 16;
}
if(base == 16)
{
while(cc = *(stringData++))
{
currentNumber *= base;
if(cc >= '0' && cc <= '9')
currentNumber += cc - '0';
else if(cc >= 'a' && cc <= 'f')
currentNumber += (cc - 'A') + 10;
else if(cc >= 'A' && cc <= 'F')
currentNumber += (cc - 'A') + 10;
else
break;
}
}
else
{
while(cc = *(stringData++))
{
currentNumber *= base;
if(cc >= '0' && cc <= '9')
currentNumber += cc - '0';
else
break;
}
}
return currentNumber;
}
AnyType TPTScriptInterface::eval(std::deque<std::string> * words)
{
if(words->size() < 1)
@ -128,7 +184,7 @@ AnyType TPTScriptInterface::eval(std::deque<std::string> * words)
return tptS_quit(words);
break;
case TypeNumber:
return NumberType(atoi(rawWord));
return NumberType(parseNumber(rawWord));
case TypePoint:
{
int pointX, pointY;

View File

@ -7,6 +7,7 @@
class TPTScriptInterface: public CommandInterface {
protected:
AnyType eval(std::deque<std::string> * words);
int parseNumber(char * stringData);
AnyType tptS_set(std::deque<std::string> * words);
AnyType tptS_create(std::deque<std::string> * words);
AnyType tptS_delete(std::deque<std::string> * words);

View File

@ -2116,6 +2116,7 @@ void Simulation::init_can_move()
can_move[PT_ELEC][PT_BIZRG] = 2;
can_move[PT_PHOT][PT_BIZRS] = 2;
can_move[PT_ELEC][PT_BIZRS] = 2;
can_move[PT_NEUT][PT_INVIS] = 2;
//whol eats anar
can_move[PT_ANAR][PT_WHOL] = 1;

View File

@ -105,7 +105,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
colored = wavelengthToDecoColour(parts[r>>8].ctype);
} else if ((r&0xFF) == PT_CRAY || nostop) {
docontinue = 1;
} else if(destroy && ((r&0xFF) != PT_DMND)) {
} else if(destroy && r && ((r&0xFF) != PT_DMND)) {
sim->kill_part(r>>8);
if(!--partsRemaining)
docontinue = 0;
@ -147,4 +147,4 @@ unsigned int Element_CRAY::wavelengthToDecoColour(int wavelength)
}
Element_CRAY::~Element_CRAY() {}
Element_CRAY::~Element_CRAY() {}

View File

@ -254,7 +254,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
case PT_SWCH:
if (receiver==PT_PSCN||receiver==PT_NSCN||receiver==PT_WATR||receiver==PT_SLTW||receiver==PT_NTCT||receiver==PT_PTCT||receiver==PT_INWR)
continue;
goto conduct;
break;
case PT_ETRD:
if (receiver==PT_METL||receiver==PT_BMTL||receiver==PT_BRMT||receiver==PT_LRBD||receiver==PT_RBDM||receiver==PT_PSCN||receiver==PT_NSCN)
goto conduct;