aboutsummaryrefslogtreecommitdiff
path: root/advtrains/init.lua
Commit message (Collapse)AuthorAge
* Add "routingcode" propertyorwell962019-01-09
| | | | Used for ARS and stop points
* Shunt signals (not exactly Ks), along with fixes in other components that ↵orwell962018-12-08
| | | | those rely on
* Added on_train_approach callback, non-permanent external LZB brakepoints and ↵orwell962018-11-29
| | | | | | basis for "stop rails" Stop rails ATM use the aforementioned things to add a pointwise "2" speed restriction. Seems to work.
* Fix protection regarding tracks (track_builder and railway_operator) and ↵orwell962018-11-12
| | | | documentation on privileges
* Increase savefile version to 2orwell962018-11-10
| | | | (Master downgrade protection)
* Remove "couple locks" and apply protection to the actual coupling process, ↵orwell962018-11-10
| | | | and fix permissions on that
* atdump() to treat certain values specialorwell962018-10-29
|
* Properly handle speed restrictionsorwell962018-10-10
|
* Add signal safety control override, restructure control systemorwell962018-10-10
|
* Improve route programming:orwell962018-10-07
| | | | | | | - Formspec for TCBs instead of unhandy chatcommands - Ability to advance route over the next secction without punching end - Better visualization - Ability to route into dead-end sections
* Add interlocking guide/manual, silence debug outputsorwell962018-09-14
|
* Move passive API to the advtrains coreorwell962018-08-16
| | | | to remove dependency of interlocking on luaautomation
* Remove redundant digtron.lua fileGabriel Pérez-Cerezo2018-08-12
|
* Add routesetting callbacks.orwell962018-08-12
| | | | Now, only the signal aspect setting is still missing
* Implement trains blocking sectionsorwell962018-06-29
|
* Complete Track Section handling, incl. removing tcb's and marker entitiesorwell962018-06-26
|
* Add track section concept and rework TCB design, implement new linking behaviororwell962018-06-21
|
* Check for inventory existence before serializing, and do not create it again ↵orwell962018-06-19
| | | | if it already exists.
* Fix box wagon inventory serialization and make box wagons protected.orwell962018-06-14
|
* Fix bugs found while testingorwell962018-06-14
|
* Fix final bugs and to-do's (u.a.save/load system)orwell962018-06-14
|
* Fix yaw calculations, track placement orientation and speed up direction ↵orwell962018-06-14
| | | | lookup functions
* Implement collisions. (does not work yet, still code errors)orwell962018-06-14
|
* Fix path_dir to actually be an angle, path item deletion and orientation of ↵orwell962018-06-14
| | | | | | | | wagons The occupation system as it is now will change. For each position, I will save the index in the train's path, and implement a callback system. I need this because the occupation window system will not be enough to cover all use cases (e.g. to make a train stop with it's center or back at a certain position, I need 3 different brake distances, which doesn't fit into the scheme)
* Bugfixes part 1orwell962018-06-14
| | | | There's something wrong with the new paths, next time build a path validity checker to trace the issue
* Restructure path systemorwell962018-06-14
| | | | The changes to the path system have not yet been integrated...
* Merge branch 'master' of https://github.com/orwell96/advtrainsGabriel Pérez-Cerezo2018-06-10
|\
| * Rework the privilege system completelyorwell962018-03-14
| | | | | | | | See privilege_guide.txt for information
* | Merge https://github.com/orwell96/advtrains into logGabriel Pérez-Cerezo2018-02-22
|\|
| * Log certain events in a logfile in the world directoryGabriel Pérez-Cerezo2018-02-21
| | | | | | | | (also fix the output of /at_sync_ndb)
* | added separate logging for railway networksGabriel Pérez-Cerezo2018-02-18
|/
* Simplify /at_rerouteorwell962018-01-23
| | | | It is not necessary to reload the save files, because there already is a function to invalidate train routes e.g. when turnouts are switched
* Add bord computer to trainsorwell962018-01-09
| | | | | | | | Features: - couple/decouple trains from a driver stand - new couple lock system (owner based, overridable by 'train_remove' privilege) - all train operators can now change the inside/outside text, allows for multilines Accessible via right-click menu or by pressing Sneak+Jump keys
* Change controls for trains (again)orwell962018-01-07
|
* Decrease the amount of garbage saved in save filesorwell962018-01-07
|
* Rewrite rail connection system...orwell962017-12-18
| | | | | | | | | ...to support an arbitrary number of connections for rails, which leads to these new features: - switches now get recognized by the trackworker correctly - ability to add real rail crosses During this, I also rewrote the rail registering system and the conway function (important part of path prediction) Note, developers: the track preset format changed, you might need to rewrite them according to the presets in tracks.lua if you wrote your own (possibly breaks advcarts)
* Move train_load() function into advtrains_train_trackorwell962017-12-18
|
* Add modifiable wagon extentsorwell962017-11-23
| | | | This will be required for advcarts
* Replace many math.floor(x+0.5) calls (or math.floor calls that should be ↵orwell962017-10-25
| | | | those) by custom atround() function
* Fix coupling and collisions in certain casesorwell962017-10-25
| | | | | | If a train moved towards another train, and the other train's step was executed after the first one's, the trains did eventually not collide. Fix by moving the enter_node and collision check to step_b Also change some couple behavior
* Fix error cascade due to inexistent drb_dump when debugging is disabledorwell962017-10-11
|
* Remove zip release files, move mod to root, exclude assets from Makefile (#92)rubenwardy2017-09-20
|
* Restructure mod directoryorwell962017-01-04
|
* Do not duplicate definitions of 'print' in every fileorwell962017-01-02
|
* Turning mod into a modpack and separating the trains from the core modorwell962016-12-20
s="hl kwc">irr::video::EMF_COLOR_MASK; driver->getOverrideMaterial().EnablePasses = irr::scene::ESNRP_SKY_BOX + irr::scene::ESNRP_SOLID + irr::scene::ESNRP_TRANSPARENT + irr::scene::ESNRP_TRANSPARENT_EFFECT + irr::scene::ESNRP_SHADOW; camera.getCameraNode()->setPosition(leftEye); camera.getCameraNode()->setTarget(focusPoint); smgr->drawAll(); driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); if (show_hud) { draw_selectionbox(driver, hud, hilightboxes, show_hud); if (draw_wield_tool) camera.drawWieldedTool(&leftMove); } guienv->drawAll(); //Right eye... irr::core::vector3df rightEye; irr::core::matrix4 rightMove; rightMove.setTranslation( irr::core::vector3df(g_settings->getFloat("3d_paralax_strength"), 0.0f, 0.0f)); rightEye = (startMatrix * rightMove).getTranslation(); //clear the depth buffer driver->clearZBuffer(); driver->getOverrideMaterial().Material.ColorMask = irr::video::ECP_GREEN + irr::video::ECP_BLUE; driver->getOverrideMaterial().EnableFlags = irr::video::EMF_COLOR_MASK; driver->getOverrideMaterial().EnablePasses = irr::scene::ESNRP_SKY_BOX + irr::scene::ESNRP_SOLID + irr::scene::ESNRP_TRANSPARENT + irr::scene::ESNRP_TRANSPARENT_EFFECT + irr::scene::ESNRP_SHADOW; camera.getCameraNode()->setPosition(rightEye); camera.getCameraNode()->setTarget(focusPoint); smgr->drawAll(); driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); if (show_hud) { draw_selectionbox(driver, hud, hilightboxes, show_hud); if (draw_wield_tool) camera.drawWieldedTool(&rightMove); } guienv->drawAll(); driver->getOverrideMaterial().Material.ColorMask = irr::video::ECP_ALL; driver->getOverrideMaterial().EnableFlags = 0; driver->getOverrideMaterial().EnablePasses = 0; camera.getCameraNode()->setPosition(oldPosition); camera.getCameraNode()->setTarget(oldTarget); } void init_texture(video::IVideoDriver* driver, const v2u32& screensize, video::ITexture** texture) { static v2u32 last_screensize = v2u32(0,0); if (( *texture == NULL ) || (screensize != last_screensize)) { if (*texture != NULL) { driver->removeTexture(*texture); } *texture = driver->addRenderTargetTexture( core::dimension2d<u32>(screensize.X, screensize.Y)); last_screensize = screensize; } } video::ITexture* draw_image(const v2u32& screensize, paralax_sign psign, const irr::core::matrix4& startMatrix, const irr::core::vector3df& focusPoint, bool show_hud, video::IVideoDriver* driver, Camera& camera, scene::ISceneManager* smgr, Hud& hud, std::vector<aabb3f>& hilightboxes, bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv, video::SColor skycolor ) { static video::ITexture* images[2] = { NULL, NULL }; video::ITexture* image = NULL; if (psign == RIGHT) { init_texture(driver, screensize, &images[1]); image = images[1]; } else { init_texture(driver, screensize, &images[0]); image = images[0]; } driver->setRenderTarget(image, true, true, irr::video::SColor(255, skycolor.getRed(), skycolor.getGreen(), skycolor.getBlue())); irr::core::vector3df eye_pos; irr::core::matrix4 movement; movement.setTranslation( irr::core::vector3df((int) psign * g_settings->getFloat("3d_paralax_strength"), 0.0f, 0.0f)); eye_pos = (startMatrix * movement).getTranslation(); //clear the depth buffer driver->clearZBuffer(); camera.getCameraNode()->setPosition(eye_pos); camera.getCameraNode()->setTarget(focusPoint); smgr->drawAll(); driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); if (show_hud) { draw_selectionbox(driver, hud, hilightboxes, show_hud); if (draw_wield_tool) camera.drawWieldedTool(&movement); } guienv->drawAll(); /* switch back to real renderer */ driver->setRenderTarget(0, true, true, irr::video::SColor(0, skycolor.getRed(), skycolor.getGreen(), skycolor.getBlue())); return image; } video::ITexture* draw_hud(video::IVideoDriver* driver, const v2u32& screensize, bool show_hud, Hud& hud, Client& client, bool draw_crosshair, video::SColor skycolor, gui::IGUIEnvironment* guienv, Camera& camera ) { static video::ITexture* image = NULL; init_texture(driver, screensize, &image); driver->setRenderTarget(image, true, true, irr::video::SColor(255,0,0,0)); if (show_hud) { if (draw_crosshair) hud.drawCrosshair(); hud.drawHotbar(client.getPlayerItem()); hud.drawLuaElements(camera.getOffset()); guienv->drawAll(); } driver->setRenderTarget(0, true, true, irr::video::SColor(0, skycolor.getRed(), skycolor.getGreen(), skycolor.getBlue())); return image; } void draw_interlaced_3d_mode(Camera& camera, bool show_hud, Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver, scene::ISceneManager* smgr, const v2u32& screensize, bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv, video::SColor skycolor ) { /* save current info */ irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition(); irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget(); irr::core::matrix4 startMatrix = camera.getCameraNode()->getAbsoluteTransformation(); irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget() - camera.getCameraNode()->getAbsolutePosition()).setLength(1) + camera.getCameraNode()->getAbsolutePosition(); /* create left view */ video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix, focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes, draw_wield_tool, client, guienv, skycolor); //Right eye... irr::core::vector3df rightEye; irr::core::matrix4 rightMove; rightMove.setTranslation( irr::core::vector3df(g_settings->getFloat("3d_paralax_strength"), 0.0f, 0.0f)); rightEye = (startMatrix * rightMove).getTranslation(); //clear the depth buffer driver->clearZBuffer(); camera.getCameraNode()->setPosition(rightEye); camera.getCameraNode()->setTarget(focusPoint); smgr->drawAll(); driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); if (show_hud) { draw_selectionbox(driver, hud, hilightboxes, show_hud); if(draw_wield_tool) camera.drawWieldedTool(&rightMove); } guienv->drawAll(); for (unsigned int i = 0; i < screensize.Y; i+=2 ) { driver->draw2DImage(left_image, irr::core::position2d<s32>(0, screensize.Y-i), irr::core::rect<s32>(0, i,screensize.X, i+1), 0, irr::video::SColor(255, 255, 255, 255), false); } /* cleanup */ camera.getCameraNode()->setPosition(oldPosition); camera.getCameraNode()->setTarget(oldTarget); } void draw_sidebyside_3d_mode(Camera& camera, bool show_hud, Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver, scene::ISceneManager* smgr, const v2u32& screensize, bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv, video::SColor skycolor ) { /* save current info */ irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition(); irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget(); irr::core::matrix4 startMatrix = camera.getCameraNode()->getAbsoluteTransformation(); irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget() - camera.getCameraNode()->getAbsolutePosition()).setLength(1) + camera.getCameraNode()->getAbsolutePosition(); /* create left view */ video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix, focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes, draw_wield_tool, client, guienv, skycolor); /* create right view */ video::ITexture* right_image = draw_image(screensize, RIGHT, startMatrix, focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes, draw_wield_tool, client, guienv, skycolor); /* create hud overlay */ video::ITexture* hudtexture = draw_hud(driver, screensize, show_hud, hud, client, false, skycolor, guienv, camera ); driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0)); //makeColorKeyTexture mirrors texture so we do it twice to get it right again driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0)); driver->draw2DImage(left_image, irr::core::rect<s32>(0, 0, screensize.X/2, screensize.Y), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false); driver->draw2DImage(hudtexture, irr::core::rect<s32>(0, 0, screensize.X/2, screensize.Y), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true); driver->draw2DImage(right_image, irr::core::rect<s32>(screensize.X/2, 0, screensize.X, screensize.Y), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false); driver->draw2DImage(hudtexture, irr::core::rect<s32>(screensize.X/2, 0, screensize.X, screensize.Y), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true); left_image = NULL; right_image = NULL; /* cleanup */ camera.getCameraNode()->setPosition(oldPosition); camera.getCameraNode()->setTarget(oldTarget); } void draw_top_bottom_3d_mode(Camera& camera, bool show_hud, Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver, scene::ISceneManager* smgr, const v2u32& screensize, bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv, video::SColor skycolor ) { /* save current info */ irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition(); irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget(); irr::core::matrix4 startMatrix = camera.getCameraNode()->getAbsoluteTransformation(); irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget() - camera.getCameraNode()->getAbsolutePosition()).setLength(1) + camera.getCameraNode()->getAbsolutePosition(); /* create left view */ video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix, focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes, draw_wield_tool, client, guienv, skycolor); /* create right view */ video::ITexture* right_image = draw_image(screensize, RIGHT, startMatrix, focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes, draw_wield_tool, client, guienv, skycolor); /* create hud overlay */ video::ITexture* hudtexture = draw_hud(driver, screensize, show_hud, hud, client, false, skycolor, guienv, camera ); driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0)); //makeColorKeyTexture mirrors texture so we do it twice to get it right again driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0)); driver->draw2DImage(left_image, irr::core::rect<s32>(0, 0, screensize.X, screensize.Y/2), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false); driver->draw2DImage(hudtexture, irr::core::rect<s32>(0, 0, screensize.X, screensize.Y/2), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true); driver->draw2DImage(right_image, irr::core::rect<s32>(0, screensize.Y/2, screensize.X, screensize.Y), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false); driver->draw2DImage(hudtexture, irr::core::rect<s32>(0, screensize.Y/2, screensize.X, screensize.Y), irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true); left_image = NULL; right_image = NULL; /* cleanup */ camera.getCameraNode()->setPosition(oldPosition); camera.getCameraNode()->setTarget(oldTarget); } void draw_plain(Camera& camera, bool show_hud, Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver, bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv) { driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); draw_selectionbox(driver, hud, hilightboxes, show_hud); if(draw_wield_tool) camera.drawWieldedTool(); } void draw_scene(video::IVideoDriver* driver, scene::ISceneManager* smgr, Camera& camera, Client& client, LocalPlayer* player, Hud& hud, gui::IGUIEnvironment* guienv, std::vector<aabb3f> hilightboxes, const v2u32& screensize, video::SColor skycolor, bool show_hud) { //TODO check if usefull u32 scenetime = 0; { TimeTaker timer("smgr"); bool draw_wield_tool = (show_hud && (player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE) && camera.getCameraMode() < CAMERA_MODE_THIRD ); bool draw_crosshair = ((player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) && (camera.getCameraMode() != CAMERA_MODE_THIRD_FRONT)); std::string draw_mode = g_settings->get("3d_mode"); smgr->drawAll(); if (draw_mode == "anaglyph") { draw_anaglyph_3d_mode(camera, show_hud, hud, hilightboxes, driver, smgr, draw_wield_tool, client, guienv); draw_crosshair = false; } else if (draw_mode == "interlaced") { draw_interlaced_3d_mode(camera, show_hud, hud, hilightboxes, driver, smgr, screensize, draw_wield_tool, client, guienv, skycolor); draw_crosshair = false; } else if (draw_mode == "sidebyside") { draw_sidebyside_3d_mode(camera, show_hud, hud, hilightboxes, driver, smgr, screensize, draw_wield_tool, client, guienv, skycolor); show_hud = false; } else if (draw_mode == "topbottom") { draw_top_bottom_3d_mode(camera, show_hud, hud, hilightboxes, driver, smgr, screensize, draw_wield_tool, client, guienv, skycolor); show_hud = false; } else { draw_plain(camera, show_hud, hud, hilightboxes, driver,