make paged things flip to first page when pressing next on the last page
This commit is contained in:
parent
5201720e5e
commit
12a9445e14
|
@ -465,15 +465,20 @@ bool CreativeChestNodeMetadata::receiveFields(std::string formname, std::map<std
|
|||
{
|
||||
if (fields["prev"] == "" && fields["next"] == "")
|
||||
return false;
|
||||
if (fields["prev"] != "")
|
||||
m_page--;
|
||||
std::vector<content_t> &list = lists::get("creative");
|
||||
if (fields["prev"] != "") {
|
||||
if (m_page > 0) {
|
||||
m_page--;
|
||||
}else{
|
||||
m_page = list.size()/32;
|
||||
}
|
||||
}
|
||||
if (fields["next"] != "")
|
||||
m_page++;
|
||||
if (m_page < 0)
|
||||
m_page = 0;
|
||||
std::vector<content_t> &list = lists::get("creative");
|
||||
if (m_page > (list.size()/32))
|
||||
m_page = list.size()/32;
|
||||
m_page = 0;
|
||||
InventoryList *l = m_inventory->getList("0");
|
||||
InventoryItem *t;
|
||||
l->clearItems();
|
||||
|
@ -1397,13 +1402,18 @@ bool CraftGuideNodeMetadata::receiveFields(std::string formname, std::map<std::s
|
|||
}
|
||||
if (fields["prev"] == "" && fields["next"] == "")
|
||||
return false;
|
||||
if (fields["prev"] != "" && m_page > 0)
|
||||
m_page--;
|
||||
std::vector<content_t> &list = lists::get("craftguide");
|
||||
if (fields["prev"] != "") {
|
||||
if (m_page > 0) {
|
||||
m_page--;
|
||||
}else{
|
||||
m_page = list.size()/40;
|
||||
}
|
||||
}
|
||||
if (fields["next"] != "")
|
||||
m_page++;
|
||||
std::vector<content_t> &list = lists::get("craftguide");
|
||||
if (m_page > (list.size()/40))
|
||||
m_page = list.size()/40;
|
||||
m_page = 0;
|
||||
content_t *r;
|
||||
l->clearItems();
|
||||
u16 start = m_page*40;
|
||||
|
@ -1597,15 +1607,18 @@ bool CookBookNodeMetadata::receiveFields(std::string formname, std::map<std::str
|
|||
{
|
||||
if (fields["prev"] == "" && fields["next"] == "")
|
||||
return false;
|
||||
if (fields["prev"] != "")
|
||||
m_page--;
|
||||
std::vector<content_t> &list = lists::get("cooking");
|
||||
if (fields["prev"] != "") {
|
||||
if (m_page > 0) {
|
||||
m_page--;
|
||||
}else{
|
||||
m_page = list.size()/40;
|
||||
}
|
||||
}
|
||||
if (fields["next"] != "")
|
||||
m_page++;
|
||||
if (m_page < 0)
|
||||
m_page = 0;
|
||||
std::vector<content_t> &list = lists::get("cooking");
|
||||
if (m_page > (list.size()/40))
|
||||
m_page = list.size()/40;
|
||||
m_page = 0;
|
||||
InventoryList *l = m_inventory->getList("list");
|
||||
InventoryItem *t;
|
||||
l->clearItems();
|
||||
|
@ -1812,15 +1825,18 @@ bool DeCraftNodeMetadata::receiveFields(std::string formname, std::map<std::stri
|
|||
{
|
||||
if (fields["prev"] == "" && fields["next"] == "")
|
||||
return false;
|
||||
if (fields["prev"] != "")
|
||||
m_page--;
|
||||
std::vector<content_t> &list = lists::get("decrafting");
|
||||
if (fields["prev"] != "") {
|
||||
if (m_page > 0) {
|
||||
m_page--;
|
||||
}else{
|
||||
m_page = list.size()/40;
|
||||
}
|
||||
}
|
||||
if (fields["next"] != "")
|
||||
m_page++;
|
||||
if (m_page < 0)
|
||||
m_page = 0;
|
||||
std::vector<content_t> &list = lists::get("decrafting");
|
||||
if (m_page > (list.size()/40))
|
||||
m_page = list.size()/40;
|
||||
m_page = 0;
|
||||
InventoryList *l = m_inventory->getList("list");
|
||||
InventoryItem *t;
|
||||
l->clearItems();
|
||||
|
|
|
@ -2513,7 +2513,7 @@ void ServerMap::verifyDatabase() {
|
|||
d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
|
||||
if(d != SQLITE_OK) {
|
||||
infostream<<"WARNING: Database failed to open: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||
throw FileNotGoodException("Cannot open database file");
|
||||
throw FileNotGoodException("map.sqlite: Cannot open database file");
|
||||
}
|
||||
|
||||
if(needs_create)
|
||||
|
@ -2522,19 +2522,19 @@ void ServerMap::verifyDatabase() {
|
|||
d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
|
||||
if(d != SQLITE_OK) {
|
||||
infostream<<"WARNING: Database read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||
throw FileNotGoodException("Cannot prepare read statement");
|
||||
throw FileNotGoodException("map.sqlite: Cannot prepare read statement");
|
||||
}
|
||||
|
||||
d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?)", -1, &m_database_write, NULL);
|
||||
if(d != SQLITE_OK) {
|
||||
infostream<<"WARNING: Database write statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||
throw FileNotGoodException("Cannot prepare write statement");
|
||||
throw FileNotGoodException("map.sqlite: Cannot prepare write statement");
|
||||
}
|
||||
|
||||
d = sqlite3_prepare(m_database, "SELECT `pos` FROM `blocks`", -1, &m_database_list, NULL);
|
||||
if(d != SQLITE_OK) {
|
||||
infostream<<"WARNING: Database list statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||
throw FileNotGoodException("Cannot prepare read statement");
|
||||
throw FileNotGoodException("map.sqlite: Cannot prepare read statement");
|
||||
}
|
||||
|
||||
infostream<<"Server: Database opened"<<std::endl;
|
||||
|
|
Loading…
Reference in New Issue