aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
Commit message (Collapse)AuthorAge
* moved map generator to separate source filesPerttu Ahola2011-06-25
|
* mapgen stuffPerttu Ahola2011-06-25
|
* New map generator added (and SQLite, messed up the commits at that time...) ↵Perttu Ahola2011-06-25
| | | | (import from temporary git repo)
* Changed MapBlockObjects to be never written anymore. Incremented version number.Perttu Ahola2011-06-18
|
* Created and moved stuff to content_nodemeta.{h,cpp}Perttu Ahola2011-06-18
|
* Moved some mapnode content stuff from mapnode.{h,cpp} and digging property ↵Perttu Ahola2011-06-17
| | | | stuff from material.cpp to content_mapnode.{h,cpp}
* made server to send map seed for testingPerttu Ahola2011-06-05
|
* removed a debug print that would flood a lot in some kind of a timeoutPerttu Ahola2011-06-02
|
* Fixed the password crash on WindowsPerttu Ahola2011-06-02
|
* Reduced server CPU usage on NodeMetadata step()s. Also furnace now cooks ↵Perttu Ahola2011-05-31
| | | | while no players are near it.
* Updated licenses of CiaranG's contributions to be in line with the new ↵celeron552011-05-31
| | | | contribution policy and added a TODO note to server.cpp
* auth stuff is now saved only when modifiedPerttu Ahola2011-05-31
|
* removed some debug printsPerttu Ahola2011-05-31
| | | | ...and added support for simple time usage profiling in the last one.
* Reduced the CPU usage of the sent block selector algorithmPerttu Ahola2011-05-31
|
* hopefully fixed the privilege problemsPerttu Ahola2011-05-29
| | | | | --HG-- extra : rebase_source : 9826d20176134a53ff232816a10407465d8c0f50
* player passwords and privileges in world/auth.txtPerttu Ahola2011-05-29
| | | | | --HG-- extra : rebase_source : 7260636295d9068fbeeddf4143c89f2b8a91446c
* Merged CiaranG's fence and fixed two thingsPerttu Ahola2011-05-24
|\
| * Added fences (but still needs an icon or something to display in inventory)Ciaran Gultnieks2011-05-24
| |
| * Added 'shout' player privilegeCiaran Gultnieks2011-05-23
| |
| * Allow default privileges for new players to be set in the server configCiaran Gultnieks2011-05-22
|/
* Added the ability to change your password (via pause menu)Ciaran Gultnieks2011-05-22
| | | | | --HG-- extra : rebase_source : e8ec407f60711d42d33be4811b2880088f617b5b
* Preliminary "active block" stuff + set up test code to grow grass.Perttu Ahola2011-05-22
|
* Passwords - a few corrections to the previous commitCiaran Gultnieks2011-05-20
|
* Passwords - password entry at main menu, stored and checked by serverCiaran Gultnieks2011-05-20
|
* Restored the auto-admin powers of the local user (via name= in the config)Ciaran Gultnieks2011-05-16
| | | | | --HG-- extra : rebase_source : a35aa0d978990c28fa4fc158ce47d1f4aa967c04
* Fixed two compiler warningsPerttu Ahola2011-05-16
|
* Server commands without classesCiaran Gultnieks2011-05-16
|
* Better synchronisation of build/mine attempts when the player isn't allowed toCiaran Gultnieks2011-05-16
|
* Improved server commands and added player permissions.Ciaran Gultnieks2011-05-16
| | | | | --HG-- extra : rebase_source : 178fe08f10b7de3ebaba088bd24faad795114216
* Added glass, with rendering and furnace support.Ciaran Gultnieks2011-05-09
|
* random comment updatesPerttu Ahola2011-04-30
|
* Maybe fixed the flood of "WARNING: StaticObjectList::remove(): id=13 not ↵Perttu Ahola2011-04-29
| | | | found" style debug messages on the server when a player has quit.
* tested out and commented out some new stuff for the terrain generator, to be ↵Perttu Ahola2011-04-26
| | | | used in the future.
* Optimized map saving and sending (server-side)Perttu Ahola2011-04-26
|
* Added /#time <int> command to server for changing the time of dayPerttu Ahola2011-04-25
|
* fix to the previous commitPerttu Ahola2011-04-25
|
* server to print version in chatPerttu Ahola2011-04-25
|
* Updated to-do list and added the give_initial_stuff setting for testingPerttu Ahola2011-04-22
|
* Some work-in-progress in hp and mobs and a frightening amount of random fixes.Perttu Ahola2011-04-21
|
* item drop multiplication fixPerttu Ahola2011-04-19
|
* fixingPerttu Ahola2011-04-12
|
* Fixed some problems with crafting and inventoryPerttu Ahola2011-04-11
|
* fixed warnings reported by cppcheckPerttu Ahola2011-04-11
|
* Fixed error reported by cppcheck:Perttu Ahola2011-04-11
| | | | [./server.cpp:1327]: (error) Possible null pointer dereference: obj - otherwise it is redundant to check if obj is null at line 1332
* better support for old mapsPerttu Ahola2011-04-10
|
* Map generation is now properly threaded and doesn't block block placement ↵Perttu Ahola2011-04-10
| | | | and other stuff.
* a commit before starting to reorganize the map loading/generation logicPerttu Ahola2011-04-10
|
* implemented rats in new system to verify that it worksPerttu Ahola2011-04-10
|
* items now fall by gravity... also some other random updatingPerttu Ahola2011-04-10
|
* new object systemPerttu Ahola2011-04-10
|
an>event.GUIEvent.Caller == this) is_dragging = false; break; case EET_MOUSE_INPUT_EVENT: { const core::position2di p(event.MouseInput.X, event.MouseInput.Y); bool is_inside = isPointInside(p); switch (event.MouseInput.Event) { case EMIE_MOUSE_WHEEL: if (Environment->hasFocus(this)) { s8 d = event.MouseInput.Wheel < 0 ? -1 : 1; s8 h = is_horizontal ? 1 : -1; setPos(getPos() + (d * small_step * h)); SEvent e; e.EventType = EET_GUI_EVENT; e.GUIEvent.Caller = this; e.GUIEvent.Element = nullptr; e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; Parent->OnEvent(e); return true; } break; case EMIE_LMOUSE_PRESSED_DOWN: { if (is_inside) { is_dragging = true; dragged_by_slider = slider_rect.isPointInside(p); core::vector2di corner = slider_rect.UpperLeftCorner; drag_offset = is_horizontal ? p.X - corner.X : p.Y - corner.Y; tray_clicked = !dragged_by_slider; if (tray_clicked) { const s32 new_pos = getPosFromMousePos(p); const s32 old_pos = scroll_pos; setPos(new_pos); // drag in the middle drag_offset = thumb_size / 2; // report the scroll event if (scroll_pos != old_pos && Parent) { SEvent e; e.EventType = EET_GUI_EVENT; e.GUIEvent.Caller = this; e.GUIEvent.Element = nullptr; e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; Parent->OnEvent(e); } } Environment->setFocus(this); return true; } break; } case EMIE_LMOUSE_LEFT_UP: case EMIE_MOUSE_MOVED: { if (!event.MouseInput.isLeftPressed()) is_dragging = false; if (!is_dragging) { if (event.MouseInput.Event == EMIE_MOUSE_MOVED) break; return is_inside; } if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) is_dragging = false; // clang-format off if (!dragged_by_slider) { if (is_inside) { dragged_by_slider = slider_rect.isPointInside(p); tray_clicked = !dragged_by_slider; } if (!dragged_by_slider) { tray_clicked = false; if (event.MouseInput.Event == EMIE_MOUSE_MOVED) return is_inside; } } // clang-format on const s32 new_pos = getPosFromMousePos(p); const s32 old_pos = scroll_pos; setPos(new_pos); if (scroll_pos != old_pos && Parent) { SEvent e; e.EventType = EET_GUI_EVENT; e.GUIEvent.Caller = this; e.GUIEvent.Element = nullptr; e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; Parent->OnEvent(e); } return is_inside; } default: break; } } break; default: break; } } return IGUIElement::OnEvent(event); } void GUIScrollBar::draw() { if (!IsVisible) return; IGUISkin *skin = Environment->getSkin(); if (!skin) return; video::SColor icon_color = skin->getColor( isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL); if (icon_color != current_icon_color) refreshControls(); slider_rect = AbsoluteRect; skin->draw2DRectangle(this, skin->getColor(EGDC_SCROLLBAR), slider_rect, &AbsoluteClippingRect); if (core::isnotzero(range())) { if (is_horizontal) { slider_rect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + draw_center - thumb_size / 2; slider_rect.LowerRightCorner.X = slider_rect.UpperLeftCorner.X + thumb_size; } else { slider_rect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + draw_center - thumb_size / 2; slider_rect.LowerRightCorner.Y = slider_rect.UpperLeftCorner.Y + thumb_size; } skin->draw3DButtonPaneStandard(this, slider_rect, &AbsoluteClippingRect); } IGUIElement::draw(); } void GUIScrollBar::updateAbsolutePosition() { IGUIElement::updateAbsolutePosition(); refreshControls(); setPos(scroll_pos); } s32 GUIScrollBar::getPosFromMousePos(const core::position2di &pos) const { s32 w, p; s32 offset = dragged_by_slider ? drag_offset : thumb_size / 2; if (is_horizontal) { w = RelativeRect.getWidth() - border_size * 2 - thumb_size; p = pos.X - AbsoluteRect.UpperLeftCorner.X - border_size - offset; } else { w = RelativeRect.getHeight() - border_size * 2 - thumb_size; p = pos.Y - AbsoluteRect.UpperLeftCorner.Y - border_size - offset; } return core::isnotzero(range()) ? s32(f32(p) / f32(w) * range() + 0.5f) + min_pos : 0; } void GUIScrollBar::setPos(const s32 &pos) { s32 thumb_area = 0; s32 thumb_min = 0; if (is_horizontal) { thumb_min = RelativeRect.getHeight(); thumb_area = RelativeRect.getWidth() - border_size * 2; } else { thumb_min = RelativeRect.getWidth(); thumb_area = RelativeRect.getHeight() - border_size * 2; } if (is_auto_scaling) thumb_size = s32(thumb_area / (f32(page_size) / f32(thumb_area + border_size * 2))); thumb_size = core::s32_clamp(thumb_size, thumb_min, thumb_area); scroll_pos = core::s32_clamp(pos, min_pos, max_pos); f32 f = core::isnotzero(range()) ? (f32(thumb_area) - f32(thumb_size)) / range() : 1.0f; draw_center = s32((f32(scroll_pos - min_pos) * f) + (f32(thumb_size) * 0.5f)) + border_size; } void GUIScrollBar::setSmallStep(const s32 &step) { small_step = step > 0 ? step : 10; } void GUIScrollBar::setLargeStep(const s32 &step) { large_step = step > 0 ? step : 50; } void GUIScrollBar::setMax(const s32 &max) { max_pos = max; if (min_pos > max_pos) min_pos = max_pos; bool enable = core::isnotzero(range()); up_button->setEnabled(enable); down_button->setEnabled(enable); setPos(scroll_pos); } void GUIScrollBar::setMin(const s32 &min) { min_pos = min; if (max_pos < min_pos) max_pos = min_pos; bool enable = core::isnotzero(range()); up_button->setEnabled(enable); down_button->setEnabled(enable); setPos(scroll_pos); } void GUIScrollBar::setPageSize(const s32 &size) { page_size = size; setPos(scroll_pos); } void GUIScrollBar::setArrowsVisible(ArrowVisibility visible) { arrow_visibility = visible; refreshControls(); } s32 GUIScrollBar::getPos() const { return scroll_pos; } void GUIScrollBar::refreshControls() { IGUISkin *skin = Environment->getSkin(); IGUISpriteBank *sprites = nullptr; current_icon_color = video::SColor(255, 255, 255, 255); if (skin) { sprites = skin->getSpriteBank(); current_icon_color = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL); } if (is_horizontal) { s32 h = RelativeRect.getHeight(); border_size = RelativeRect.getWidth() < h * 4 ? 0 : h; if (!up_button) { up_button = Environment->addButton( core::rect<s32>(0, 0, h, h), this); up_button->setSubElement(true); up_button->setTabStop(false); } if (sprites) { up_button->setSpriteBank(sprites); up_button->setSprite(EGBS_BUTTON_UP, s32(skin->getIcon(EGDI_CURSOR_LEFT)), current_icon_color); up_button->setSprite(EGBS_BUTTON_DOWN, s32(skin->getIcon(EGDI_CURSOR_LEFT)), current_icon_color); } up_button->setRelativePosition(core::rect<s32>(0, 0, h, h)); up_button->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); if (!down_button) { down_button = Environment->addButton( core::rect<s32>(RelativeRect.getWidth() - h, 0, RelativeRect.getWidth(), h), this); down_button->setSubElement(true); down_button->setTabStop(false); } if (sprites) { down_button->setSpriteBank(sprites); down_button->setSprite(EGBS_BUTTON_UP, s32(skin->getIcon(EGDI_CURSOR_RIGHT)), current_icon_color); down_button->setSprite(EGBS_BUTTON_DOWN, s32(skin->getIcon(EGDI_CURSOR_RIGHT)), current_icon_color); } down_button->setRelativePosition( core::rect<s32>(RelativeRect.getWidth() - h, 0, RelativeRect.getWidth(), h)); down_button->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); } else { s32 w = RelativeRect.getWidth(); border_size = RelativeRect.getHeight() < w * 4 ? 0 : w; if (!up_button) { up_button = Environment->addButton( core::rect<s32>(0, 0, w, w), this); up_button->setSubElement(true); up_button->setTabStop(false); } if (sprites) { up_button->setSpriteBank(sprites); up_button->setSprite(EGBS_BUTTON_UP, s32(skin->getIcon(EGDI_CURSOR_UP)), current_icon_color); up_button->setSprite(EGBS_BUTTON_DOWN, s32(skin->getIcon(EGDI_CURSOR_UP)), current_icon_color); } up_button->setRelativePosition(core::rect<s32>(0, 0, w, w)); up_button->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); if (!down_button) { down_button = Environment->addButton( core::rect<s32>(0, RelativeRect.getHeight() - w, w, RelativeRect.getHeight()), this); down_button->setSubElement(true); down_button->setTabStop(false); } if (sprites) { down_button->setSpriteBank(sprites); down_button->setSprite(EGBS_BUTTON_UP, s32(skin->getIcon(EGDI_CURSOR_DOWN)), current_icon_color); down_button->setSprite(EGBS_BUTTON_DOWN, s32(skin->getIcon(EGDI_CURSOR_DOWN)), current_icon_color); } down_button->setRelativePosition( core::rect<s32>(0, RelativeRect.getHeight() - w, w, RelativeRect.getHeight())); down_button->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); } bool visible; if (arrow_visibility == DEFAULT) visible = (border_size != 0); else if (arrow_visibility == HIDE) { visible = false; border_size = 0; } else { visible = true; if (is_horizontal) border_size = RelativeRect.getHeight(); else border_size = RelativeRect.getWidth(); } up_button->setVisible(visible); down_button->setVisible(visible); }