summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-04-07 11:46:09 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-04-07 11:46:09 (GMT)
commit8d312ecdfadb7c68d00caf01effe0c1e0a45cb76 (patch)
tree4c9f891c6fb3d4a7cdf58339139dc1359e85b528 /src
parent9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d (diff)
parentf7dd658a301bf22802b72f0d338c6a769e28ed0a (diff)
downloadpowder-8d312ecdfadb7c68d00caf01effe0c1e0a45cb76.zip
powder-8d312ecdfadb7c68d00caf01effe0c1e0a45cb76.tar.gz
Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy
Diffstat (limited to 'src')
-rw-r--r--src/Config.h4
-rw-r--r--src/cat/TPTScriptInterface.cpp58
-rw-r--r--src/cat/TPTScriptInterface.h1
-rw-r--r--src/simulation/Simulation.cpp1
-rw-r--r--src/simulation/elements/CRAY.cpp4
-rw-r--r--src/simulation/elements/SPRK.cpp2
6 files changed, 64 insertions, 6 deletions
diff --git a/src/Config.h b/src/Config.h
index 0cb3b0e..a397902 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -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
diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp
index 601c228..d1a7588 100644
--- a/src/cat/TPTScriptInterface.cpp
+++ b/src/cat/TPTScriptInterface.cpp
@@ -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;
diff --git a/src/cat/TPTScriptInterface.h b/src/cat/TPTScriptInterface.h
index 3cb0b5f..dea284e 100644
--- a/src/cat/TPTScriptInterface.h
+++ b/src/cat/TPTScriptInterface.h
@@ -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);
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index bec937f..7e076ad 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -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;
diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp
index 38c3b9f..3cba72a 100644
--- a/src/simulation/elements/CRAY.cpp
+++ b/src/simulation/elements/CRAY.cpp
@@ -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() {} \ No newline at end of file
+Element_CRAY::~Element_CRAY() {}
diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp
index 8122385..d441455 100644
--- a/src/simulation/elements/SPRK.cpp
+++ b/src/simulation/elements/SPRK.cpp
@@ -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;