summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2017-12-06 13:23:55 +0100
committerorwell96 <orwell@bleipb.de>2017-12-06 13:23:55 +0100
commitac3d4dffeb5ca5c78db92e1292e1eade0bb057a5 (patch)
tree8550c9ec93220ff5dee45612bbdf4fed8a61648a
parent34429b8154e45bc6acafd4d3af7a4f9b99f8b5c4 (diff)
downloadbasic_trains-ac3d4dffeb5ca5c78db92e1292e1eade0bb057a5.tar.gz
basic_trains-ac3d4dffeb5ca5c78db92e1292e1eade0bb057a5.tar.bz2
basic_trains-ac3d4dffeb5ca5c78db92e1292e1eade0bb057a5.zip
Implement sound api and some sounds
- Level crossing bell - Horns - Subway train driving and door sounds ...to be continued...
-rw-r--r--advtrains_train_industrial/init.lua1
-rw-r--r--advtrains_train_industrial/sounds/advtrains_industrial_horn.oggbin0 -> 24325 bytes
-rw-r--r--advtrains_train_japan/init.lua1
-rw-r--r--advtrains_train_japan/sounds/advtrains_japan_horn.oggbin0 -> 39307 bytes
-rwxr-xr-xadvtrains_train_steam/init.lua2
-rw-r--r--advtrains_train_steam/sounds/advtrains_steam_whistle.oggbin0 -> 56532 bytes
-rw-r--r--advtrains_train_subway/init.lua30
-rw-r--r--advtrains_train_subway/sounds/advtrains_subway_arrive.oggbin0 -> 22658 bytes
-rw-r--r--advtrains_train_subway/sounds/advtrains_subway_dclose.oggbin0 -> 14298 bytes
-rw-r--r--advtrains_train_subway/sounds/advtrains_subway_depart.oggbin0 -> 39161 bytes
-rw-r--r--advtrains_train_subway/sounds/advtrains_subway_dopen.oggbin0 -> 14307 bytes
-rw-r--r--advtrains_train_subway/sounds/advtrains_subway_horn.oggbin0 -> 14370 bytes
-rw-r--r--advtrains_train_subway/sounds/advtrains_subway_loop.oggbin0 -> 19691 bytes
13 files changed, 28 insertions, 6 deletions
diff --git a/advtrains_train_industrial/init.lua b/advtrains_train_industrial/init.lua
index ebf8d65..42804f3 100644
--- a/advtrains_train_industrial/init.lua
+++ b/advtrains_train_industrial/init.lua
@@ -39,6 +39,7 @@ advtrains.register_wagon("engine_industrial", {
is_locomotive=true,
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
drops={"default:steelblock 4"},
+ horn_sound = "advtrains_industrial_horn",
}, S("Industrial Train Engine"), "advtrains_engine_industrial_inv.png")
advtrains.register_wagon("wagon_tank", {
mesh="advtrains_wagon_tank.b3d",
diff --git a/advtrains_train_industrial/sounds/advtrains_industrial_horn.ogg b/advtrains_train_industrial/sounds/advtrains_industrial_horn.ogg
new file mode 100644
index 0000000..2bc42c2
--- /dev/null
+++ b/advtrains_train_industrial/sounds/advtrains_industrial_horn.ogg
Binary files differ
diff --git a/advtrains_train_japan/init.lua b/advtrains_train_japan/init.lua
index 8816db3..6cf6c6d 100644
--- a/advtrains_train_japan/init.lua
+++ b/advtrains_train_japan/init.lua
@@ -72,6 +72,7 @@ advtrains.register_wagon("engine_japan", {
is_locomotive=true,
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
drops={"default:steelblock 4"},
+ horn_sound = "advtrains_japan_horn",
}, S("Japanese Train Engine"), "advtrains_engine_japan_inv.png")
advtrains.register_wagon("wagon_japan", {
diff --git a/advtrains_train_japan/sounds/advtrains_japan_horn.ogg b/advtrains_train_japan/sounds/advtrains_japan_horn.ogg
new file mode 100644
index 0000000..f7ddb14
--- /dev/null
+++ b/advtrains_train_japan/sounds/advtrains_japan_horn.ogg
Binary files differ
diff --git a/advtrains_train_steam/init.lua b/advtrains_train_steam/init.lua
index 37c63a0..b8d9adb 100755
--- a/advtrains_train_steam/init.lua
+++ b/advtrains_train_steam/init.lua
@@ -71,6 +71,7 @@ advtrains.register_wagon("newlocomotive", {
})
end,
drops={"default:steelblock 4"},
+ horn_sound = "advtrains_steam_whistle",
}, S("Steam Engine"), "advtrains_engine_steam_inv.png")
advtrains.register_wagon("detailed_steam_engine", {
@@ -139,6 +140,7 @@ advtrains.register_wagon("detailed_steam_engine", {
})
end,
drops={"default:steelblock 4"},
+ horn_sound = "advtrains_steam_whistle",
}, S("Detailed Steam Engine"), "advtrains_detailed_engine_steam_inv.png")
advtrains.register_wagon("wagon_default", {
diff --git a/advtrains_train_steam/sounds/advtrains_steam_whistle.ogg b/advtrains_train_steam/sounds/advtrains_steam_whistle.ogg
new file mode 100644
index 0000000..42172a2
--- /dev/null
+++ b/advtrains_train_steam/sounds/advtrains_steam_whistle.ogg
Binary files differ
diff --git a/advtrains_train_subway/init.lua b/advtrains_train_subway/init.lua
index e3c73c9..f8e5e3b 100644
--- a/advtrains_train_subway/init.lua
+++ b/advtrains_train_subway/init.lua
@@ -59,11 +59,13 @@ advtrains.register_wagon("subway_wagon", {
doors={
open={
[-1]={frames={x=0, y=20}, time=1},
- [1]={frames={x=40, y=60}, time=1}
+ [1]={frames={x=40, y=60}, time=1},
+ sound = "advtrains_subway_dopen",
},
close={
[-1]={frames={x=20, y=40}, time=1},
- [1]={frames={x=60, y=80}, time=1}
+ [1]={frames={x=60, y=80}, time=1},
+ sound = "advtrains_subway_dclose",
}
},
door_entry={-1, 1},
@@ -73,10 +75,26 @@ advtrains.register_wagon("subway_wagon", {
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
is_locomotive=true,
drops={"default:steelblock 4"},
- --custom_on_activate = function(self, dtime_s)
- -- atprint("subway custom_on_activate")
- -- self.object:set_animation({x=1,y=80}, 15, 0, true)
- --end,
+ horn_sound = "advtrains_subway_horn",
+ custom_on_velocity_change = function(self, velocity, old_velocity)
+ if old_velocity == 0 and velocity > 0 then
+ minetest.sound_play("advtrains_subway_depart", {object = self.object})
+ end
+ if velocity < 2 and (old_velocity >= 2 or old_velocity == velocity) and not self.sound_arrive_handle then
+ self.sound_arrive_handle = minetest.sound_play("advtrains_subway_arrive", {object = self.object})
+ elseif (velocity > old_velocity) and self.sound_arrive_handle then
+ minetest.sound_stop(self.sound_arrive_handle)
+ self.sound_arrive_handle = nil
+ end
+ if velocity > 0 and not self.sound_loop_handle then
+ self.sound_loop_handle = minetest.sound_play({name="advtrains_subway_loop", gain=0.3}, {object = self.object, loop=true})
+ elseif velocity==0 then
+ if self.sound_loop_handle then
+ minetest.sound_stop(self.sound_loop_handle)
+ self.sound_loop_handle = nil
+ end
+ end
+ end,
}, S("Subway Passenger Wagon"), "advtrains_subway_wagon_inv.png")
--wagons
diff --git a/advtrains_train_subway/sounds/advtrains_subway_arrive.ogg b/advtrains_train_subway/sounds/advtrains_subway_arrive.ogg
new file mode 100644
index 0000000..71bb90e
--- /dev/null
+++ b/advtrains_train_subway/sounds/advtrains_subway_arrive.ogg
Binary files differ
diff --git a/advtrains_train_subway/sounds/advtrains_subway_dclose.ogg b/advtrains_train_subway/sounds/advtrains_subway_dclose.ogg
new file mode 100644
index 0000000..ffbc6ed
--- /dev/null
+++ b/advtrains_train_subway/sounds/advtrains_subway_dclose.ogg
Binary files differ
diff --git a/advtrains_train_subway/sounds/advtrains_subway_depart.ogg b/advtrains_train_subway/sounds/advtrains_subway_depart.ogg
new file mode 100644
index 0000000..aca8cbc
--- /dev/null
+++ b/advtrains_train_subway/sounds/advtrains_subway_depart.ogg
Binary files differ
diff --git a/advtrains_train_subway/sounds/advtrains_subway_dopen.ogg b/advtrains_train_subway/sounds/advtrains_subway_dopen.ogg
new file mode 100644
index 0000000..f1322df
--- /dev/null
+++ b/advtrains_train_subway/sounds/advtrains_subway_dopen.ogg
Binary files differ
diff --git a/advtrains_train_subway/sounds/advtrains_subway_horn.ogg b/advtrains_train_subway/sounds/advtrains_subway_horn.ogg
new file mode 100644
index 0000000..f4519a3
--- /dev/null
+++ b/advtrains_train_subway/sounds/advtrains_subway_horn.ogg
Binary files differ
diff --git a/advtrains_train_subway/sounds/advtrains_subway_loop.ogg b/advtrains_train_subway/sounds/advtrains_subway_loop.ogg
new file mode 100644
index 0000000..1a7021a
--- /dev/null
+++ b/advtrains_train_subway/sounds/advtrains_subway_loop.ogg
Binary files differ
/a> 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 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
/*
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 "irrlicht.h" // createDevice
#include "irrlichttypes_extrabloated.h"
#include "chat_interface.h"
#include "debug.h"
#include "unittest/test.h"
#include "server.h"
#include "filesys.h"
#include "version.h"
#include "game.h"
#include "defaultsettings.h"
#include "gettext.h"
#include "log.h"
#include "quicktune.h"
#include "httpfetch.h"
#include "gameparams.h"
#include "database.h"
#include "config.h"
#include "player.h"
#include "porting.h"
#include "network/socket.h"
#if USE_CURSES
	#include "terminal_chat_console.h"
#endif
#ifndef SERVER
#include "guiMainMenu.h"
#include "client/clientlauncher.h"
#include "guiEngine.h"
#include "mainmenumanager.h"
#endif

#ifdef HAVE_TOUCHSCREENGUI
	#include "touchscreengui.h"
#endif

#if !defined(SERVER) && \
	(IRRLICHT_VERSION_MAJOR == 1) && \
	(IRRLICHT_VERSION_MINOR == 8) && \
	(IRRLICHT_VERSION_REVISION == 2)
	#error "Irrlicht 1.8.2 is known to be broken - please update Irrlicht to version >= 1.8.3"
#endif

#define DEBUGFILE "debug.txt"
#define DEFAULT_SERVER_PORT 30000

typedef std::map<std::string, ValueSpec> OptionList;

/**********************************************************************
 * Private functions
 **********************************************************************/

static bool get_cmdline_opts(int argc, char *argv[], Settings *cmd_args);
static void set_allowed_options(OptionList *allowed_options);

static void print_help(const OptionList &allowed_options);
static void print_allowed_options(const OptionList &allowed_options);
static void print_version();
static void print_worldspecs(const std::vector<WorldSpec> &worldspecs,
							 std::ostream &os);
static void print_modified_quicktune_values();

static void list_game_ids();
static void list_worlds();
static void setup_log_params(const Settings &cmd_args);
static bool create_userdata_path();
static bool init_common(const Settings &cmd_args, int argc, char *argv[]);
static void startup_message();
static bool read_config_file(const Settings &cmd_args);
static void init_log_streams(const Settings &cmd_args);

static bool game_configure(GameParams *game_params, const Settings &cmd_args);
static void game_configure_port(GameParams *game_params, const Settings &cmd_args);

static bool game_configure_world(GameParams *game_params, const Settings &cmd_args);
static bool get_world_from_cmdline(GameParams *game_params, const Settings &cmd_args);
static bool get_world_from_config(GameParams *game_params, const Settings &cmd_args);
static bool auto_select_world(GameParams *game_params);
static std::string get_clean_world_path(const std::string &path);

static bool game_configure_subgame(GameParams *game_params, const Settings &cmd_args);
static bool get_game_from_cmdline(GameParams *game_params, const Settings &cmd_args);
static bool determine_subgame(GameParams *game_params);

static bool run_dedicated_server(const GameParams &game_params, const Settings &cmd_args);
static bool migrate_map_database(const GameParams &game_params, const Settings &cmd_args);

/**********************************************************************/


FileLogOutput file_log_output;

static OptionList allowed_options;

int main(int argc, char *argv[])
{
	int retval;
	debug_set_exception_handler();

	g_logger.registerThread("Main");
	g_logger.addOutputMaxLevel(&stderr_output, LL_ACTION);

	Settings cmd_args;
	bool cmd_args_ok = get_cmdline_opts(argc, argv, &cmd_args);
	if (!cmd_args_ok
			|| cmd_args.getFlag("help")
			|| cmd_args.exists("nonopt1")) {
		porting::attachOrCreateConsole();
		print_help(allowed_options);
		return cmd_args_ok ? 0 : 1;
	}
	if (cmd_args.getFlag("console"))
		porting::attachOrCreateConsole();

	if (cmd_args.getFlag("version")) {
		porting::attachOrCreateConsole();
		print_version();
		return 0;
	}

	setup_log_params(cmd_args);

	porting::signal_handler_init();

#ifdef __ANDROID__
	porting::initAndroid();
	porting::initializePathsAndroid();
#else
	porting::initializePaths();
#endif