aboutsummaryrefslogtreecommitdiff
path: root/assets/oldmodels/trackvertical1.b3d
blob: 5620f6057328dbdd4c78a36cda37f8f9bf5640ce (plain)
ofshex dumpascii
0000 42 42 33 44 6d 02 00 00 01 00 00 00 4e 4f 44 45 61 02 00 00 43 75 62 65 00 00 00 00 00 00 00 00 BB3Dm.......NODEa...Cube........
0020 00 00 00 00 00 00 00 80 3f 00 00 80 3f 00 00 80 3f d3 bb 4b b5 00 00 00 00 00 00 80 3f 00 00 00 ........?...?...?..K........?...
0040 00 4d 45 53 48 2c 02 00 00 ff ff ff ff 56 52 54 53 cc 01 00 00 01 00 00 00 01 00 00 00 02 00 00 .MESH,.......VRTS...............
0060 00 57 7e 3c 3f 00 00 00 bf 5c 73 00 3f 92 05 49 3f 7c 01 be 3e fc c1 fd 3e 1f e6 62 3f a1 af 5d .W~<?....\s.?..I?|..>...>..b?..]
0080 3f 71 7e 3c bf 00 00 00 bf 15 73 00 3f 92 05 49 bf 7c 01 be 3e fc c1 fd 3e 20 e6 62 3f 7c 41 09 ?q~<......s.?..I.|..>...>..b?|A.
00a0 3e 0d 00 00 bf 00 00 00 00 20 73 00 3f b4 05 da be 93 8f 49 3f c8 39 e4 3e 9d 47 23 3f fa c2 80 >.........s.?......I?.9.>.G#?...
00c0 3e e9 ff ff 3e 00 00 00 00 51 73 00 3f b4 05 da 3e 93 8f 49 3f c8 39 e4 3e 9f 47 23 3f 80 9e 3f >...>....Qs.?...>..I?.9.>.G#?..?
00e0 3f b7 ff ff be 00 00 00 bf c4 19 ff be f3 81 79 be bc 11 5e 3f bc 11 de be 03 2f a8 3d 00 c3 80 ?..............y...^?...../.=...
0100 3e 0d 00 00 bf 00 00 00 00 20 73 00 3f b4 05 da be 93 8f 49 3f c8 39 e4 3e 9d 47 23 3f fa c2 80 >.........s.?......I?.9.>.G#?...
0120 3e 71 7e 3c bf 00 00 00 bf 15 73 00 3f 92 05 49 bf 7c 01 be 3e fc c1 fd 3e 0f d4 06 3f 00 20 bc >q~<......s.?..I.|..>...>...?...
0140 38 e9 ff ff 3e 00 00 00 00 51 73 00 3f b4 05 da 3e 93 8f 49 3f c8 39 e4 3e 9f 47 23 3f 80 9e 3f 8...>....Qs.?...>..I?.9.>.G#?..?
0160 3f 23 00 00 3f 00 00 00 bf 62 19 ff be f3 81 79 3e bc 11 5e 3f bc 11 de be 0a 2f a8 3d 85 9e 3f ?#..?....b.....y>..^?...../.=..?
0180 3f 57 7e 3c 3f 00 00 00 bf 5c 73 00 3f 92 05 49 3f 7c 01 be 3e fc c1 fd 3e 14 d4 06 3f 20 fa 7f ?W~<?....\s.?..I?|..>...>...?...
01a0 3f 23 00 00 3f 00 00 00 bf 62 19 ff be f3 81 79 3e bc 11 5e 3f bc 11 de be 0a 2f a8 3d 85 9e 3f ?#..?....b.....y>..^?...../.=..?
01c0 3f e9 ff ff 3e 00 00 00 00 51 73 00 3f b4 05 da 3e 93 8f 49 3f c8 39 e4 3e 9f 47 23 3f 80 9e 3f ?...>....Qs.?...>..I?.9.>.G#?..?
01e0 3f 0d 00 00 bf 00 00 00 00 20 73 00 3f b4 05 da be 93 8f 49 3f c8 39 e4 3e 9d 47 23 3f fa c2 80 ?.........s.?......I?.9.>.G#?...
0200 3e b7 ff ff be 00 00 00 bf c4 19 ff be f3 81 79 be bc 11 5e 3f bc 11 de be 03 2f a8 3d 00 c3 80 >..............y...^?...../.=...
0220 3e 54 52 49 53 4c 00 00 00 ff ff ff ff 02 00 00 00 01 00 00 00 00 00 00 00 03 00 00 00 02 00 00 >TRISL..........................
0240 00 00 00 00 00 06 00 00 00 05 00 00 00 04 00 00 00 09 00 00 00 08 00 00 00 07 00 00 00 0c 00 00 ................................
0260 00 0b 00 00 00 0a 00 00 00 0d 00 00 00 0c 00 00 00 0a 00 00 00 .....................
4' href='#n154'>154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
/*
Minetest
Copyright (C) 2013 sapier, <sapier AT gmx DOT net>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <stdio.h>
#include <stdlib.h>

extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}

#include "server.h"
#include "s_async.h"
#include "log.h"
#include "filesys.h"
#include "porting.h"
#include "common/c_internal.h"

/******************************************************************************/
AsyncEngine::AsyncEngine() :
	initDone(false),
	jobIdCounter(0)
{
}

/******************************************************************************/
AsyncEngine::~AsyncEngine()
{

	// Request all threads to stop
	for (std::vector<AsyncWorkerThread *>::iterator it = workerThreads.begin();
			it != workerThreads.end(); it++) {
		(*it)->stop();
	}


	// Wake up all threads
	for (std::vector<AsyncWorkerThread *>::iterator it = workerThreads.begin();
			it != workerThreads.end(); it++) {
		jobQueueCounter.post();
	}

	// Wait for threads to finish
	for (std::vector<AsyncWorkerThread *>::iterator it = workerThreads.begin();
			it != workerThreads.end(); it++) {
		(*it)->wait();
	}

	// Force kill all threads
	for (std::vector<AsyncWorkerThread *>::iterator it = workerThreads.begin();
			it != workerThreads.end(); it++) {
		delete *it;
	}

	jobQueueMutex.lock();
	jobQueue.clear();
	jobQueueMutex.unlock();
	workerThreads.clear();
}

/******************************************************************************/
bool AsyncEngine::registerFunction(const char* name, lua_CFunction func)
{
	if (initDone) {
		return false;
	}
	functionList[name] = func;
	return true;
}

/******************************************************************************/
void AsyncEngine::initialize(unsigned int numEngines)
{
	initDone = true;

	for (unsigned int i = 0; i < numEngines; i++) {
		AsyncWorkerThread *toAdd = new AsyncWorkerThread(this,
			std::string("AsyncWorker-") + itos(i));
		workerThreads.push_back(toAdd);
		toAdd->start();
	}
}

/******************************************************************************/
unsigned int AsyncEngine::queueAsyncJob(std::string func, std::string params)
{
	jobQueueMutex.lock();
	LuaJobInfo toAdd;
	toAdd.id = jobIdCounter++;
	toAdd.serializedFunction = func;
	toAdd.serializedParams = params;

	jobQueue.push_back(toAdd);

	jobQueueCounter.post();

	jobQueueMutex.unlock();

	return toAdd.id;
}

/******************************************************************************/
LuaJobInfo AsyncEngine::getJob()
{
	jobQueueCounter.wait();
	jobQueueMutex.lock();

	LuaJobInfo retval;
	retval.valid = false;

	if (!jobQueue.empty()) {
		retval = jobQueue.front();
		jobQueue.pop_front();
		retval.valid = true;
	}
	jobQueueMutex.unlock();

	return retval;
}

/******************************************************************************/
void AsyncEngine::putJobResult(LuaJobInfo result)
{
	resultQueueMutex.lock();
	resultQueue.push_back(result);
	resultQueueMutex.unlock();
}

/******************************************************************************/
void AsyncEngine::step(lua_State *L)
{
	int error_handler = PUSH_ERROR_HANDLER(L);
	lua_getglobal(L, "core");
	resultQueueMutex.lock();
	while (!resultQueue.empty()) {
		LuaJobInfo jobDone = resultQueue.front();
		resultQueue.pop_front();

		lua_getfield(L, -1, "async_event_handler");

		if (lua_isnil(L, -1)) {
			FATAL_ERROR("Async event handler does not exist!");
		}

		luaL_checktype(L, -1, LUA_TFUNCTION);

		lua_pushinteger(L, jobDone.id);
		lua_pushlstring(L, jobDone.serializedResult.data(),
				jobDone.serializedResult.size());

		PCALL_RESL(L, lua_pcall(L, 2, 0, error_handler));
	}
	resultQueueMutex.unlock();
	lua_pop(L, 2); // Pop core and error handler
}

/******************************************************************************/
void AsyncEngine::pushFinishedJobs(lua_State* L) {
	// Result Table
	MutexAutoLock l(resultQueueMutex);

	unsigned int index = 1;
	lua_createtable(L, resultQueue.size(), 0);
	int top = lua_gettop(L);

	while (!resultQueue.empty()) {
		LuaJobInfo jobDone = resultQueue.front();
		resultQueue.pop_front();

		lua_createtable(L, 0, 2);  // Pre-allocate space for two map fields
		int top_lvl2 = lua_gettop(L);

		lua_pushstring(L, "jobid");
		lua_pushnumber(L, jobDone.id);
		lua_settable(L, top_lvl2);

		lua_pushstring(L, "retval");