aboutsummaryrefslogtreecommitdiff
path: root/src/content_cao.cpp
Commit message (Expand)AuthorAge
...
* Create new instance of mesh every time it's required (Solves #703)Perttu Ahola2014-01-06
* Fix a bug in GenericCAO GENERIC_CMD_UPDATE_POSITION parsing.Ilya Zhuravlev2013-12-13
* Add sneak and sneak_glitch to set_physics_override()PilzAdam2013-12-03
* Add offset to automatic_face_movement_dirPilzAdam2013-09-10
* Send player damage to all clients and apply [brightenPilzAdam2013-08-17
* Add support for entities to automatic face movement directionsapier2013-08-13
* Add support for setting stepheight for entitiessapier2013-07-30
* Add an option to disable object <-> object collision for Lua entitiesPilzAdam2013-07-20
* Fix multiple texture support for animated meshnodesstujones112013-07-10
* Remove texture atlas / AtlasPointer, rename getTextureRaw to getTextureKahrl2013-07-02
* fix objects colliding with its own collision boxessapier2013-04-09
* unkn own block -> unkn own nodekhonkhortisan2013-04-05
* Fix nick completionPilzAdam2013-04-05
* Allow modifying movement speed, jump height and gravity per-player via the Lu...MirceaKitsune2013-04-05
* Fix camera "jumping" when attached and the parent goes too fastZeg92013-04-03
* Closed add object <-> object collision handlingsapier2013-03-28
* Migrate to STL containers/algorithms.Ilya Zhuravlev2013-03-11
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* On-demand item meshes and texturesPerttu Ahola2012-12-02
* Fix forgotten material properties for meshes (also seems to have been forgott...MirceaKitsune2012-11-27
* Proper versioning of new network-serialized stuffPerttu Ahola2012-11-26
* Fix LuaEntitySAO::getClientInitializationData() and bump the related versionPerttu Ahola2012-11-26
* RealBadAngel's patch which allows the lua api to read pressed player keys. Th...MirceaKitsune2012-11-25
* A bunch of fixesMirceaKitsune2012-11-25
* Allow Vanessa's texture filtering / mipmap patch to work on models, as well a...MirceaKitsune2012-11-25
* Fix more things I forgot for attached players. Such players will now properly...MirceaKitsune2012-11-25
* Update attachments at the ending of the addToScene function for parents. And ...MirceaKitsune2012-11-25
* Send animations, bone overrides and attachments in entity initialization. Cli...MirceaKitsune2012-11-25
* Enable client-side attachments, add detachment codeMirceaKitsune2012-11-25
* Fix some remaining issues with attachments, now they work. Tested with object...MirceaKitsune2012-11-25
* Complete the attachment framework.MirceaKitsune2012-11-25
* Framework for the attachment system, new object property which allows changin...MirceaKitsune2012-11-25
* Get the new animation framework properly workingMirceaKitsune2012-11-25
* Joint positioning and rotation code, and fix a problem related to their lua APIMirceaKitsune2012-11-25
* Allow the LUA API to set animations to meshes as well as the animation speed....MirceaKitsune2012-11-25
* Get the mesh working through the memory cache properly. Most credit goes to c...MirceaKitsune2012-11-25
* Add a subfolder for models and transfer models from server to clientMirceaKitsune2012-11-25
* Fix material properties and allow lighting. Models should now be affected by ...MirceaKitsune2012-11-25
* Properly read the mesh from LUA.MirceaKitsune2012-11-25
* 3D model support for players using Irrlicht. Also ready the basis for mesh su...MirceaKitsune2012-11-25
* Fix wielditem entity drawtype brightness controlPerttu Ahola2012-09-09
* Experimental-ish rollback functionalityPerttu Ahola2012-07-27
* Define M_PI on MSVCPerttu Ahola2012-07-21
* Custom boxy nodes (stairs, slabs) and collision changesKahrl2012-06-17
* Properly and efficiently use split utility headersPerttu Ahola2012-06-17
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* Fix fabs() brainfartPerttu Ahola2012-04-07
* Fix MSVC ambiguous fabs() call errorsPerttu Ahola2012-04-07
* Fix visual='cube' sizePerttu Ahola2012-04-04
>(m_database, "COMMIT;", NULL, NULL, NULL) != SQLITE_OK) errorstream<<"WARNING: endSave() failed, map might not have saved."; } void Database_SQLite3::createDirs(std::string path) { if(fs::CreateAllDirs(path) == false) { infostream<<DTIME<<"Database_SQLite3: Failed to create directory " <<"\""<<path<<"\""<<std::endl; throw BaseException("Database_SQLite3 failed to create directory"); } } void Database_SQLite3::verifyDatabase() { if(m_database) return; std::string dbp = m_savedir + DIR_DELIM "map.sqlite"; bool needs_create = false; int d; // Open the database connection createDirs(m_savedir); // ? if(!fs::PathExists(dbp)) needs_create = true; d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); if(d != SQLITE_OK) { errorstream<<"SQLite3 database failed to open: "<<sqlite3_errmsg(m_database)<<std::endl; throw FileNotGoodException("Cannot open database file"); } if(needs_create) createDatabase(); std::string querystr = std::string("PRAGMA synchronous = ") + itos(g_settings->getU16("sqlite_synchronous")); d = sqlite3_exec(m_database, querystr.c_str(), NULL, NULL, NULL); if(d != SQLITE_OK) { errorstream<<"Database pragma set failed: " <<sqlite3_errmsg(m_database)<<std::endl; throw FileNotGoodException("Cannot set pragma"); } d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL); if(d != SQLITE_OK) { errorstream<<"SQLite3 read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl; throw FileNotGoodException("Cannot prepare read statement"); } #ifdef __ANDROID__ d = sqlite3_prepare(m_database, "INSERT INTO `blocks` VALUES(?, ?);", -1, &m_database_write, NULL); #else d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?);", -1, &m_database_write, NULL); #endif if(d != SQLITE_OK) { errorstream<<"SQLite3 write statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl; throw FileNotGoodException("Cannot prepare write statement"); } d = sqlite3_prepare(m_database, "DELETE FROM `blocks` WHERE `pos`=?;", -1, &m_database_delete, NULL); if(d != SQLITE_OK) { infostream<<"WARNING: SQLite3 database delete statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl; throw FileNotGoodException("Cannot prepare delete statement"); } d = sqlite3_prepare(m_database, "SELECT `pos` FROM `blocks`", -1, &m_database_list, NULL); if(d != SQLITE_OK) { infostream<<"SQLite3 list statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl; throw FileNotGoodException("Cannot prepare read statement"); } infostream<<"ServerMap: SQLite3 database opened"<<std::endl; } bool Database_SQLite3::deleteBlock(v3s16 blockpos) { verifyDatabase(); if (sqlite3_bind_int64(m_database_delete, 1, getBlockAsInteger(blockpos)) != SQLITE_OK) { errorstream << "WARNING: Could not bind block position for delete: " << sqlite3_errmsg(m_database) << std::endl; } if (sqlite3_step(m_database_delete) != SQLITE_DONE) { errorstream << "WARNING: deleteBlock: Block failed to delete " << PP(blockpos) << ": " << sqlite3_errmsg(m_database) << std::endl; sqlite3_reset(m_database_delete); return false; } sqlite3_reset(m_database_delete); return true; } bool Database_SQLite3::saveBlock(v3s16 blockpos, std::string &data) { verifyDatabase(); s64 bkey = getBlockAsInteger(blockpos); #ifdef __ANDROID__ /** * Note: For some unknown reason sqlite3 fails to REPLACE blocks on android, * deleting them and inserting first works. */ if (sqlite3_bind_int64(m_database_read, 1, bkey) != SQLITE_OK) { infostream << "WARNING: Could not bind block position for load: " << sqlite3_errmsg(m_database)<<std::endl; } int step_result = sqlite3_step(m_database_read); sqlite3_reset(m_database_read); if (step_result == SQLITE_ROW) { if (sqlite3_bind_int64(m_database_delete, 1, bkey) != SQLITE_OK) { infostream << "WARNING: Could not bind block position for delete: " << sqlite3_errmsg(m_database)<<std::endl; } if (sqlite3_step(m_database_delete) != SQLITE_DONE) { errorstream << "WARNING: saveBlock: Block failed to delete " << PP(blockpos) << ": " << sqlite3_errmsg(m_database) << std::endl; return false; } sqlite3_reset(m_database_delete); } #endif if (sqlite3_bind_int64(m_database_write, 1, bkey) != SQLITE_OK) { errorstream << "WARNING: saveBlock: Block position failed to bind: " << PP(blockpos) << ": " << sqlite3_errmsg(m_database) << std::endl; sqlite3_reset(m_database_write); return false; } if (sqlite3_bind_blob(m_database_write, 2, (void *)data.c_str(), data.size(), NULL) != SQLITE_OK) { errorstream << "WARNING: saveBlock: Block data failed to bind: " << PP(blockpos) << ": " << sqlite3_errmsg(m_database) << std::endl; sqlite3_reset(m_database_write); return false; } if (sqlite3_step(m_database_write) != SQLITE_DONE) { errorstream << "WARNING: saveBlock: Block failed to save " << PP(blockpos) << ": " << sqlite3_errmsg(m_database) << std::endl; sqlite3_reset(m_database_write); return false; } sqlite3_reset(m_database_write); return true; } std::string Database_SQLite3::loadBlock(v3s16 blockpos) { verifyDatabase(); if (sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK) { errorstream << "Could not bind block position for load: " << sqlite3_errmsg(m_database)<<std::endl; } if (sqlite3_step(m_database_read) == SQLITE_ROW) { const char *data = (const char *) sqlite3_column_blob(m_database_read, 0); size_t len = sqlite3_column_bytes(m_database_read, 0); std::string s = ""; if(data) s = std::string(data, len); sqlite3_step(m_database_read); // We should never get more than 1 row, so ok to reset sqlite3_reset(m_database_read); return s; } sqlite3_reset(m_database_read); return ""; } void Database_SQLite3::createDatabase() { int e; assert(m_database); e = sqlite3_exec(m_database, "CREATE TABLE IF NOT EXISTS `blocks` (" "`pos` INT NOT NULL PRIMARY KEY," "`data` BLOB" ");" , NULL, NULL, NULL); if(e != SQLITE_OK) throw FileNotGoodException("Could not create sqlite3 database structure"); else infostream<<"ServerMap: SQLite3 database structure was created"; } void Database_SQLite3::listAllLoadableBlocks(std::list<v3s16> &dst) { verifyDatabase(); while(sqlite3_step(m_database_list) == SQLITE_ROW) { sqlite3_int64 block_i = sqlite3_column_int64(m_database_list, 0); v3s16 p = getIntegerAsBlock(block_i); //dstream<<"block_i="<<block_i<<" p="<<PP(p)<<std::endl; dst.push_back(p); } } #define FINALIZE_STATEMENT(statement) \ if ( statement ) \ rc = sqlite3_finalize(statement); \ if ( rc != SQLITE_OK ) \ errorstream << "Database_SQLite3::~Database_SQLite3():" \ << "Failed to finalize: " << #statement << ": rc=" << rc << std::endl; Database_SQLite3::~Database_SQLite3() { int rc = SQLITE_OK; FINALIZE_STATEMENT(m_database_read) FINALIZE_STATEMENT(m_database_write) FINALIZE_STATEMENT(m_database_list) FINALIZE_STATEMENT(m_database_delete) if(m_database) rc = sqlite3_close(m_database); if (rc != SQLITE_OK) { errorstream << "Database_SQLite3::~Database_SQLite3(): " << "Failed to close database: rc=" << rc << std::endl; } }