aboutsummaryrefslogtreecommitdiff
Commit message (Expand)AuthorAge
* Add missing recipe: 45_low platformsrelease-2.1.4Blockhead2020-10-19
* Remove couple entities when out of range from playersGabriel Pérez-Cerezo2020-10-12
* Remove last files with CR-LF line endings.Gabriel Pérez-Cerezo2020-10-11
* Fix 3-way conns table so traverser doesn't complainBlockhead2020-10-11
* Forbid track modification when train, IP or TCB is on it, better handle remov...orwell962020-10-07
* Don't allow wagons with non-empty inventories to be destroyed (H#164)orwell962020-10-07
* Fix schedule_in() crash when RWT is not in number format (H#159)orwell962020-10-07
* Add windows compatibility in nodedb saving (H#153)orwell962020-10-07
* Fix manual switching on regular track switches.Gabriel Pérez-Cerezo2020-09-14
* Fix issues introduced by changes to switchingBlockhead2020-09-14
* Enable three-way turnouts with proper conns support on all sidesBlockhead2020-09-11
* Add 3-way turnouts and y-turnouts (both diverging)Blockhead2020-09-11
* Make the models for Y and three-way turnoutsBlockhead2020-09-11
* localize split function to prevent conflicts with the builtin oneGabriel Pérez-Cerezo2020-09-04
* Escape fields in wagon properties (H#158)orwell962020-09-04
* tcb: Fix crash when player is nilLinus Jahn2020-09-01
* Fix seating_from_key_helper: use pname instead of player:get_player_name()Relatio2020-08-27
* Deprecate old 4590 crossingsBlockhead2020-08-21
* Add two new sets of diamond crossing typesBlockhead2020-08-21
* Add models for all diamond crossing varieties to .blendBlockhead2020-08-21
* add maximum length parameter to split_at_fc and split_off_locomotiveGabriel Pérez-Cerezo2020-08-21
* Add command to split off locomotiveGabriel Pérez-Cerezo2020-07-28
* Complete Documentation on return value of split_at_fc()Gabriel Pérez-Cerezo2020-07-28
* Document new luaatc commandsGabriel Pérez-Cerezo2020-07-28
* add train_length command to luaatcGabriel Pérez-Cerezo2020-07-27
* Add function to step through freight codesGabriel Pérez-Cerezo2020-07-26
* add split_train_at_fc luaatc commandGabriel Pérez-Cerezo2020-07-26
* add Freightcodes to wagon properties formspecGabriel Pérez-Cerezo2020-07-26
* Do not unload wagons when a player that is logged in sits in itrelease-2.1.3orwell962020-07-26
* Add low 45 degree platformsBlockhead2020-07-25
* subway trains: display up to two digitsHume22020-07-25
* Merge branch 'master' of bananach.space:advtrainsGabriel Pérez-Cerezo2020-07-24
|\
| * DISCARD ON MERGE!: Temporary compatibility fix: translate signal aspects back...orwell962020-07-23
* | Add client side translations by ywangGabriel Pérez-Cerezo2020-07-19
|\ \ | |/ |/|
| * [BREAKING] Use client-side translations instead of intllib; add zh_CN transla...ywang2020-07-19
* | Fix error in workaround causing train entities to despawn.Gabriel Pérez-Cerezo2020-07-19
* | Merge branch 'master' of bananach.space:advtrainsGabriel Pérez-Cerezo2020-07-19
|\|
| * Add workaround to unload wagons that are too far away from playersorwell962020-07-12
* | Move recipes to train_track and add crossing recipesBlockhead2020-07-10
* | Make using the default tracks optional, even in submodsBlockhead2020-07-10
|/
* optimize path_get_index_by_offsettechniX2020-07-10
* Add "Fallback state" for freed routes, move p_mesecon_iface.lua to coreorwell962020-07-07
* Add perpendicular and 45/90 degree crossing railsBlockhead2020-07-06
* fix typo in luaautomationGabriel Pérez-Cerezo2020-07-02
* Fix access control to wagon propertiesBlockhead2020-06-29
* Add autocouple modeGabriel Pérez-Cerezo2020-06-29
* comment out annoying debug infoGabriel Pérez-Cerezo2020-06-14
* Merge branch 'master' of bananach.space:advtrainsGabriel Pérez-Cerezo2020-06-14
|\
| * Workaround to handle split points (dt. aufgefahrene Weichen), fixing H#77orwell962020-06-10
* | display oncoming lzb speed restrictions in HUDGabriel Pérez-Cerezo2020-06-14
|/
5'>495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>

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 "localplayer.h"

#include "event.h"
#include "collision.h"
#include "gamedef.h"
#include "nodedef.h"
#include "settings.h"
#include "environment.h"
#include "map.h"
#include "util/numeric.h"

/*
	LocalPlayer
*/

LocalPlayer::LocalPlayer(IGameDef *gamedef, const char *name):
	Player(gamedef, name),
	parent(0),
	isAttached(false),
	overridePosition(v3f(0,0,0)),
	last_position(v3f(0,0,0)),
	last_speed(v3f(0,0,0)),
	last_pitch(0),
	last_yaw(0),
	last_keyPressed(0),
	last_animation(NO_ANIM),
	hotbar_image(""),
	hotbar_selected_image(""),
	light_color(255,255,255,255),
	m_sneak_node(32767,32767,32767),
	m_sneak_node_exists(false),
	m_need_to_get_new_sneak_node(true),
	m_sneak_node_bb_ymax(0),
	m_old_node_below(32767,32767,32767),
	m_old_node_below_type("air"),
	m_can_jump(false),
	m_cao(NULL)
{
	// Initialize hp to 0, so that no hearts will be shown if server
	// doesn't support health points
	hp = 0;
	eye_offset_first = v3f(0,0,0);
	eye_offset_third = v3f(0,0,0);
}

LocalPlayer::~LocalPlayer()
{
}

void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
		std::vector<CollisionInfo> *collision_info)
{
	Map *map = &env->getMap();
	INodeDefManager *nodemgr = m_gamedef->ndef();

	v3f position = getPosition();

	// Copy parent position if local player is attached
	if(isAttached)
	{
		setPosition(overridePosition);
		m_sneak_node_exists = false;
		return;
	}

	// Skip collision detection if noclip mode is used
	bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
	bool noclip = m_gamedef->checkLocalPrivilege("noclip") &&
		g_settings->getBool("noclip");
	bool free_move = noclip && fly_allowed && g_settings->getBool("free_move");
	if (free_move) {
		position += m_speed * dtime;
		setPosition(position);
		m_sneak_node_exists = false;
		return;
	}

	/*
		Collision detection
	*/

	bool is_valid_position;
	MapNode node;
	v3s16 pp;

	/*
		Check if player is in liquid (the oscillating value)
	*/

	// If in liquid, the threshold of coming out is at higher y
	if (in_liquid)
	{