Some "old-style" interrupts:
*/
+class InvalidNoiseParamsException : public BaseException {
+public:
+ InvalidNoiseParamsException():
+ BaseException("One or more noise parameters were invalid or require "
+ "too much memory")
+ {}
+
+ InvalidNoiseParamsException(const std::string &s):
+ BaseException(s)
+ {}
+};
+
class InvalidPositionException : public BaseException
{
public:
#include <string.h> // memset
#include "debug.h"
#include "util/numeric.h"
+#include "exceptions.h"
#define NOISE_MAGIC_X 1619
#define NOISE_MAGIC_Y 31337
this->noisebuf = NULL;
resizeNoiseBuf(sz > 1);
- this->buf = new float[sx * sy * sz];
- this->result = new float[sx * sy * sz];
+ try {
+ this->buf = new float[sx * sy * sz];
+ this->result = new float[sx * sy * sz];
+ } catch (std::bad_alloc &e) {
+ throw InvalidNoiseParamsException();
+ }
}
delete[] buf;
delete[] result;
- this->buf = new float[sx * sy * sz];
- this->result = new float[sx * sy * sz];
+ try {
+ this->buf = new float[sx * sy * sz];
+ this->result = new float[sx * sy * sz];
+ } catch (std::bad_alloc &e) {
+ throw InvalidNoiseParamsException();
+ }
}
if (noisebuf)
delete[] noisebuf;
- noisebuf = new float[nlx * nly * nlz];
+ try {
+ noisebuf = new float[nlx * nly * nlz];
+ } catch (std::bad_alloc &e) {
+ throw InvalidNoiseParamsException();
+ }
}
f *= 2.0;
}
-
+
delete[] g;
return result;
}
n->perlinMap2D(p.X, p.Y);
int maplen = n->sx * n->sy;
-
+
lua_newtable(L);
for (int i = 0; i != maplen; i++) {
float noiseval = n->np->offset + n->np->scale * n->result[i];
int maplen = n->sx * n->sy * n->sz;
-
+
lua_newtable(L);
for (int i = 0; i != maplen; i++) {
float noiseval = n->np->offset + n->np->scale * n->result[i];
}
LuaPerlinNoiseMap::LuaPerlinNoiseMap(NoiseParams *np, int seed, v3s16 size) {
- noise = new Noise(np, seed, size.X, size.Y, size.Z);
+ try {
+ noise = new Noise(np, seed, size.X, size.Y, size.Z);
+ } catch (InvalidNoiseParamsException &e) {
+ throw LuaError(e.what());
+ }
}
LuaPerlinNoiseMap::~LuaPerlinNoiseMap()