mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 21:29:18 +02:00
Merge Milek7 sound and lua
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -70,4 +70,8 @@ ipch/
|
||||
#ref/
|
||||
*.aps
|
||||
|
||||
builds/
|
||||
builds/build_*
|
||||
builds/*.zip
|
||||
builds/deps_*
|
||||
|
||||
CMakeLists.txt.user
|
||||
|
||||
181
AdvSound.cpp
181
AdvSound.cpp
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "AdvSound.h"
|
||||
#include "Timer.h"
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
TAdvancedSound::~TAdvancedSound()
|
||||
{ // Ra: stopowanie się sypie
|
||||
// SoundStart.Stop();
|
||||
// SoundCommencing.Stop();
|
||||
// SoundShut.Stop();
|
||||
}
|
||||
|
||||
void TAdvancedSound::Free()
|
||||
{
|
||||
}
|
||||
|
||||
void TAdvancedSound::Init( std::string const &NameOn, std::string const &Name, std::string const &NameOff, double DistanceAttenuation,
|
||||
vector3 const &pPosition)
|
||||
{
|
||||
SoundStart.Init(NameOn, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true);
|
||||
SoundCommencing.Init(Name, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true);
|
||||
SoundShut.Init(NameOff, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true);
|
||||
fStartLength = SoundStart.GetWaveTime();
|
||||
fShutLength = SoundShut.GetWaveTime();
|
||||
SoundStart.AM = 1.0;
|
||||
SoundStart.AA = 0.0;
|
||||
SoundStart.FM = 1.0;
|
||||
SoundStart.FA = 0.0;
|
||||
SoundCommencing.AM = 1.0;
|
||||
SoundCommencing.AA = 0.0;
|
||||
SoundCommencing.FM = 1.0;
|
||||
SoundCommencing.FA = 0.0;
|
||||
defAM = 1.0;
|
||||
defFM = 1.0;
|
||||
SoundShut.AM = 1.0;
|
||||
SoundShut.AA = 0.0;
|
||||
SoundShut.FM = 1.0;
|
||||
SoundShut.FA = 0.0;
|
||||
}
|
||||
|
||||
void TAdvancedSound::Load(cParser &Parser, vector3 const &pPosition)
|
||||
{
|
||||
std::string nameon, name, nameoff;
|
||||
double attenuation;
|
||||
Parser.getTokens( 3, true, "\n\t ;," ); // samples separated with commas
|
||||
Parser
|
||||
>> nameon
|
||||
>> name
|
||||
>> nameoff;
|
||||
Parser.getTokens( 1, false );
|
||||
Parser
|
||||
>> attenuation;
|
||||
Init( nameon, name, nameoff, attenuation, pPosition );
|
||||
}
|
||||
|
||||
void TAdvancedSound::TurnOn(bool ListenerInside, vector3 NewPosition)
|
||||
{
|
||||
// hunter-311211: nie trzeba czekac na ponowne odtworzenie dzwieku, az sie wylaczy
|
||||
if ((State == ss_Off || State == ss_ShuttingDown) && (SoundStart.AM > 0))
|
||||
{
|
||||
SoundStart.ResetPosition();
|
||||
SoundCommencing.ResetPosition();
|
||||
SoundStart.Play(1, 0, ListenerInside, NewPosition);
|
||||
// SoundStart->SetVolume(-10000);
|
||||
State = ss_Starting;
|
||||
fTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void TAdvancedSound::TurnOff(bool ListenerInside, vector3 NewPosition)
|
||||
{
|
||||
if ((State == ss_Commencing || State == ss_Starting) && (SoundShut.AM > 0))
|
||||
{
|
||||
SoundStart.Stop();
|
||||
SoundCommencing.Stop();
|
||||
SoundShut.ResetPosition();
|
||||
SoundShut.Play(1, 0, ListenerInside, NewPosition);
|
||||
State = ss_ShuttingDown;
|
||||
fTime = fShutLength;
|
||||
// SoundShut->SetVolume(0);
|
||||
}
|
||||
}
|
||||
|
||||
void TAdvancedSound::Update(bool ListenerInside, vector3 NewPosition)
|
||||
{
|
||||
if ((State == ss_Commencing) && (SoundCommencing.AM > 0))
|
||||
{
|
||||
// SoundCommencing->SetFrequency();
|
||||
SoundShut.Stop(); // hunter-311211
|
||||
SoundCommencing.Play(1, DSBPLAY_LOOPING, ListenerInside, NewPosition);
|
||||
}
|
||||
else if (State == ss_Starting)
|
||||
{
|
||||
fTime += Timer::GetDeltaTime();
|
||||
// SoundStart->SetVolume(-1000*(4-fTime)/4);
|
||||
if (fTime >= fStartLength)
|
||||
{
|
||||
State = ss_Commencing;
|
||||
SoundCommencing.ResetPosition();
|
||||
SoundCommencing.Play(1, DSBPLAY_LOOPING, ListenerInside, NewPosition);
|
||||
SoundStart.Stop();
|
||||
}
|
||||
else
|
||||
SoundStart.Play(1, 0, ListenerInside, NewPosition);
|
||||
}
|
||||
else if (State == ss_ShuttingDown)
|
||||
{
|
||||
fTime -= Timer::GetDeltaTime();
|
||||
// SoundShut->SetVolume(-1000*(4-fTime)/4);
|
||||
if (fTime <= 0)
|
||||
{
|
||||
State = ss_Off;
|
||||
SoundShut.Stop();
|
||||
}
|
||||
else
|
||||
SoundShut.Play(1, 0, ListenerInside, NewPosition);
|
||||
}
|
||||
}
|
||||
|
||||
void TAdvancedSound::UpdateAF(double A, double F, bool ListenerInside, vector3 NewPosition)
|
||||
{ // update, ale z amplituda i czestotliwoscia
|
||||
if( State == ss_Off ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((State == ss_Commencing) && (SoundCommencing.AM > 0))
|
||||
{
|
||||
SoundShut.Stop(); // hunter-311211
|
||||
SoundCommencing.Play(A, DSBPLAY_LOOPING, ListenerInside, NewPosition);
|
||||
}
|
||||
else if (State == ss_Starting)
|
||||
{
|
||||
fTime += Timer::GetDeltaTime();
|
||||
// SoundStart->SetVolume(-1000*(4-fTime)/4);
|
||||
if (fTime >= fStartLength)
|
||||
{
|
||||
State = ss_Commencing;
|
||||
SoundCommencing.ResetPosition();
|
||||
SoundCommencing.Play(A, DSBPLAY_LOOPING, ListenerInside, NewPosition);
|
||||
SoundStart.Stop();
|
||||
}
|
||||
else
|
||||
SoundStart.Play(A, 0, ListenerInside, NewPosition);
|
||||
}
|
||||
else if (State == ss_ShuttingDown)
|
||||
{
|
||||
fTime -= Timer::GetDeltaTime();
|
||||
// SoundShut->SetVolume(-1000*(4-fTime)/4);
|
||||
if (fTime <= 0)
|
||||
{
|
||||
State = ss_Off;
|
||||
SoundShut.Stop();
|
||||
}
|
||||
else
|
||||
SoundShut.Play(A, 0, ListenerInside, NewPosition);
|
||||
}
|
||||
SoundCommencing.AdjFreq(F, Timer::GetDeltaTime());
|
||||
}
|
||||
|
||||
void TAdvancedSound::CopyIfEmpty(TAdvancedSound &s)
|
||||
{ // skopiowanie, gdyby był potrzebny, a nie został wczytany
|
||||
if ((fStartLength > 0.0) || (fShutLength > 0.0))
|
||||
return; // coś jest
|
||||
SoundStart = s.SoundStart;
|
||||
SoundCommencing = s.SoundCommencing;
|
||||
SoundShut = s.SoundShut;
|
||||
State = s.State;
|
||||
fStartLength = s.fStartLength;
|
||||
fShutLength = s.fShutLength;
|
||||
defAM = s.defAM;
|
||||
defFM = s.defFM;
|
||||
};
|
||||
50
AdvSound.h
50
AdvSound.h
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef AdvSoundH
|
||||
#define AdvSoundH
|
||||
|
||||
#include "RealSound.h"
|
||||
#include "parser.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ss_Off,
|
||||
ss_Starting,
|
||||
ss_Commencing,
|
||||
ss_ShuttingDown
|
||||
} TSoundState;
|
||||
|
||||
class TAdvancedSound
|
||||
{ // klasa dźwięków mających początek, dowolnie długi środek oraz zakończenie (np. Rp1)
|
||||
TRealSound SoundStart;
|
||||
TRealSound SoundCommencing;
|
||||
TRealSound SoundShut;
|
||||
TSoundState State = ss_Off;
|
||||
double fTime = 0.0;
|
||||
double fStartLength = 0.0;
|
||||
double fShutLength = 0.0;
|
||||
double defAM = 0.0;
|
||||
double defFM = 0.0;
|
||||
|
||||
public:
|
||||
TAdvancedSound() = default;
|
||||
~TAdvancedSound();
|
||||
void Init( std::string const &NameOn, std::string const &Name, std::string const &NameOff, double DistanceAttenuation, vector3 const &pPosition);
|
||||
void Load(cParser &Parser, vector3 const &pPosition);
|
||||
void TurnOn(bool ListenerInside, vector3 NewPosition);
|
||||
void TurnOff(bool ListenerInside, vector3 NewPosition);
|
||||
void Free();
|
||||
void Update(bool ListenerInside, vector3 NewPosition);
|
||||
void UpdateAF(double A, double F, bool ListenerInside, vector3 NewPosition);
|
||||
void CopyIfEmpty(TAdvancedSound &s);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -94,11 +94,11 @@ class TAnimContainer
|
||||
void UpdateModel();
|
||||
void UpdateModelIK();
|
||||
bool InMovement(); // czy w trakcie animacji?
|
||||
double _fastcall AngleGet()
|
||||
double AngleGet()
|
||||
{
|
||||
return vRotateAngles.z;
|
||||
}; // jednak ostatnia, T3D ma inny układ
|
||||
vector3 _fastcall TransGet()
|
||||
vector3 TransGet()
|
||||
{
|
||||
return vector3(-vTranslation.x, vTranslation.z, vTranslation.y);
|
||||
}; // zmiana, bo T3D ma inny układ
|
||||
|
||||
15
Button.cpp
15
Button.cpp
@@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "parser.h"
|
||||
#include "Model3d.h"
|
||||
#include "Console.h"
|
||||
#include "logs.h"
|
||||
#include "Logs.h"
|
||||
|
||||
void TButton::Clear(int i)
|
||||
{
|
||||
@@ -89,13 +89,13 @@ TButton::Load_mapping( cParser &Input ) {
|
||||
if( key == "soundinc:" ) {
|
||||
m_soundfxincrease = (
|
||||
value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
sound_man->create_sound(value) :
|
||||
nullptr );
|
||||
}
|
||||
else if( key == "sounddec:" ) {
|
||||
m_soundfxdecrease = (
|
||||
value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
sound_man->create_sound(value) :
|
||||
nullptr );
|
||||
}
|
||||
return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized
|
||||
@@ -124,6 +124,7 @@ void TButton::Update() {
|
||||
if( pModelOn != nullptr ) { pModelOn->iVisible = m_state; }
|
||||
if( pModelOff != nullptr ) { pModelOff->iVisible = (!m_state); }
|
||||
|
||||
#ifdef _WIN32
|
||||
if (iFeedbackBit) {
|
||||
// jeżeli generuje informację zwrotną
|
||||
if (m_state) // zapalenie
|
||||
@@ -131,6 +132,7 @@ void TButton::Update() {
|
||||
else
|
||||
Console::BitsClear(iFeedbackBit);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
void TButton::AssignBool(bool const *bValue) {
|
||||
@@ -148,12 +150,11 @@ TButton::play() {
|
||||
}
|
||||
|
||||
void
|
||||
TButton::play( PSound Sound ) {
|
||||
TButton::play( sound* Sound ) {
|
||||
|
||||
if( Sound == nullptr ) { return; }
|
||||
|
||||
Sound->SetCurrentPosition( 0 );
|
||||
Sound->SetVolume( DSBVOLUME_MAX );
|
||||
Sound->Play( 0, 0, 0 );
|
||||
Sound->stop();
|
||||
Sound->play();
|
||||
return;
|
||||
}
|
||||
|
||||
6
Button.h
6
Button.h
@@ -22,8 +22,8 @@ class TButton
|
||||
bool m_state { false };
|
||||
bool const *bData { nullptr };
|
||||
int iFeedbackBit { 0 }; // Ra: bit informacji zwrotnej, do wyprowadzenia na pulpit
|
||||
PSound m_soundfxincrease { nullptr }; // sound associated with increasing control's value
|
||||
PSound m_soundfxdecrease { nullptr }; // sound associated with decreasing control's value
|
||||
sound* m_soundfxincrease { nullptr }; // sound associated with increasing control's value
|
||||
sound* m_soundfxdecrease { nullptr }; // sound associated with decreasing control's value
|
||||
// methods
|
||||
// imports member data pair from the config file
|
||||
bool
|
||||
@@ -33,7 +33,7 @@ class TButton
|
||||
play();
|
||||
// plays specified sound
|
||||
void
|
||||
play( PSound Sound );
|
||||
play( sound *Sound );
|
||||
|
||||
public:
|
||||
TButton() = default;
|
||||
|
||||
@@ -15,34 +15,27 @@ set(SOURCES
|
||||
"Train.cpp"
|
||||
"TrkFoll.cpp"
|
||||
"VBO.cpp"
|
||||
"wavread.cpp"
|
||||
"World.cpp"
|
||||
"AdvSound.cpp"
|
||||
"AirCoupler.cpp"
|
||||
"AnimModel.cpp"
|
||||
"Button.cpp"
|
||||
"Camera.cpp"
|
||||
"Console.cpp"
|
||||
"console/LPT.cpp"
|
||||
"Console/MWD.cpp"
|
||||
"console/PoKeys55.cpp"
|
||||
"Driver.cpp"
|
||||
"dumb3d.cpp"
|
||||
"DynObj.cpp"
|
||||
"EU07.cpp"
|
||||
"Event.cpp"
|
||||
"EvLaunch.cpp"
|
||||
"FadeSound.cpp"
|
||||
"Float3d.cpp"
|
||||
"Gauge.cpp"
|
||||
"Globals.cpp"
|
||||
"Ground.cpp"
|
||||
"Logs.cpp"
|
||||
"mczapkie/friction.cpp"
|
||||
"mczapkie/hamulce.cpp"
|
||||
"mczapkie/mctools.cpp"
|
||||
"mczapkie/Mover.cpp"
|
||||
"mczapkie/Oerlikon_ESt.cpp"
|
||||
"McZapkie/friction.cpp"
|
||||
"McZapkie/hamulce.cpp"
|
||||
"McZapkie/mctools.cpp"
|
||||
"McZapkie/Mover.cpp"
|
||||
"McZapkie/Oerlikon_ESt.cpp"
|
||||
"MdlMngr.cpp"
|
||||
"MemCell.cpp"
|
||||
"Model3d.cpp"
|
||||
@@ -50,7 +43,6 @@ set(SOURCES
|
||||
"parser.cpp"
|
||||
"renderer.cpp"
|
||||
"PyInt.cpp"
|
||||
"RealSound.cpp"
|
||||
"ResourceManager.cpp"
|
||||
"sn_utils.cpp"
|
||||
"Segment.cpp"
|
||||
@@ -59,14 +51,26 @@ set(SOURCES
|
||||
"stars.cpp"
|
||||
"lightarray.cpp"
|
||||
"skydome.cpp"
|
||||
"Sound.cpp"
|
||||
"sound.cpp"
|
||||
"Spring.cpp"
|
||||
"shader.cpp"
|
||||
"frustum.cpp"
|
||||
"uilayer.cpp"
|
||||
"openglmatrixstack.cpp"
|
||||
"moon.cpp"
|
||||
"command.cpp"
|
||||
"keyboardinput.cpp"
|
||||
"gamepadinput.cpp"
|
||||
"openglgeometrybank.cpp"
|
||||
"mouseinput.cpp"
|
||||
"translation.cpp"
|
||||
"material.cpp"
|
||||
"lua.cpp"
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
add_definitions(-DHAVE_ROUND) # to make pymath to not redefine round
|
||||
set(SOURCES ${SOURCES} "windows.cpp")
|
||||
set(SOURCES ${SOURCES} "windows.cpp" "Console.cpp" "Console/LPT.cpp" "Console/MWD.cpp" "Console/PoKeys55.cpp" "wavread.cpp")
|
||||
endif()
|
||||
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
||||
@@ -80,6 +84,7 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
||||
# /wd4996: disable "deprecation" warnings
|
||||
# /wd4244: disable warnings for conversion with possible loss of data
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4996 /wd4244")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
|
||||
endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
@@ -103,5 +108,28 @@ include_directories(${PYTHON_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES})
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
include_directories(${PNG_INCLUDE_DIRS})
|
||||
include_directories(${PNG_INCLUDE_DIRS} ${PNG_PNG_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${PNG_LIBRARIES})
|
||||
target_link_libraries(${PROJECT_NAME} ${PNG_LIBRARY})
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} Threads::Threads)
|
||||
|
||||
find_package(GLM REQUIRED)
|
||||
include_directories(${GLM_INCLUDE_DIRS})
|
||||
|
||||
find_package(OpenAL REQUIRED)
|
||||
include_directories(${OPENAL_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${OPENAL_LIBRARY})
|
||||
|
||||
find_package(libsndfile REQUIRED)
|
||||
include_directories(${LIBSNDFILE_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBSNDFILE_LIBRARY})
|
||||
|
||||
find_package(LuaJIT REQUIRED)
|
||||
include_directories(${LUAJIT_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${LUAJIT_LIBRARIES})
|
||||
|
||||
if (UNIX)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
||||
endif()
|
||||
|
||||
52
CMake_modules/FindGLM.cmake
Normal file
52
CMake_modules/FindGLM.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Find GLM
|
||||
#
|
||||
# Try to find GLM : OpenGL Mathematics.
|
||||
# This module defines
|
||||
# - GLM_INCLUDE_DIRS
|
||||
# - GLM_FOUND
|
||||
#
|
||||
# The following variables can be set as arguments for the module.
|
||||
# - GLM_ROOT_DIR : Root library directory of GLM
|
||||
#
|
||||
# References:
|
||||
# - https://github.com/Groovounet/glm/blob/master/util/FindGLM.cmake
|
||||
# - https://bitbucket.org/alfonse/gltut/src/28636298c1c0/glm-0.9.0.7/FindGLM.cmake
|
||||
#
|
||||
|
||||
# Additional modules
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if (WIN32)
|
||||
# Find include files
|
||||
find_path(
|
||||
GLM_INCLUDE_DIR
|
||||
NAMES glm/glm.hpp
|
||||
PATHS
|
||||
$ENV{PROGRAMFILES}/include
|
||||
${GLM_ROOT_DIR}/include
|
||||
DOC "The directory where glm/glm.hpp resides")
|
||||
else()
|
||||
# Find include files
|
||||
find_path(
|
||||
GLM_INCLUDE_DIR
|
||||
NAMES glm/glm.hpp
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
${GLM_ROOT_DIR}/include
|
||||
DOC "The directory where glm/glm.hpp resides")
|
||||
endif()
|
||||
|
||||
# Handle REQUIRD argument, define *_FOUND variable
|
||||
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIR)
|
||||
|
||||
# Define GLM_INCLUDE_DIRS
|
||||
if (GLM_FOUND)
|
||||
set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# Hide some variables
|
||||
mark_as_advanced(GLM_INCLUDE_DIR)
|
||||
81
CMake_modules/FindLuaJIT.cmake
Normal file
81
CMake_modules/FindLuaJIT.cmake
Normal file
@@ -0,0 +1,81 @@
|
||||
# Locate Lua library
|
||||
# This module defines
|
||||
# LUAJIT_FOUND, if false, do not try to link to Lua
|
||||
# LUAJIT_LIBRARIES
|
||||
# LUAJIT_INCLUDE_DIR, where to find lua.h
|
||||
# LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
#
|
||||
# Note that the expected include convention is
|
||||
# #include "lua.h"
|
||||
# and not
|
||||
# #include <lua/lua.h>
|
||||
# This is because, the lua location is not standardized and may exist
|
||||
# in locations other than lua/
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_path(LUAJIT_INCLUDE_DIR luajit.h
|
||||
HINTS
|
||||
$ENV{LUA_DIR}
|
||||
PATH_SUFFIXES include/luajit-2.0 include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
find_library(LUAJIT_LIBRARY
|
||||
NAMES luajit luajit-5.1
|
||||
HINTS
|
||||
$ENV{LUA_DIR}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
if (LUAJIT_LIBRARY)
|
||||
# include the math library for Unix
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_library(LUAJIT_MATH_LIBRARY m)
|
||||
set(LUAJIT_LIBRARIES "${LUAJIT_LIBRARY};${LUAJIT_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
else ()
|
||||
set(LUAJIT_LIBRARIES "${LUAJIT_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if(LUAJIT_INCLUDE_DIR AND EXISTS "${LUAJIT_INCLUDE_DIR}/lua.h")
|
||||
file(STRINGS "${LUAJIT_INCLUDE_DIR}/lua.h" luajit_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
||||
|
||||
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${luajit_version_str}")
|
||||
unset(luajit_version_str)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
find_package_handle_standard_args(LuaJIT
|
||||
REQUIRED_VARS LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR
|
||||
VERSION_VAR LUAJIT_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY LUAJIT_MATH_LIBRARY)
|
||||
|
||||
34
CMake_modules/Findlibsndfile.cmake
Normal file
34
CMake_modules/Findlibsndfile.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
# - Try to find libsndfile
|
||||
# Once done, this will define
|
||||
#
|
||||
# LIBSNDFILE_FOUND - system has libsndfile
|
||||
# LIBSNDFILE_INCLUDE_DIRS - the libsndfile include directories
|
||||
# LIBSNDFILE_LIBRARIES - link these to use libsndfile
|
||||
|
||||
# Use pkg-config to get hints about paths
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(LIBSNDFILE_PKGCONF sndfile)
|
||||
endif(PKG_CONFIG_FOUND)
|
||||
|
||||
# Include dir
|
||||
find_path(LIBSNDFILE_INCLUDE_DIR
|
||||
NAMES sndfile.h
|
||||
PATHS ${LIBSNDFILE_PKGCONF_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Library
|
||||
find_library(LIBSNDFILE_LIBRARY
|
||||
NAMES sndfile libsndfile-1
|
||||
PATHS ${LIBSNDFILE_PKGCONF_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
find_package(PackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibSndFile DEFAULT_MSG LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
|
||||
|
||||
if(LIBSNDFILE_FOUND)
|
||||
set(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY})
|
||||
set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR})
|
||||
endif(LIBSNDFILE_FOUND)
|
||||
|
||||
mark_as_advanced(LIBSNDFILE_LIBRARY LIBSNDFILE_LIBRARIES LIBSNDFILE_INCLUDE_DIR LIBSNDFILE_INCLUDE_DIRS)
|
||||
@@ -11,10 +11,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Camera.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
#include "Console.h"
|
||||
#include "Timer.h"
|
||||
#include "mover.h"
|
||||
#include "MOVER.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -379,7 +379,8 @@ void TCamera::Update()
|
||||
|
||||
vector3 TCamera::GetDirection() {
|
||||
|
||||
return glm::normalize( glm::rotateY<float>( glm::vec3{ 0.f, 0.f, 1.f }, Yaw ) );
|
||||
glm::vec3 v = glm::normalize( glm::rotateY<float>( glm::vec3{ 0.f, 0.f, 1.f }, Yaw ) );
|
||||
return vector3(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
||||
|
||||
2
Camera.h
2
Camera.h
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include "dumb3d.h"
|
||||
#include "dynobj.h"
|
||||
#include "DynObj.h"
|
||||
#include "command.h"
|
||||
|
||||
using namespace Math3D;
|
||||
|
||||
@@ -23,8 +23,8 @@ class TModel3d; //siatka modelu wspólna dla egzemplarzy
|
||||
class TSubModel; // fragment modelu (tu do wyświetlania terenu)
|
||||
class TMemCell; // komórka pamięci
|
||||
class cParser;
|
||||
class TRealSound; // dźwięk ze współrzędnymi XYZ
|
||||
class TTextSound; // dźwięk ze stenogramem
|
||||
class sound;
|
||||
class text_sound;
|
||||
class TEventLauncher;
|
||||
class TTraction; // drut
|
||||
class TTractionPowerSource; // zasilanie drutów
|
||||
|
||||
10
Console.cpp
10
Console.cpp
@@ -10,11 +10,11 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "Console.h"
|
||||
#include "Globals.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
#include "LPT.h"
|
||||
#include "Logs.h"
|
||||
#include "MWD.h" // maciek001: obsluga portu COM
|
||||
#include "PoKeys55.h"
|
||||
#include "mczapkie/mctools.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Ra: klasa statyczna gromadząca sygnały sterujące oraz informacje zwrotne
|
||||
@@ -341,14 +341,6 @@ void Console::BitsUpdate(int mask)
|
||||
}
|
||||
};
|
||||
|
||||
bool Console::Pressed(int x)
|
||||
{ // na razie tak - czyta się tylko klawiatura
|
||||
if (glfwGetKey(Global::window, x) == GLFW_TRUE)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
|
||||
void Console::ValueSet(int x, double y)
|
||||
{ // ustawienie wartości (y) na kanale analogowym (x)
|
||||
if (iMode == 4)
|
||||
|
||||
11
Console.h
11
Console.h
@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef ConsoleH
|
||||
#define ConsoleH
|
||||
#include "Globals.h"
|
||||
//---------------------------------------------------------------------------
|
||||
class TConsoleDevice; // urządzenie podłączalne za pomocą DLL
|
||||
class TPoKeys55;
|
||||
@@ -49,7 +50,15 @@ class Console
|
||||
static void BitsClear(int mask, int entry = 0);
|
||||
static int On();
|
||||
static void Off();
|
||||
static bool Pressed(int x);
|
||||
|
||||
inline static bool Pressed(int x)
|
||||
{ // na razie tak - czyta się tylko klawiatura
|
||||
if (glfwGetKey(Global::window, x) == GLFW_TRUE)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
|
||||
static void ValueSet(int x, double y);
|
||||
static void Update();
|
||||
static float AnalogGet(int x);
|
||||
|
||||
2
Curve.h
2
Curve.h
@@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#define CurveH
|
||||
|
||||
#include "QueryParserComp.hpp"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
|
||||
class TCurve
|
||||
{
|
||||
|
||||
122
Driver.cpp
122
Driver.cpp
@@ -15,7 +15,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "Driver.h"
|
||||
|
||||
#include <direct.h>
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "mtable.h"
|
||||
@@ -26,6 +25,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "World.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
#include "McZapkie/MOVER.h"
|
||||
#include "sound.h"
|
||||
|
||||
#define LOGVELOCITY 0
|
||||
#define LOGORDERS 1
|
||||
@@ -1498,8 +1498,12 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
|
||||
TableClear();
|
||||
|
||||
if( WriteLogFlag ) {
|
||||
_mkdir( "physicslog\\" );
|
||||
LogFile.open( std::string( "physicslog\\" + VehicleName + ".dat" ),
|
||||
#ifdef _WIN32
|
||||
CreateDirectory( "physicslog", NULL );
|
||||
#elif __linux__
|
||||
mkdir( "physicslog", 0644 );
|
||||
#endif
|
||||
LogFile.open( std::string( "physicslog/" + VehicleName + ".dat" ),
|
||||
std::ios::in | std::ios::out | std::ios::trunc );
|
||||
#if LOGPRESS == 0
|
||||
LogFile << std::string( " Time [s] Velocity [m/s] Acceleration [m/ss] Coupler.Dist[m] "
|
||||
@@ -1531,7 +1535,7 @@ void TController::CloseLog()
|
||||
|
||||
TController::~TController()
|
||||
{ // wykopanie mechanika z roboty
|
||||
delete tsGuardSignal;
|
||||
sound_man->destroy_sound(&tsGuardSignal);
|
||||
delete TrainParams;
|
||||
CloseLog();
|
||||
};
|
||||
@@ -2539,7 +2543,7 @@ bool TController::DecBrake()
|
||||
bool TController::IncSpeed()
|
||||
{ // zwiększenie prędkości; zwraca false, jeśli dalej się nie da zwiększać
|
||||
if (tsGuardSignal) // jeśli jest dźwięk kierownika
|
||||
if (tsGuardSignal->GetStatus() & DSBSTATUS_PLAYING) // jeśli gada, to nie jedziemy
|
||||
if (tsGuardSignal->is_playing()) // jeśli gada, to nie jedziemy
|
||||
return false;
|
||||
bool OK = true;
|
||||
if( ( iDrivigFlags & moveDoorOpened )
|
||||
@@ -3012,8 +3016,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
|
||||
TrainParams = new TTrainParameters(NewCommand); // rozkład jazdy
|
||||
else
|
||||
TrainParams->NewName(NewCommand); // czyści tabelkę przystanków
|
||||
delete tsGuardSignal;
|
||||
tsGuardSignal = nullptr; // wywalenie kierownika
|
||||
sound_man->destroy_sound(&tsGuardSignal); // wywalenie kierownika
|
||||
if (NewCommand != "none")
|
||||
{
|
||||
if (!TrainParams->LoadTTfile(
|
||||
@@ -3036,9 +3039,9 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
|
||||
NewCommand = Global::asCurrentSceneryPath + NewCommand + ".wav"; // na razie jeden
|
||||
if (FileExists(NewCommand))
|
||||
{ // wczytanie dźwięku odjazdu podawanego bezpośrenido
|
||||
tsGuardSignal = new TTextSound(NewCommand, 30, pVehicle->GetPosition().x,
|
||||
pVehicle->GetPosition().y, pVehicle->GetPosition().z,
|
||||
false);
|
||||
tsGuardSignal = sound_man->create_text_sound(NewCommand);
|
||||
if (tsGuardSignal)
|
||||
tsGuardSignal->position(pVehicle->GetPosition());
|
||||
// rsGuardSignal->Stop();
|
||||
iGuardRadio = 0; // nie przez radio
|
||||
}
|
||||
@@ -3047,9 +3050,9 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
|
||||
NewCommand = NewCommand.insert(NewCommand.find_last_of("."),"radio"); // wstawienie przed kropkč
|
||||
if (FileExists(NewCommand))
|
||||
{ // wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie)
|
||||
tsGuardSignal = new TTextSound(NewCommand, -1, pVehicle->GetPosition().x,
|
||||
pVehicle->GetPosition().y, pVehicle->GetPosition().z,
|
||||
false);
|
||||
tsGuardSignal = sound_man->create_text_sound(NewCommand);
|
||||
if (tsGuardSignal)
|
||||
tsGuardSignal->position(pVehicle->GetPosition());
|
||||
iGuardRadio = iRadioChannel;
|
||||
}
|
||||
}
|
||||
@@ -4393,27 +4396,30 @@ TController::UpdateSituation(double dt) {
|
||||
->DoorOpenCtrl ) // jeśli drzwi niesterowane przez maszynistę
|
||||
Doors( false ); // a EZT zamknie dopiero po odegraniu komunikatu kierownika
|
||||
|
||||
tsGuardSignal->Stop();
|
||||
// w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy
|
||||
// bezpośrednim
|
||||
// albo trzeba zrobić dwa dźwięki, jeden bezpośredni, słyszalny w
|
||||
// pobliżu, a drugi radiowy, słyszalny w innych lokomotywach
|
||||
// na razie zakładam, że to nie jest dźwięk radiowy, bo trzeba by zrobić
|
||||
// obsługę kanałów radiowych itd.
|
||||
if( !iGuardRadio ) {
|
||||
// jeśli nie przez radio
|
||||
tsGuardSignal->Play( 1.0, 0, !FreeFlyModeFlag, pVehicle->GetPosition() ); // dla true jest głośniej
|
||||
}
|
||||
else {
|
||||
// if (iGuardRadio==iRadioChannel) //zgodność kanału
|
||||
// if (!FreeFlyModeFlag) //obserwator musi być w środku pojazdu
|
||||
// (albo może mieć radio przenośne) - kierownik mógłby powtarzać
|
||||
// przy braku reakcji
|
||||
if( SquareMagnitude( pVehicle->GetPosition() - Global::pCameraPosition ) < 2000 * 2000 ) {
|
||||
// w odległości mniejszej niż 2km
|
||||
tsGuardSignal->Play( 1.0, 0, true, pVehicle->GetPosition() ); // dźwięk niby przez radio
|
||||
}
|
||||
}
|
||||
if (tsGuardSignal)
|
||||
{
|
||||
tsGuardSignal->stop();
|
||||
// w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy
|
||||
// bezpośrednim
|
||||
// albo trzeba zrobić dwa dźwięki, jeden bezpośredni, słyszalny w
|
||||
// pobliżu, a drugi radiowy, słyszalny w innych lokomotywach
|
||||
// na razie zakładam, że to nie jest dźwięk radiowy, bo trzeba by zrobić
|
||||
// obsługę kanałów radiowych itd.
|
||||
if( !iGuardRadio ) {
|
||||
// jeśli nie przez radio
|
||||
tsGuardSignal->position(pVehicle->GetPosition()).play();
|
||||
}
|
||||
else {
|
||||
// if (iGuardRadio==iRadioChannel) //zgodność kanału
|
||||
// if (!FreeFlyModeFlag) //obserwator musi być w środku pojazdu
|
||||
// (albo może mieć radio przenośne) - kierownik mógłby powtarzać
|
||||
// przy braku reakcji
|
||||
if( SquareMagnitude( pVehicle->GetPosition() - Global::pCameraPosition ) < 2000 * 2000 ) {
|
||||
// w odległości mniejszej niż 2km
|
||||
tsGuardSignal->position(pVehicle->GetPosition()).play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( mvOccupied->V == 0.0 ) {
|
||||
@@ -4825,19 +4831,41 @@ TController::UpdateSituation(double dt) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((AccDesired < fAccGravity - 0.05) && (AbsAccS < AccDesired - fBrake_a1[0]*0.51)) {
|
||||
// jak hamuje, to nie tykaj kranu za często
|
||||
// yB: luzuje hamulec dopiero przy różnicy opóźnień rzędu 0.2
|
||||
if( OrderList[ OrderPos ] != Disconnect ) {
|
||||
// przy odłączaniu nie zwalniamy tu hamulca
|
||||
DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu
|
||||
}
|
||||
fBrakeTime = (
|
||||
mvOccupied->BrakeDelayFlag > bdelay_G ?
|
||||
mvOccupied->BrakeDelay[ 0 ] :
|
||||
mvOccupied->BrakeDelay[ 2 ] )
|
||||
/ 3.0;
|
||||
fBrakeTime *= 0.5; // Ra: tymczasowo, bo przeżyna S1
|
||||
// Mietek-end1
|
||||
SpeedSet(); // ciągla regulacja prędkości
|
||||
#if LOGVELOCITY
|
||||
WriteLog("BrakePos=" + AnsiString(mvOccupied->BrakeCtrlPos) + ", MainCtrl=" +
|
||||
AnsiString(mvControlling->MainCtrlPos));
|
||||
#endif
|
||||
|
||||
/* //Ra: mamy teraz wskażnik na człon silnikowy, gorzej jak są dwa w
|
||||
ukrotnieniu...
|
||||
//zapobieganie poslizgowi w czlonie silnikowym; Ra: Couplers[1] powinno
|
||||
być
|
||||
if (Controlling->Couplers[0].Connected!=NULL)
|
||||
if (TestFlag(Controlling->Couplers[0].CouplingFlag,ctrain_controll))
|
||||
if (Controlling->Couplers[0].Connected->SlippingWheels)
|
||||
if (Controlling->ScndCtrlPos>0?!Controlling->DecScndCtrl(1):true)
|
||||
{
|
||||
if (!Controlling->DecMainCtrl(1))
|
||||
if (mvOccupied->BrakeCtrlPos==mvOccupied->BrakeCtrlPosNo)
|
||||
mvOccupied->DecBrakeLevel();
|
||||
++iDriverFailCount;
|
||||
}
|
||||
*/
|
||||
// zapobieganie poslizgowi u nas
|
||||
if (mvControlling->SlippingWheels)
|
||||
{
|
||||
if (!mvControlling->DecScndCtrl(2)) // bocznik na zero
|
||||
mvControlling->DecMainCtrl(1);
|
||||
if (mvOccupied->BrakeCtrlPos ==
|
||||
mvOccupied->BrakeCtrlPosNo) // jeśli ostatnia pozycja hamowania
|
||||
//yB: ten warunek wyżej nie ma sensu
|
||||
mvOccupied->DecBrakeLevel(); // to cofnij hamulec
|
||||
else
|
||||
mvControlling->AntiSlippingButton();
|
||||
++iDriverFailCount;
|
||||
//mvControlling->SlippingWheels = false; // flaga już wykorzystana
|
||||
}
|
||||
// stop-gap measure to ensure cars actually brake to stop even when above calculactions go awry
|
||||
// instead of releasing the brakes and creeping into obstacle at 1-2 km/h
|
||||
|
||||
6
Driver.h
6
Driver.h
@@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
//#include <fstream>
|
||||
#include "Classes.h"
|
||||
#include "dumb3d.h"
|
||||
#include "mczapkie/mover.h"
|
||||
#include "McZapkie/MOVER.h"
|
||||
#include <string>
|
||||
using namespace Math3D;
|
||||
using namespace Mtable;
|
||||
@@ -174,7 +174,7 @@ static const int BrakeAccTableSize = 20;
|
||||
class TController
|
||||
{
|
||||
private: // obsługa tabelki prędkości (musi mieć możliwość odhaczania stacji w rozkładzie)
|
||||
int iLast{ 0 }; // ostatnia wypełniona pozycja w tabeli <iFirst (modulo iSpeedTableSize)
|
||||
size_t iLast{ 0 }; // ostatnia wypełniona pozycja w tabeli <iFirst (modulo iSpeedTableSize)
|
||||
int iTableDirection{ 0 }; // kierunek zapełnienia tabelki względem pojazdu z AI
|
||||
std::vector<TSpeedPos> sSpeedTable;
|
||||
double fLastVel = 0.0; // prędkość na poprzednio sprawdzonym torze
|
||||
@@ -240,7 +240,7 @@ private:
|
||||
TTrainParameters *TrainParams = nullptr; // rozkład jazdy zawsze jest, nawet jeśli pusty
|
||||
int iRadioChannel = 1; // numer aktualnego kanału radiowego
|
||||
int iGuardRadio = 0; // numer kanału radiowego kierownika (0, gdy nie używa radia)
|
||||
TTextSound *tsGuardSignal = nullptr; // komunikat od kierownika
|
||||
sound *tsGuardSignal = nullptr; // komunikat od kierownika
|
||||
public:
|
||||
double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji)
|
||||
double AccDesired = AccPreferred; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj)
|
||||
|
||||
50
DummySound.cpp
Normal file
50
DummySound.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "Sound.h"
|
||||
|
||||
TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, std::string const &Directory, std::string const &Filename, int NConcurrent)
|
||||
{
|
||||
};
|
||||
|
||||
TSoundContainer::~TSoundContainer()
|
||||
{
|
||||
};
|
||||
|
||||
LPDIRECTSOUNDBUFFER TSoundContainer::GetUnique(LPDIRECTSOUND pDS)
|
||||
{
|
||||
return new dummysb();
|
||||
};
|
||||
|
||||
TSoundsManager::~TSoundsManager()
|
||||
{
|
||||
};
|
||||
|
||||
void TSoundsManager::Free()
|
||||
{
|
||||
};
|
||||
|
||||
TSoundContainer * TSoundsManager::LoadFromFile( std::string const &Dir, std::string const &Filename, int Concurrent)
|
||||
{
|
||||
return new TSoundContainer(0, Dir, Filename, Concurrent);
|
||||
};
|
||||
|
||||
LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(std::string const &Name, bool Dynamic, float *fSamplingRate)
|
||||
{
|
||||
return new dummysb();
|
||||
};
|
||||
|
||||
void TSoundsManager::RestoreAll()
|
||||
{
|
||||
};
|
||||
|
||||
void TSoundsManager::Init(HWND hWnd)
|
||||
{
|
||||
};
|
||||
617
DynObj.cpp
617
DynObj.cpp
@@ -15,10 +15,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "DynObj.h"
|
||||
|
||||
#include "logs.h"
|
||||
#include "Logs.h"
|
||||
#include "MdlMngr.h"
|
||||
#include "Timer.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
// McZapkie-260202
|
||||
#include "Globals.h"
|
||||
#include "renderer.h"
|
||||
@@ -31,6 +31,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Camera.h" //bo likwidujemy trzęsienie
|
||||
#include "Console.h"
|
||||
#include "Traction.h"
|
||||
#include "sound.h"
|
||||
|
||||
// Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny
|
||||
#define vWorldFront Math3D::vector3(0, 0, 1)
|
||||
@@ -1588,21 +1589,32 @@ TDynamicObject::~TDynamicObject()
|
||||
// parametrow fizycznych
|
||||
SafeDelete(Mechanik);
|
||||
SafeDelete(MoverParameters);
|
||||
// Ra: wyłączanie dźwięków powinno być dodane w ich destruktorach, ale się
|
||||
// sypie
|
||||
/* to też się sypie
|
||||
for (int i=0;i<MaxAxles;++i)
|
||||
rsStukot[i].Stop(); //dzwieki poszczegolnych osi
|
||||
rsSilnik.Stop();
|
||||
rsWentylator.Stop();
|
||||
rsPisk.Stop();
|
||||
rsDerailment.Stop();
|
||||
sPantUp.Stop();
|
||||
sPantDown.Stop();
|
||||
sBrakeAcc.Stop(); //dzwiek przyspieszacza
|
||||
rsDiesielInc.Stop();
|
||||
rscurve.Stop();
|
||||
*/
|
||||
|
||||
for (size_t i = 0; i < MaxAxles; i++)
|
||||
sound_man->destroy_sound(&rsStukot[i]);
|
||||
sound_man->destroy_sound(&rsSilnik);
|
||||
sound_man->destroy_sound(&rsWentylator);
|
||||
sound_man->destroy_sound(&rsPisk);
|
||||
sound_man->destroy_sound(&rsDerailment);
|
||||
sound_man->destroy_sound(&rsPrzekladnia);
|
||||
sound_man->destroy_sound(&sHorn1);
|
||||
sound_man->destroy_sound(&sHorn2);
|
||||
sound_man->destroy_sound(&sCompressor);
|
||||
sound_man->destroy_sound(&sConverter);
|
||||
sound_man->destroy_sound(&sSmallCompressor);
|
||||
sound_man->destroy_sound(&sDepartureSignal);
|
||||
sound_man->destroy_sound(&sTurbo);
|
||||
sound_man->destroy_sound(&sSand);
|
||||
sound_man->destroy_sound(&sReleaser);
|
||||
sound_man->destroy_sound(&sPantUp);
|
||||
sound_man->destroy_sound(&sPantDown);
|
||||
sound_man->destroy_sound(&rsDoorOpen);
|
||||
sound_man->destroy_sound(&rsDoorClose);
|
||||
sound_man->destroy_sound(&sBrakeAcc);
|
||||
sound_man->destroy_sound(&rsUnbrake);
|
||||
sound_man->destroy_sound(&rsDiesielInc);
|
||||
sound_man->destroy_sound(&rscurve);
|
||||
|
||||
/*
|
||||
delete[] pAnimations; // obiekty obsługujące animację
|
||||
*/
|
||||
@@ -2984,7 +2996,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// McZapkie-270202
|
||||
if (MyTrack->fSoundDistance != -1)
|
||||
{
|
||||
if (ObjectDist < rsStukot[0].dSoundAtt * rsStukot[0].dSoundAtt * 15.0)
|
||||
//m7todo: restore
|
||||
//if (ObjectDist < rsStukot[0].dSoundAtt * rsStukot[0].dSoundAtt * 15.0)
|
||||
{
|
||||
vol = (20.0 + MyTrack->iDamageFlag) / 21;
|
||||
if (MyTrack->eEnvironment == e_tunnel)
|
||||
@@ -3019,16 +3032,15 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// McZapkie-040302
|
||||
if (i == iAxles - 1)
|
||||
{
|
||||
rsStukot[0].Stop();
|
||||
if (rsStukot[0]) rsStukot[0]->stop();
|
||||
MoverParameters->AccV +=
|
||||
0.5 * GetVelocity() / (1 + MoverParameters->Vmax);
|
||||
}
|
||||
else
|
||||
{
|
||||
rsStukot[i + 1].Stop();
|
||||
if (rsStukot[i + 1]) rsStukot[i + 1]->stop();
|
||||
}
|
||||
rsStukot[i].Play(vol, 0, MechInside,
|
||||
vPosition); // poprawic pozycje o uklad osi
|
||||
if (rsStukot[i]) rsStukot[i]->gain(vol).position(vPosition).play(); // poprawic pozycje o uklad osi
|
||||
if (i == 1)
|
||||
MoverParameters->AccV -=
|
||||
0.5 * GetVelocity() / (1 + MoverParameters->Vmax);
|
||||
@@ -3045,11 +3057,10 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
int flag = MoverParameters->Hamulec->GetSoundFlag();
|
||||
if ((bBrakeAcc) && (TestFlag(flag, sf_Acc)) && (ObjectDist < 2500))
|
||||
{
|
||||
sBrakeAcc->SetVolume(-ObjectDist * 3 - (FreeFlyModeFlag ? 0 : 2000));
|
||||
sBrakeAcc->Play(0, 0, 0);
|
||||
sBrakeAcc->SetPan(10000 * sin(ModCamRot));
|
||||
sBrakeAcc->gain(-ObjectDist * 3 - (FreeFlyModeFlag ? 0 : 2000));
|
||||
sBrakeAcc->play();
|
||||
}
|
||||
if ((rsUnbrake.AM != 0) && (ObjectDist < 5000))
|
||||
if ((rsUnbrake) && (ObjectDist < 5000))
|
||||
{
|
||||
if ((TestFlag(flag, sf_CylU)) &&
|
||||
((MoverParameters->BrakePress * MoverParameters->MaxBrakePress[3]) > 0.05))
|
||||
@@ -3060,11 +3071,10 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
MoverParameters->MaxBrakePress[3]),
|
||||
1);
|
||||
vol = vol + (FreeFlyModeFlag ? 0 : -0.5) - ObjectDist / 5000;
|
||||
rsUnbrake.SetPan(10000 * sin(ModCamRot));
|
||||
rsUnbrake.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
rsUnbrake->loop().gain(vol).position(GetPosition()).play();
|
||||
}
|
||||
else
|
||||
rsUnbrake.Stop();
|
||||
rsUnbrake->stop();
|
||||
}
|
||||
|
||||
// fragment z EXE Kursa
|
||||
@@ -3177,8 +3187,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
&& ( PantDiff < 0.01 ) ) // tolerancja niedolegania
|
||||
{
|
||||
if ((MoverParameters->PantFrontVolt == 0.0) &&
|
||||
(MoverParameters->PantRearVolt == 0.0))
|
||||
sPantUp.Play(vol, 0, MechInside, vPosition);
|
||||
(MoverParameters->PantRearVolt == 0.0) && sPantUp)
|
||||
sPantUp->gain(vol).position(vPosition).play();
|
||||
if (p->hvPowerWire) // TODO: wyliczyć trzeba prąd przypadający na
|
||||
// pantograf i
|
||||
// wstawić do GetVoltage()
|
||||
@@ -3206,8 +3216,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
&& ( PantDiff < 0.01 ) )
|
||||
{
|
||||
if ((MoverParameters->PantRearVolt == 0.0) &&
|
||||
(MoverParameters->PantFrontVolt == 0.0))
|
||||
sPantUp.Play(vol, 0, MechInside, vPosition);
|
||||
(MoverParameters->PantFrontVolt == 0.0) && sPantUp)
|
||||
sPantUp->gain(vol).position(vPosition).play();
|
||||
if (p->hvPowerWire) // TODO: wyliczyć trzeba prąd przypadający na
|
||||
// pantograf i
|
||||
// wstawić do GetVoltage()
|
||||
@@ -3294,12 +3304,12 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
} // koniec pętli po pantografach
|
||||
if ((MoverParameters->PantFrontSP == false) && (MoverParameters->PantFrontUp == false))
|
||||
{
|
||||
sPantDown.Play(vol, 0, MechInside, vPosition);
|
||||
if (sPantDown) sPantDown->gain(vol).position(vPosition).play();
|
||||
MoverParameters->PantFrontSP = true;
|
||||
}
|
||||
if ((MoverParameters->PantRearSP == false) && (MoverParameters->PantRearUp == false))
|
||||
{
|
||||
sPantDown.Play(vol, 0, MechInside, vPosition);
|
||||
if (sPantDown) sPantDown->gain(vol).position(vPosition).play();
|
||||
MoverParameters->PantRearSP = true;
|
||||
}
|
||||
/*
|
||||
@@ -3402,24 +3412,24 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// NBMX Obsluga drzwi, MC: zuniwersalnione
|
||||
if ((dDoorMoveL < MoverParameters->DoorMaxShiftL) && (MoverParameters->DoorLeftOpened))
|
||||
{
|
||||
rsDoorOpen.Play(1, 0, MechInside, vPosition);
|
||||
if (rsDoorOpen) rsDoorOpen->position(vPosition).play();
|
||||
dDoorMoveL += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
|
||||
}
|
||||
if ((dDoorMoveL > 0) && (!MoverParameters->DoorLeftOpened))
|
||||
{
|
||||
rsDoorClose.Play(1, 0, MechInside, vPosition);
|
||||
if (rsDoorClose) rsDoorClose->position(vPosition).play();
|
||||
dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed;
|
||||
if (dDoorMoveL < 0)
|
||||
dDoorMoveL = 0;
|
||||
}
|
||||
if ((dDoorMoveR < MoverParameters->DoorMaxShiftR) && (MoverParameters->DoorRightOpened))
|
||||
{
|
||||
rsDoorOpen.Play(1, 0, MechInside, vPosition);
|
||||
if (rsDoorOpen) rsDoorOpen->position(vPosition).play();
|
||||
dDoorMoveR += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
|
||||
}
|
||||
if ((dDoorMoveR > 0) && (!MoverParameters->DoorRightOpened))
|
||||
{
|
||||
rsDoorClose.Play(1, 0, MechInside, vPosition);
|
||||
if (rsDoorClose) rsDoorClose->position(vPosition).play();
|
||||
dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed;
|
||||
if (dDoorMoveR < 0)
|
||||
dDoorMoveR = 0;
|
||||
@@ -3559,7 +3569,7 @@ void TDynamicObject::RenderSounds()
|
||||
|
||||
if (MoverParameters->Power > 0)
|
||||
{
|
||||
if ((rsSilnik.AM != 0)
|
||||
if ((rsSilnik)
|
||||
&& ((MoverParameters->Mains)
|
||||
// McZapkie-280503: zeby dla dumb dzialal silnik na jalowych obrotach
|
||||
|| (MoverParameters->EngineType == DieselEngine)))
|
||||
@@ -3567,39 +3577,33 @@ void TDynamicObject::RenderSounds()
|
||||
if ((fabs(MoverParameters->enrot) > 0.01) ||
|
||||
(MoverParameters->EngineType == Dumb)) //&& (MoverParameters->EnginePower>0.1))
|
||||
{
|
||||
freq = rsSilnik.FM * fabs(MoverParameters->enrot) + rsSilnik.FA;
|
||||
freq = fabs(MoverParameters->enrot);
|
||||
if (MoverParameters->EngineType == Dumb)
|
||||
freq = freq -
|
||||
0.2 * MoverParameters->EnginePower / (1 + MoverParameters->Power * 1000);
|
||||
rsSilnik.AdjFreq(freq, dt);
|
||||
rsSilnik->pitch(freq);
|
||||
if (MoverParameters->EngineType == DieselEngine)
|
||||
{
|
||||
if (MoverParameters->enrot > 0)
|
||||
{
|
||||
if (MoverParameters->EnginePower > 0)
|
||||
vol = rsSilnik.AM * MoverParameters->dizel_fill + rsSilnik.AA;
|
||||
vol = MoverParameters->dizel_fill;
|
||||
else
|
||||
vol =
|
||||
rsSilnik.AM * fabs(MoverParameters->enrot / MoverParameters->dizel_nmax) +
|
||||
rsSilnik.AA * 0.9;
|
||||
fabs(MoverParameters->enrot / MoverParameters->dizel_nmax);
|
||||
}
|
||||
else
|
||||
vol = 0;
|
||||
}
|
||||
else if (MoverParameters->EngineType == DieselElectric)
|
||||
vol = rsSilnik.AM *
|
||||
(MoverParameters->EnginePower / 1000 / MoverParameters->Power) +
|
||||
vol = (MoverParameters->EnginePower / 1000 / MoverParameters->Power) +
|
||||
0.2 * (MoverParameters->enrot * 60) /
|
||||
(MoverParameters->DElist[MoverParameters->MainCtrlPosNo].RPM) +
|
||||
rsSilnik.AA;
|
||||
(MoverParameters->DElist[MoverParameters->MainCtrlPosNo].RPM);
|
||||
else if (MoverParameters->EngineType == ElectricInductionMotor)
|
||||
vol = rsSilnik.AM *
|
||||
(MoverParameters->EnginePower + fabs(MoverParameters->enrot * 2)) +
|
||||
rsSilnik.AA;
|
||||
vol = (MoverParameters->EnginePower + fabs(MoverParameters->enrot * 2));
|
||||
else
|
||||
vol = rsSilnik.AM * (MoverParameters->EnginePower / 1000 +
|
||||
fabs(MoverParameters->enrot) * 60.0) +
|
||||
rsSilnik.AA;
|
||||
vol = (MoverParameters->EnginePower / 1000 +
|
||||
fabs(MoverParameters->enrot) * 60.0);
|
||||
// McZapkie-250302 - natezenie zalezne od obrotow i mocy
|
||||
if ((vol < 1) && (MoverParameters->EngineType == ElectricSeriesMotor) &&
|
||||
(MoverParameters->EnginePower < 100))
|
||||
@@ -3632,11 +3636,11 @@ void TDynamicObject::RenderSounds()
|
||||
if (enginevolume > 0.0001)
|
||||
if (MoverParameters->EngineType != DieselElectric)
|
||||
{
|
||||
rsSilnik.Play(enginevolume, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
rsSilnik->loop().gain(enginevolume).position(GetPosition()).play();
|
||||
}
|
||||
else
|
||||
{
|
||||
sConverter.UpdateAF(vol, freq, MechInside, GetPosition());
|
||||
if (sConverter) sConverter->gain(vol).pitch(freq).position(GetPosition());
|
||||
|
||||
float fincvol;
|
||||
fincvol = 0;
|
||||
@@ -3647,100 +3651,114 @@ void TDynamicObject::RenderSounds()
|
||||
(MoverParameters->enrot * 60));
|
||||
fincvol /= (0.05 * MoverParameters->DElist[0].RPM);
|
||||
};
|
||||
if (fincvol > 0.02)
|
||||
rsDiesielInc.Play(fincvol, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
else
|
||||
rsDiesielInc.Stop();
|
||||
if (rsDiesielInc)
|
||||
{
|
||||
if (fincvol > 0.02)
|
||||
rsDiesielInc->loop().position(GetPosition()).gain(fincvol).play();
|
||||
else
|
||||
rsDiesielInc->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
rsSilnik.Stop();
|
||||
rsSilnik->stop();
|
||||
}
|
||||
enginevolume = (enginevolume + vol) * 0.5;
|
||||
if( enginevolume < 0.01 ) {
|
||||
rsSilnik.Stop();
|
||||
if (rsSilnik) rsSilnik->stop();
|
||||
}
|
||||
if ( ( MoverParameters->EngineType == ElectricSeriesMotor )
|
||||
|| ( MoverParameters->EngineType == ElectricInductionMotor )
|
||||
&& ( rsWentylator.AM != 0 ) )
|
||||
if ( (( MoverParameters->EngineType == ElectricSeriesMotor )
|
||||
|| ( MoverParameters->EngineType == ElectricInductionMotor ))
|
||||
&& ( rsWentylator ) )
|
||||
{
|
||||
if (MoverParameters->RventRot > 0.1) {
|
||||
// play ventilator sound if the ventilators are rotating fast enough...
|
||||
freq = rsWentylator.FM * MoverParameters->RventRot + rsWentylator.FA;
|
||||
rsWentylator.AdjFreq(freq, dt);
|
||||
freq = MoverParameters->RventRot;
|
||||
rsWentylator->pitch(freq);
|
||||
if( MoverParameters->EngineType == ElectricInductionMotor ) {
|
||||
|
||||
vol = rsWentylator.AM * std::sqrt( std::fabs( MoverParameters->dizel_fill ) ) + rsWentylator.AA;
|
||||
vol = std::sqrt( std::fabs( MoverParameters->dizel_fill ) );
|
||||
}
|
||||
else {
|
||||
|
||||
vol = rsWentylator.AM * MoverParameters->RventRot + rsWentylator.AA;
|
||||
vol = MoverParameters->RventRot;
|
||||
}
|
||||
rsWentylator.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
rsWentylator->gain(vol).loop().position(GetPosition()).play();
|
||||
}
|
||||
else {
|
||||
// ...otherwise shut down the sound
|
||||
rsWentylator.Stop();
|
||||
rsWentylator->stop();
|
||||
}
|
||||
}
|
||||
if (MoverParameters->TrainType == dt_ET40)
|
||||
if (MoverParameters->TrainType == dt_ET40 && rsPrzekladnia)
|
||||
{
|
||||
if (MoverParameters->Vel > 0.1)
|
||||
{
|
||||
freq = rsPrzekladnia.FM * (MoverParameters->Vel) + rsPrzekladnia.FA;
|
||||
rsPrzekladnia.AdjFreq(freq, dt);
|
||||
vol = rsPrzekladnia.AM * (MoverParameters->Vel) + rsPrzekladnia.AA;
|
||||
rsPrzekladnia.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
freq = MoverParameters->Vel;
|
||||
rsPrzekladnia->pitch(freq);
|
||||
vol = MoverParameters->Vel;
|
||||
rsPrzekladnia->loop().position(GetPosition()).gain(vol).play();
|
||||
}
|
||||
else
|
||||
rsPrzekladnia.Stop();
|
||||
rsPrzekladnia->stop();
|
||||
}
|
||||
}
|
||||
|
||||
// youBy: dzwiek ostrych lukow i ciasnych zwrotek
|
||||
|
||||
if ((ts.R * ts.R > 1) && (MoverParameters->Vel > 0))
|
||||
vol = MoverParameters->AccN * MoverParameters->AccN;
|
||||
else
|
||||
vol = 0;
|
||||
// vol+=(50000/ts.R*ts.R);
|
||||
|
||||
if (vol > 0.001)
|
||||
if (rscurve)
|
||||
{
|
||||
rscurve.Play(2 * vol, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
if ((ts.R * ts.R > 1) && (MoverParameters->Vel > 0))
|
||||
vol = MoverParameters->AccN * MoverParameters->AccN;
|
||||
else
|
||||
vol = 0;
|
||||
// vol+=(50000/ts.R*ts.R);
|
||||
|
||||
if (vol > 0.001)
|
||||
{
|
||||
rscurve->gain(2 * vol).loop().position(GetPosition()).play();
|
||||
}
|
||||
else
|
||||
rscurve->stop();
|
||||
}
|
||||
else
|
||||
rscurve.Stop();
|
||||
|
||||
// McZapkie-280302 - pisk mocno zacisnietych hamulcow - trzeba jeszcze
|
||||
// zabezpieczyc przed
|
||||
// brakiem deklaracji w mmedia.dta
|
||||
if (rsPisk.AM != 0)
|
||||
|
||||
if (rsPisk)
|
||||
{
|
||||
if ((MoverParameters->Vel > (rsPisk.GetStatus() != 0 ? 0.01 : 0.5)) &&
|
||||
(!MoverParameters->SlippingWheels) && (MoverParameters->UnitBrakeForce > rsPisk.AM))
|
||||
if ((MoverParameters->Vel > (rsPisk->is_playing() != 0 ? 0.01 : 0.5)) &&
|
||||
(!MoverParameters->SlippingWheels) && (MoverParameters->UnitBrakeForce > rsPisk->gain_mul))
|
||||
{
|
||||
vol = MoverParameters->UnitBrakeForce / (rsPisk.AM + 1) + rsPisk.AA;
|
||||
rsPisk.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
vol = (MoverParameters->UnitBrakeForce / (rsPisk->gain_mul + 1)) / rsPisk->gain_mul;
|
||||
rsPisk->gain(vol).loop().position(GetPosition()).play();
|
||||
}
|
||||
else
|
||||
rsPisk.Stop();
|
||||
rsPisk->stop();
|
||||
}
|
||||
|
||||
if (MoverParameters->SandDose) // Dzwiek piasecznicy
|
||||
sSand.TurnOn(MechInside, GetPosition());
|
||||
else
|
||||
sSand.TurnOff(MechInside, GetPosition());
|
||||
sSand.Update(MechInside, GetPosition());
|
||||
if (MoverParameters->Hamulec->GetStatus() & b_rls) // Dzwiek odluzniacza
|
||||
sReleaser.TurnOn(MechInside, GetPosition());
|
||||
else
|
||||
sReleaser.TurnOff(MechInside, GetPosition());
|
||||
//sReleaser.Update(MechInside, GetPosition());
|
||||
double releaser_vol = 1;
|
||||
if (MoverParameters->BrakePress < 0.1)
|
||||
releaser_vol = MoverParameters->BrakePress * 10;
|
||||
sReleaser.UpdateAF(releaser_vol, 1, MechInside, GetPosition());
|
||||
if (sSand)
|
||||
{
|
||||
if (MoverParameters->SandDose) // Dzwiek piasecznicy
|
||||
sSand->position(GetPosition()).play();
|
||||
else
|
||||
sSand->stop();
|
||||
}
|
||||
|
||||
if (sReleaser)
|
||||
{
|
||||
if (MoverParameters->Hamulec->GetStatus() & b_rls) // Dzwiek odluzniacza
|
||||
sReleaser->position(GetPosition()).play();
|
||||
else
|
||||
sReleaser->stop();
|
||||
//sReleaser.Update(MechInside, GetPosition());
|
||||
double releaser_vol = 1;
|
||||
if (MoverParameters->BrakePress < 0.1)
|
||||
releaser_vol = MoverParameters->BrakePress * 10;
|
||||
|
||||
sReleaser->gain(releaser_vol);
|
||||
}
|
||||
// if ((MoverParameters->ConverterFlag==false) &&
|
||||
// (MoverParameters->TrainType!=dt_ET22))
|
||||
// if
|
||||
@@ -3752,51 +3770,59 @@ void TDynamicObject::RenderSounds()
|
||||
// MoverParameters->CompressorAllow=MoverParameters->ConverterFlag;
|
||||
|
||||
// McZapkie! - dzwiek compressor.wav tylko gdy dziala sprezarka
|
||||
if (MoverParameters->VeselVolume != 0)
|
||||
{
|
||||
if (MoverParameters->CompressorFlag)
|
||||
sCompressor.TurnOn(MechInside, GetPosition());
|
||||
else
|
||||
sCompressor.TurnOff(MechInside, GetPosition());
|
||||
sCompressor.Update(MechInside, GetPosition());
|
||||
}
|
||||
if (MoverParameters->PantCompFlag) // Winger 160404 - dzwiek malej sprezarki
|
||||
sSmallCompressor.TurnOn(MechInside, GetPosition());
|
||||
else
|
||||
sSmallCompressor.TurnOff(MechInside, GetPosition());
|
||||
sSmallCompressor.Update(MechInside, GetPosition());
|
||||
|
||||
// youBy - przenioslem, bo diesel tez moze miec turbo
|
||||
if( (MoverParameters->TurboTest > 0)
|
||||
&& (MoverParameters->MainCtrlPos >= MoverParameters->TurboTest))
|
||||
if (sCompressor)
|
||||
{
|
||||
// udawanie turbo: (6.66*(eng_vol-0.85))
|
||||
if (eng_turbo > 6.66 * (enginevolume - 0.8) + 0.2 * dt)
|
||||
eng_turbo = eng_turbo - 0.2 * dt; // 0.125
|
||||
else if (eng_turbo < 6.66 * (enginevolume - 0.8) - 0.4 * dt)
|
||||
eng_turbo = eng_turbo + 0.4 * dt; // 0.333
|
||||
else
|
||||
eng_turbo = 6.66 * (enginevolume - 0.8);
|
||||
|
||||
sTurbo.TurnOn(MechInside, GetPosition());
|
||||
// sTurbo.UpdateAF(eng_turbo,0.7+(eng_turbo*0.6),MechInside,GetPosition());
|
||||
sTurbo.UpdateAF(3 * eng_turbo - 1, 0.4 + eng_turbo * 0.4, MechInside, GetPosition());
|
||||
// eng_vol_act=enginevolume;
|
||||
// eng_frq_act=eng_frq;
|
||||
if (MoverParameters->VeselVolume != 0)
|
||||
{
|
||||
if (MoverParameters->CompressorFlag)
|
||||
sCompressor->position(GetPosition()).play();
|
||||
else
|
||||
sCompressor->stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (sSmallCompressor)
|
||||
{
|
||||
if (MoverParameters->PantCompFlag) // Winger 160404 - dzwiek malej sprezarki
|
||||
sSmallCompressor->position(GetPosition()).play();
|
||||
else
|
||||
sSmallCompressor->stop();
|
||||
}
|
||||
|
||||
if (sTurbo)
|
||||
{
|
||||
// youBy - przenioslem, bo diesel tez moze miec turbo
|
||||
if( (MoverParameters->TurboTest > 0)
|
||||
&& (MoverParameters->MainCtrlPos >= MoverParameters->TurboTest))
|
||||
{
|
||||
// udawanie turbo: (6.66*(eng_vol-0.85))
|
||||
if (eng_turbo > 6.66 * (enginevolume - 0.8) + 0.2 * dt)
|
||||
eng_turbo = eng_turbo - 0.2 * dt; // 0.125
|
||||
else if (eng_turbo < 6.66 * (enginevolume - 0.8) - 0.4 * dt)
|
||||
eng_turbo = eng_turbo + 0.4 * dt; // 0.333
|
||||
else
|
||||
eng_turbo = 6.66 * (enginevolume - 0.8);
|
||||
|
||||
sTurbo->gain(3 * eng_turbo - 1).pitch(0.4 + eng_turbo * 0.4).position(GetPosition()).play();
|
||||
}
|
||||
else
|
||||
sTurbo->stop();
|
||||
}
|
||||
else
|
||||
sTurbo.TurnOff(MechInside, GetPosition());
|
||||
|
||||
if (MoverParameters->TrainType == dt_PseudoDiesel)
|
||||
{
|
||||
// ABu: udawanie woodwarda dla lok. spalinowych
|
||||
// jesli silnik jest podpiety pod dzwiek przetwornicy
|
||||
if (MoverParameters->ConverterFlag) // NBMX dzwiek przetwornicy
|
||||
if (sConverter)
|
||||
{
|
||||
sConverter.TurnOn(MechInside, GetPosition());
|
||||
if (MoverParameters->ConverterFlag) // NBMX dzwiek przetwornicy
|
||||
{
|
||||
sConverter->position(GetPosition()).play();
|
||||
}
|
||||
else
|
||||
sConverter->stop();
|
||||
}
|
||||
else
|
||||
sConverter.TurnOff(MechInside, GetPosition());
|
||||
|
||||
// glosnosc zalezy od stosunku mocy silnika el. do mocy max
|
||||
double eng_vol;
|
||||
@@ -3843,7 +3869,7 @@ void TDynamicObject::RenderSounds()
|
||||
if (eng_frq_act < defrot + 0.1 * dt)
|
||||
eng_frq_act = defrot;
|
||||
}
|
||||
sConverter.UpdateAF(eng_vol_act, eng_frq_act + eng_dfrq, MechInside, GetPosition());
|
||||
if (sConverter) sConverter->gain(eng_vol_act).pitch(eng_frq_act + eng_dfrq).position(GetPosition());
|
||||
// udawanie turbo: (6.66*(eng_vol-0.85))
|
||||
if (eng_turbo > 6.66 * (eng_vol - 0.8) + 0.2 * dt)
|
||||
eng_turbo = eng_turbo - 0.2 * dt; // 0.125
|
||||
@@ -3852,62 +3878,67 @@ void TDynamicObject::RenderSounds()
|
||||
else
|
||||
eng_turbo = 6.66 * (eng_vol - 0.8);
|
||||
|
||||
sTurbo.TurnOn(MechInside, GetPosition());
|
||||
if (sTurbo) sTurbo->gain(3 * eng_turbo - 1).pitch(0.4 + eng_turbo * 0.4).position(GetPosition()).play();
|
||||
// sTurbo.UpdateAF(eng_turbo,0.7+(eng_turbo*0.6),MechInside,GetPosition());
|
||||
sTurbo.UpdateAF(3 * eng_turbo - 1, 0.4 + eng_turbo * 0.4, MechInside, GetPosition());
|
||||
eng_vol_act = eng_vol;
|
||||
// eng_frq_act=eng_frq;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MoverParameters->ConverterFlag) // NBMX dzwiek przetwornicy
|
||||
sConverter.TurnOn(MechInside, GetPosition());
|
||||
else
|
||||
sConverter.TurnOff(MechInside, GetPosition());
|
||||
sConverter.Update(MechInside, GetPosition());
|
||||
if (sConverter)
|
||||
{
|
||||
if (MoverParameters->ConverterFlag) // NBMX dzwiek przetwornicy
|
||||
{
|
||||
sConverter->position(GetPosition()).play();
|
||||
}
|
||||
else
|
||||
sConverter->stop();
|
||||
}
|
||||
}
|
||||
|
||||
if( TestFlag( MoverParameters->WarningSignal, 1 ) ) {
|
||||
sHorn1.TurnOn( MechInside, GetPosition() );
|
||||
}
|
||||
else {
|
||||
sHorn1.TurnOff( MechInside, GetPosition() );
|
||||
}
|
||||
if( TestFlag( MoverParameters->WarningSignal, 2 ) ) {
|
||||
sHorn2.TurnOn( MechInside, GetPosition() );
|
||||
}
|
||||
else {
|
||||
sHorn2.TurnOff( MechInside, GetPosition() );
|
||||
if (sHorn1)
|
||||
{
|
||||
if( TestFlag( MoverParameters->WarningSignal, 1 ) ) {
|
||||
sHorn1->position(GetPosition()).play();
|
||||
}
|
||||
else {
|
||||
sHorn1->stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (MoverParameters->DoorClosureWarning)
|
||||
if (sHorn2)
|
||||
{
|
||||
if (MoverParameters->DepartureSignal) // NBMX sygnal odjazdu, MC: pod warunkiem ze jest
|
||||
// zdefiniowane w chk
|
||||
sDepartureSignal.TurnOn(MechInside, GetPosition());
|
||||
else
|
||||
sDepartureSignal.TurnOff(MechInside, GetPosition());
|
||||
sDepartureSignal.Update(MechInside, GetPosition());
|
||||
if( TestFlag( MoverParameters->WarningSignal, 2 ) ) {
|
||||
sHorn2->position(GetPosition()).play();
|
||||
}
|
||||
else {
|
||||
sHorn2->stop();
|
||||
}
|
||||
}
|
||||
sHorn1.Update(MechInside, GetPosition());
|
||||
sHorn2.Update(MechInside, GetPosition());
|
||||
// McZapkie: w razie wykolejenia
|
||||
if (MoverParameters->EventFlag)
|
||||
|
||||
if (sDepartureSignal)
|
||||
{
|
||||
if (TestFlag(MoverParameters->DamageFlag, dtrain_out) && GetVelocity() > 0)
|
||||
rsDerailment.Play(1, 0, true, GetPosition());
|
||||
if (GetVelocity() == 0)
|
||||
rsDerailment.Stop();
|
||||
if (MoverParameters->DoorClosureWarning)
|
||||
{
|
||||
if (MoverParameters->DepartureSignal) // NBMX sygnal odjazdu, MC: pod warunkiem ze jest
|
||||
// zdefiniowane w chk
|
||||
sDepartureSignal->position(GetPosition()).play();
|
||||
else
|
||||
sDepartureSignal->stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (rsDerailment)
|
||||
{
|
||||
// McZapkie: w razie wykolejenia
|
||||
if (MoverParameters->EventFlag)
|
||||
{
|
||||
if (TestFlag(MoverParameters->DamageFlag, dtrain_out) && GetVelocity() > 0)
|
||||
rsDerailment->position(GetPosition()).play();
|
||||
if (GetVelocity() == 0)
|
||||
rsDerailment->stop();
|
||||
}
|
||||
}
|
||||
/* //Ra: dwa razy?
|
||||
if (MoverParameters->EventFlag)
|
||||
{
|
||||
if (TestFlag(MoverParameters->DamageFlag,dtrain_out) && GetVelocity()>0)
|
||||
rsDerailment.Play(1,0,true,GetPosition());
|
||||
if (GetVelocity()==0)
|
||||
rsDerailment.Stop();
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
// McZapkie-250202
|
||||
@@ -3938,7 +3969,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser.getTokens(); parser >> token;
|
||||
|
||||
if( ( token == "models:" )
|
||||
|| ( token == "models:" ) ) { // crude way to handle utf8 bom potentially appearing before the first token
|
||||
|| ( token == "\xef\xbb\xbfmodels:" ) ) { // crude way to handle utf8 bom potentially appearing before the first token
|
||||
// modele i podmodele
|
||||
m_materialdata.multi_textures = 0; // czy jest wiele tekstur wymiennych?
|
||||
parser.getTokens();
|
||||
@@ -4609,12 +4640,12 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
for( int i = 0; i < iAxles; i++ ) {
|
||||
parser.getTokens( 1, false );
|
||||
parser >> dWheelsPosition[ i ];
|
||||
parser.getTokens();
|
||||
parser.getTokens(1, false);
|
||||
parser >> token;
|
||||
if( token != "end" ) {
|
||||
rsStukot[ i ].Init( token, dSDist, GetPosition().x,
|
||||
GetPosition().y + dWheelsPosition[ i ], GetPosition().z,
|
||||
true );
|
||||
rsStukot[i] = sound_man->create_sound(token);
|
||||
if (rsStukot[i]) rsStukot[i]->position(glm::vec3(GetPosition().x,
|
||||
GetPosition().y + dWheelsPosition[ i ], GetPosition().z)).dist(dSDist);
|
||||
}
|
||||
}
|
||||
if( token != "end" ) {
|
||||
@@ -4631,32 +4662,31 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rsSilnik.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true, true );
|
||||
if( rsSilnik.GetWaveTime() == 0 ) {
|
||||
ErrorLog( "Missed sound: \"" + token + "\" for " + asFileName );
|
||||
}
|
||||
parser.getTokens( 1, false );
|
||||
parser >> rsSilnik.AM;
|
||||
if( MoverParameters->EngineType == DieselEngine ) {
|
||||
rsSilnik = sound_man->create_sound(token);
|
||||
if (rsSilnik)
|
||||
{
|
||||
rsSilnik->dist(attenuation);
|
||||
parser.getTokens( 4, false );
|
||||
|
||||
rsSilnik.AM /= ( MoverParameters->Power + MoverParameters->nmax * 60 );
|
||||
}
|
||||
else if( MoverParameters->EngineType == DieselElectric ) {
|
||||
parser >> rsSilnik->gain_mul;
|
||||
if( MoverParameters->EngineType == DieselEngine ) {
|
||||
|
||||
rsSilnik.AM /= ( MoverParameters->Power * 3 );
|
||||
}
|
||||
else {
|
||||
rsSilnik->gain_mul /= ( MoverParameters->Power + MoverParameters->nmax * 60 );
|
||||
}
|
||||
else if( MoverParameters->EngineType == DieselElectric ) {
|
||||
|
||||
rsSilnik.AM /= ( MoverParameters->Power + MoverParameters->nmax * 60 + MoverParameters->Power + MoverParameters->Power );
|
||||
}
|
||||
parser.getTokens( 3, false );
|
||||
parser
|
||||
>> rsSilnik.AA
|
||||
>> rsSilnik.FM // MoverParameters->nmax;
|
||||
>> rsSilnik.FA;
|
||||
rsSilnik->gain_mul /= ( MoverParameters->Power * 3 );
|
||||
}
|
||||
else {
|
||||
|
||||
rsSilnik->gain_mul /= ( MoverParameters->Power + MoverParameters->nmax * 60 + MoverParameters->Power + MoverParameters->Power );
|
||||
}
|
||||
|
||||
parser
|
||||
>> rsSilnik->gain_off
|
||||
>> rsSilnik->pitch_mul // MoverParameters->nmax;
|
||||
>> rsSilnik->pitch_off;
|
||||
}
|
||||
}
|
||||
|
||||
else if( ( token == "ventilator:" )
|
||||
@@ -4668,18 +4698,19 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rsWentylator.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true, true );
|
||||
parser.getTokens( 4, false );
|
||||
parser
|
||||
>> rsWentylator.AM
|
||||
>> rsWentylator.AA
|
||||
>> rsWentylator.FM
|
||||
>> rsWentylator.FA;
|
||||
rsWentylator.AM /= MoverParameters->RVentnmax;
|
||||
rsWentylator.FM /= MoverParameters->RVentnmax;
|
||||
rsWentylator = sound_man->create_sound(token);
|
||||
if (rsWentylator)
|
||||
{
|
||||
rsWentylator->dist(attenuation);
|
||||
parser.getTokens( 4, false );
|
||||
parser
|
||||
>> rsWentylator->gain_mul
|
||||
>> rsWentylator->gain_off
|
||||
>> rsWentylator->pitch_mul
|
||||
>> rsWentylator->pitch_off;
|
||||
rsWentylator->gain_mul /= MoverParameters->RVentnmax;
|
||||
rsWentylator->pitch_mul /= MoverParameters->RVentnmax;
|
||||
}
|
||||
}
|
||||
|
||||
else if( ( token == "transmission:" )
|
||||
@@ -4690,14 +4721,15 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rsPrzekladnia.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rsPrzekladnia.AM = 0.029;
|
||||
rsPrzekladnia.AA = 0.1;
|
||||
rsPrzekladnia.FM = 0.005;
|
||||
rsPrzekladnia.FA = 1.0;
|
||||
rsPrzekladnia = sound_man->create_sound(token);
|
||||
if (rsPrzekladnia)
|
||||
{
|
||||
rsPrzekladnia->dist(attenuation);
|
||||
rsPrzekladnia->gain_mul = 0.029;
|
||||
rsPrzekladnia->gain_off = 0.1;
|
||||
rsPrzekladnia->pitch_mul = 0.005;
|
||||
rsPrzekladnia->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
else if( token == "brake:" ){
|
||||
@@ -4707,26 +4739,27 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rsPisk.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rsPisk.AM = parser.getToken<double>();
|
||||
rsPisk.AA = parser.getToken<double>() * ( 105 - Random( 10 ) ) / 100;
|
||||
rsPisk.FM = 1.0;
|
||||
rsPisk.FA = 0.0;
|
||||
rsPisk = sound_man->create_sound(token);
|
||||
if (rsPisk)
|
||||
{
|
||||
rsPisk->dist(attenuation);
|
||||
rsPisk->gain_mul = parser.getToken<double>();
|
||||
rsPisk->gain_off = parser.getToken<double>() * ( 105 - Random( 10 ) ) / 100;
|
||||
rsPisk->pitch_mul = 1.0;
|
||||
rsPisk->pitch_off = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
else if( token == "brakeacc:" ) {
|
||||
// plik z przyspieszaczem (upust po zlapaniu hamowania)
|
||||
// sBrakeAcc.Init(str.c_str(),Parser->GetNextSymbol().ToDouble(),GetPosition().x,GetPosition().y,GetPosition().z,true);
|
||||
parser.getTokens( 1, false ); parser >> token;
|
||||
sBrakeAcc = TSoundsManager::GetFromName( token, true );
|
||||
sBrakeAcc = sound_man->create_sound(token);
|
||||
bBrakeAcc = true;
|
||||
// sBrakeAcc.AM=1.0;
|
||||
// sBrakeAcc.AA=0.0;
|
||||
// sBrakeAcc.FM=1.0;
|
||||
// sBrakeAcc.FA=0.0;
|
||||
// sBrakeAcc->gain_mul=1.0;
|
||||
// sBrakeAcc->gain_off=0.0;
|
||||
// sBrakeAcc->pitch_mul=1.0;
|
||||
// sBrakeAcc->pitch_off=0.0;
|
||||
}
|
||||
|
||||
else if( token == "unbrake:" ) {
|
||||
@@ -4736,14 +4769,9 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rsUnbrake.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rsUnbrake.AM = 1.0;
|
||||
rsUnbrake.AA = 0.0;
|
||||
rsUnbrake.FM = 1.0;
|
||||
rsUnbrake.FA = 0.0;
|
||||
rsUnbrake = sound_man->create_sound(token);
|
||||
if (rsUnbrake)
|
||||
rsUnbrake->dist(attenuation);
|
||||
}
|
||||
|
||||
else if( token == "derail:" ) {
|
||||
@@ -4753,14 +4781,9 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rsDerailment.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rsDerailment.AM = 1.0;
|
||||
rsDerailment.AA = 0.0;
|
||||
rsDerailment.FM = 1.0;
|
||||
rsDerailment.FA = 0.0;
|
||||
rsDerailment = sound_man->create_sound(token);
|
||||
if (rsDerailment)
|
||||
rsDerailment->dist(attenuation);
|
||||
}
|
||||
|
||||
else if( token == "dieselinc:" ) {
|
||||
@@ -4770,14 +4793,9 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rsDiesielInc.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rsDiesielInc.AM = 1.0;
|
||||
rsDiesielInc.AA = 0.0;
|
||||
rsDiesielInc.FM = 1.0;
|
||||
rsDiesielInc.FA = 0.0;
|
||||
rsDiesielInc = sound_man->create_sound(token);
|
||||
if (rsDiesielInc)
|
||||
rsDiesielInc->dist(attenuation);
|
||||
}
|
||||
|
||||
else if( token == "curve:" ) {
|
||||
@@ -4787,24 +4805,19 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
parser
|
||||
>> token
|
||||
>> attenuation;
|
||||
rscurve.Init(
|
||||
token, attenuation,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rscurve.AM = 1.0;
|
||||
rscurve.AA = 0.0;
|
||||
rscurve.FM = 1.0;
|
||||
rscurve.FA = 0.0;
|
||||
rscurve = sound_man->create_sound(token);
|
||||
if (rscurve)
|
||||
rscurve->dist(attenuation);
|
||||
}
|
||||
|
||||
else if( token == "horn1:" ) {
|
||||
// pliki z trabieniem
|
||||
sHorn1.Load( parser, GetPosition() );
|
||||
sHorn1 = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
else if( token == "horn2:" ) {
|
||||
// pliki z trabieniem wysokoton.
|
||||
sHorn2.Load( parser, GetPosition() );
|
||||
sHorn2 = sound_man->create_complex_sound(parser);
|
||||
if( iHornWarning ) {
|
||||
iHornWarning = 2; // numer syreny do użycia po otrzymaniu sygnału do jazdy
|
||||
}
|
||||
@@ -4812,74 +4825,62 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
|
||||
else if( token == "departuresignal:" ) {
|
||||
// pliki z sygnalem odjazdu
|
||||
sDepartureSignal.Load( parser, GetPosition() );
|
||||
sDepartureSignal = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
else if( token == "pantographup:" ) {
|
||||
// pliki dzwiekow pantografow
|
||||
parser.getTokens( 1, false ); parser >> token;
|
||||
sPantUp.Init(
|
||||
token, 50,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
sPantUp = sound_man->create_sound(token);
|
||||
}
|
||||
|
||||
else if( token == "pantographdown:" ) {
|
||||
// pliki dzwiekow pantografow
|
||||
parser.getTokens( 1, false ); parser >> token;
|
||||
sPantDown.Init(
|
||||
token, 50,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
sPantDown = sound_man->create_sound(token);
|
||||
}
|
||||
|
||||
else if( token == "compressor:" ) {
|
||||
// pliki ze sprezarka
|
||||
sCompressor.Load( parser, GetPosition() );
|
||||
sCompressor = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
else if( token == "converter:" ) {
|
||||
// pliki z przetwornica
|
||||
// if (MoverParameters->EngineType==DieselElectric) //będzie modulowany?
|
||||
sConverter.Load( parser, GetPosition() );
|
||||
sConverter = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
else if( token == "turbo:" ) {
|
||||
// pliki z turbogeneratorem
|
||||
sTurbo.Load( parser, GetPosition() );
|
||||
sTurbo = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
else if( token == "small-compressor:" ) {
|
||||
// pliki z przetwornica
|
||||
sSmallCompressor.Load( parser, GetPosition() );
|
||||
sSmallCompressor = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
else if( token == "dooropen:" ) {
|
||||
|
||||
parser.getTokens( 1, false ); parser >> token;
|
||||
rsDoorOpen.Init(
|
||||
token, 50,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rsDoorOpen = sound_man->create_sound(token);
|
||||
}
|
||||
|
||||
else if( token == "doorclose:" ) {
|
||||
|
||||
parser.getTokens( 1, false ); parser >> token;
|
||||
rsDoorClose.Init(
|
||||
token, 50,
|
||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||
true );
|
||||
rsDoorClose = sound_man->create_sound(token);
|
||||
}
|
||||
|
||||
else if( token == "sand:" ) {
|
||||
// pliki z piasecznica
|
||||
sSand.Load( parser, GetPosition() );
|
||||
sSand = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
else if( token == "releaser:" ) {
|
||||
// pliki z odluzniaczem
|
||||
sReleaser.Load( parser, GetPosition() );
|
||||
sReleaser = sound_man->create_complex_sound(parser);
|
||||
}
|
||||
|
||||
} while( ( token != "" )
|
||||
@@ -4917,6 +4918,14 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
} while( ( token != "" )
|
||||
&& ( false == Stop_InternalData ) );
|
||||
|
||||
if (sConverter && rsSilnik)
|
||||
{
|
||||
sConverter->gain_mul = rsSilnik->gain_mul;
|
||||
sConverter->gain_off = rsSilnik->gain_off;
|
||||
sConverter->pitch_mul = rsSilnik->pitch_mul;
|
||||
sConverter->pitch_off = rsSilnik->pitch_off;
|
||||
}
|
||||
|
||||
if( !iAnimations ) {
|
||||
// if the animations weren't defined the model is likely to be non-functional. warrants a warning.
|
||||
ErrorLog( "Animations tag is missing from the .mmd file \"" + asFileName + "\"" );
|
||||
|
||||
56
DynObj.h
56
DynObj.h
@@ -14,11 +14,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "TrkFoll.h"
|
||||
// McZapkie:
|
||||
#include "RealSound.h"
|
||||
#include "AdvSound.h"
|
||||
#include "Button.h"
|
||||
#include "AirCoupler.h"
|
||||
#include "texture.h"
|
||||
#include "Texture.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -308,28 +306,28 @@ public: // modele składowe pojazdu
|
||||
double dRailLength;
|
||||
double dRailPosition[MaxAxles]; // licznik pozycji osi w/m szyny
|
||||
double dWheelsPosition[MaxAxles]; // pozycja osi w/m srodka pojazdu
|
||||
TRealSound rsStukot[MaxAxles]; // dzwieki poszczegolnych osi //McZapkie-270202
|
||||
TRealSound rsSilnik; // McZapkie-010302 - silnik
|
||||
TRealSound rsWentylator; // McZapkie-030302
|
||||
TRealSound rsPisk; // McZapkie-260302
|
||||
TRealSound rsDerailment; // McZapkie-051202
|
||||
TRealSound rsPrzekladnia;
|
||||
TAdvancedSound sHorn1;
|
||||
TAdvancedSound sHorn2;
|
||||
TAdvancedSound sCompressor; // NBMX wrzesien 2003
|
||||
TAdvancedSound sConverter;
|
||||
TAdvancedSound sSmallCompressor;
|
||||
TAdvancedSound sDepartureSignal;
|
||||
TAdvancedSound sTurbo;
|
||||
TAdvancedSound sSand;
|
||||
TAdvancedSound sReleaser;
|
||||
sound* rsStukot[MaxAxles] = { nullptr }; // dzwieki poszczegolnych osi //McZapkie-270202
|
||||
sound* rsSilnik = nullptr; // McZapkie-010302 - silnik
|
||||
sound* rsWentylator = nullptr; // McZapkie-030302
|
||||
sound* rsPisk = nullptr; // McZapkie-260302
|
||||
sound* rsDerailment = nullptr; // McZapkie-051202
|
||||
sound* rsPrzekladnia = nullptr;
|
||||
sound* sHorn1 = nullptr;
|
||||
sound* sHorn2 = nullptr;
|
||||
sound* sCompressor = nullptr; // NBMX wrzesien 2003
|
||||
sound* sConverter = nullptr;
|
||||
sound* sSmallCompressor = nullptr;
|
||||
sound* sDepartureSignal = nullptr;
|
||||
sound* sTurbo = nullptr;
|
||||
sound* sSand = nullptr;
|
||||
sound* sReleaser = nullptr;
|
||||
|
||||
// Winger 010304
|
||||
// TRealSound rsPanTup; //PSound sPantUp;
|
||||
TRealSound sPantUp;
|
||||
TRealSound sPantDown;
|
||||
TRealSound rsDoorOpen; // Ra: przeniesione z kabiny
|
||||
TRealSound rsDoorClose;
|
||||
// sound* rsPanTup; //PSound sPantUp;
|
||||
sound* sPantUp = nullptr;
|
||||
sound* sPantDown = nullptr;
|
||||
sound* rsDoorOpen = nullptr; // Ra: przeniesione z kabiny
|
||||
sound* rsDoorClose = nullptr;
|
||||
|
||||
double eng_vol_act;
|
||||
double eng_frq_act;
|
||||
@@ -340,10 +338,10 @@ public: // modele składowe pojazdu
|
||||
Math3D::vector3 modelShake;
|
||||
|
||||
bool renderme; // yB - czy renderowac
|
||||
// TRealSound sBrakeAcc; //dźwięk przyspieszacza
|
||||
PSound sBrakeAcc;
|
||||
// sound* sBrakeAcc; //dźwięk przyspieszacza
|
||||
sound* sBrakeAcc = nullptr;
|
||||
bool bBrakeAcc;
|
||||
TRealSound rsUnbrake; // yB - odglos luzowania
|
||||
sound* rsUnbrake = nullptr; // yB - odglos luzowania
|
||||
float ModCamRot;
|
||||
int iInventory; // flagi bitowe posiadanych submodeli (np. świateł)
|
||||
void TurnOff();
|
||||
@@ -394,8 +392,8 @@ public: // modele składowe pojazdu
|
||||
return this ? asName : std::string("");
|
||||
};
|
||||
|
||||
TRealSound rsDiesielInc; // youBy
|
||||
TRealSound rscurve; // youBy
|
||||
sound* rsDiesielInc = nullptr; // youBy
|
||||
sound* rscurve = nullptr; // youBy
|
||||
// std::ofstream PneuLogFile; //zapis parametrow pneumatycznych
|
||||
// youBy - dym
|
||||
// TSmoke Smog;
|
||||
@@ -425,7 +423,7 @@ public: // modele składowe pojazdu
|
||||
// poprzedniego
|
||||
TDynamicObject();
|
||||
~TDynamicObject();
|
||||
double TDynamicObject::Init( // zwraca długość pojazdu albo 0, jeśli błąd
|
||||
double Init( // zwraca długość pojazdu albo 0, jeśli błąd
|
||||
std::string Name, std::string BaseDir, std::string asReplacableSkin, std::string Type_Name,
|
||||
TTrack *Track, double fDist, std::string DriverType, double fVel, std::string TrainName,
|
||||
float Load, std::string LoadType, bool Reversed, std::string);
|
||||
|
||||
184
EU07.cpp
184
EU07.cpp
@@ -15,10 +15,10 @@ Authors:
|
||||
MarcinW, McZapkie, Shaxbee, ABu, nbmx, youBy, Ra, winger, mamut, Q424,
|
||||
Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#ifdef CAN_I_HAS_LIBPNG
|
||||
#include <png.h>
|
||||
#endif
|
||||
#include <thread>
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
@@ -28,39 +28,20 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
||||
#include "Console.h"
|
||||
#include "PyInt.h"
|
||||
#include "World.h"
|
||||
#include "Mover.h"
|
||||
#include "MOVER.h"
|
||||
#include "usefull.h"
|
||||
#include "timer.h"
|
||||
#include "Timer.h"
|
||||
#include "resource.h"
|
||||
#include "uilayer.h"
|
||||
|
||||
#ifdef EU07_BUILD_STATIC
|
||||
#pragma comment( lib, "glfw3.lib" )
|
||||
#pragma comment( lib, "glew32s.lib" )
|
||||
#else
|
||||
#ifdef _WINDOWS
|
||||
#pragma comment( lib, "glfw3dll.lib" )
|
||||
#else
|
||||
#pragma comment( lib, "glfw3.lib" )
|
||||
#endif
|
||||
#pragma comment( lib, "glew32.lib" )
|
||||
#endif // build_static
|
||||
#pragma comment( lib, "opengl32.lib" )
|
||||
#pragma comment( lib, "glu32.lib" )
|
||||
#pragma comment( lib, "dsound.lib" )
|
||||
#pragma comment( lib, "winmm.lib" )
|
||||
#pragma comment( lib, "setupapi.lib" )
|
||||
#pragma comment( lib, "python27.lib" )
|
||||
#pragma comment (lib, "glu32.lib")
|
||||
#pragma comment (lib, "dsound.lib")
|
||||
#pragma comment (lib, "winmm.lib")
|
||||
#pragma comment (lib, "setupapi.lib")
|
||||
#pragma comment (lib, "dbghelp.lib")
|
||||
#pragma comment (lib, "version.lib")
|
||||
#ifdef CAN_I_HAS_LIBPNG
|
||||
#pragma comment (lib, "libpng16.lib")
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
|
||||
#endif
|
||||
|
||||
std::unique_ptr<sound_manager> sound_man;
|
||||
TWorld World;
|
||||
|
||||
namespace input {
|
||||
@@ -72,7 +53,6 @@ glm::dvec2 mouse_pickmodepos; // stores last mouse position in control picking
|
||||
|
||||
}
|
||||
|
||||
#ifdef CAN_I_HAS_LIBPNG
|
||||
void screenshot_save_thread( char *img )
|
||||
{
|
||||
png_image png;
|
||||
@@ -90,7 +70,13 @@ void screenshot_save_thread( char *img )
|
||||
strftime(datetime, 64, "%Y-%m-%d_%H-%M-%S", tm_info);
|
||||
|
||||
uint64_t perf;
|
||||
#ifdef _WIN32
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&perf);
|
||||
#elif __linux__
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
perf = ts.tv_nsec;
|
||||
#endif
|
||||
|
||||
std::string filename = "screenshots/" + std::string(datetime) +
|
||||
"_" + std::to_string(perf) + ".png";
|
||||
@@ -111,7 +97,6 @@ void make_screenshot()
|
||||
std::thread t(screenshot_save_thread, img);
|
||||
t.detach();
|
||||
}
|
||||
#endif
|
||||
|
||||
void window_resize_callback(GLFWwindow *window, int w, int h)
|
||||
{
|
||||
@@ -125,12 +110,12 @@ void window_resize_callback(GLFWwindow *window, int w, int h)
|
||||
|
||||
void cursor_pos_callback(GLFWwindow *window, double x, double y)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
input::Mouse.move( x, y );
|
||||
|
||||
if( true == Global::ControlPicking ) {
|
||||
glfwSetCursorPos( window, x, y );
|
||||
}
|
||||
else {
|
||||
if( !Global::ControlPicking ) {
|
||||
glfwSetCursorPos( window, 0, 0 );
|
||||
}
|
||||
}
|
||||
@@ -187,7 +172,6 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
|
||||
|
||||
World.OnKeyDown( key );
|
||||
|
||||
#ifdef CAN_I_HAS_LIBPNG
|
||||
switch( key )
|
||||
{
|
||||
case GLFW_KEY_F11: {
|
||||
@@ -196,7 +180,6 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
|
||||
}
|
||||
default: { break; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,17 +214,8 @@ extern WNDPROC BaseWindowProc;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if defined(_MSC_VER) && defined (_DEBUG)
|
||||
// memory leaks
|
||||
_CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF );
|
||||
// floating point operation errors
|
||||
auto state = _clearfp();
|
||||
state = _control87( 0, 0 );
|
||||
// this will turn on FPE for #IND and zerodiv
|
||||
state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM );
|
||||
#endif
|
||||
#ifdef _WINDOWS
|
||||
::SetUnhandledExceptionFilter( unhandled_handler );
|
||||
::SetUnhandledExceptionFilter(unhandled_handler);
|
||||
#endif
|
||||
|
||||
if (!glfwInit())
|
||||
@@ -250,60 +224,21 @@ int main(int argc, char *argv[])
|
||||
#ifdef _WINDOWS
|
||||
DeleteFile( "log.txt" );
|
||||
DeleteFile( "errors.txt" );
|
||||
_mkdir("logs");
|
||||
CreateDirectory("logs", NULL);
|
||||
#endif
|
||||
Global::LoadIniFile("eu07.ini");
|
||||
Global::InitKeys();
|
||||
|
||||
#ifdef _WIN32
|
||||
// hunter-271211: ukrywanie konsoli
|
||||
if( Global::iWriteLogEnabled & 2 )
|
||||
{
|
||||
AllocConsole();
|
||||
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN );
|
||||
}
|
||||
/*
|
||||
std::string executable( argv[ 0 ] ); auto const pathend = executable.rfind( '\\' );
|
||||
Global::ExecutableName =
|
||||
( pathend != std::string::npos ?
|
||||
executable.substr( executable.rfind( '\\' ) + 1 ) :
|
||||
executable );
|
||||
*/
|
||||
// retrieve product version from the file's version data table
|
||||
{
|
||||
auto const fileversionsize = ::GetFileVersionInfoSize( argv[ 0 ], NULL );
|
||||
std::vector<BYTE>fileversiondata; fileversiondata.resize( fileversionsize );
|
||||
if( ::GetFileVersionInfo( argv[ 0 ], 0, fileversionsize, fileversiondata.data() ) ) {
|
||||
#endif
|
||||
|
||||
struct lang_codepage {
|
||||
WORD language;
|
||||
WORD codepage;
|
||||
} *langcodepage;
|
||||
UINT datasize;
|
||||
|
||||
::VerQueryValue(
|
||||
fileversiondata.data(),
|
||||
TEXT( "\\VarFileInfo\\Translation" ),
|
||||
(LPVOID*)&langcodepage,
|
||||
&datasize );
|
||||
|
||||
std::string subblock; subblock.resize( 50 );
|
||||
::StringCchPrintf(
|
||||
&subblock[0], subblock.size(),
|
||||
TEXT( "\\StringFileInfo\\%04x%04x\\ProductVersion" ),
|
||||
langcodepage->language,
|
||||
langcodepage->codepage );
|
||||
|
||||
VOID *stringdata;
|
||||
if( ::VerQueryValue(
|
||||
fileversiondata.data(),
|
||||
subblock.data(),
|
||||
&stringdata,
|
||||
&datasize ) ) {
|
||||
|
||||
Global::asVersion = std::string( reinterpret_cast<char*>(stringdata) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Global::asVersion = "NG";
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
@@ -346,6 +281,8 @@ int main(int argc, char *argv[])
|
||||
glfwWindowHint(GLFW_REFRESH_RATE, vmode->refreshRate);
|
||||
|
||||
glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
if( Global::iMultisampling > 0 ) {
|
||||
glfwWindowHint( GLFW_SAMPLES, 1 << Global::iMultisampling );
|
||||
}
|
||||
@@ -358,14 +295,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
GLFWwindow *window =
|
||||
glfwCreateWindow(
|
||||
Global::iWindowWidth,
|
||||
Global::iWindowHeight,
|
||||
Global::AppName.c_str(),
|
||||
( Global::bFullScreen ?
|
||||
monitor :
|
||||
nullptr),
|
||||
nullptr );
|
||||
glfwCreateWindow( Global::iWindowWidth, Global::iWindowHeight,
|
||||
Global::AppName.c_str(), Global::bFullScreen ? monitor : nullptr, nullptr );
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -412,40 +343,50 @@ int main(int argc, char *argv[])
|
||||
::SendMessage( Hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>( icon ) );
|
||||
#endif
|
||||
|
||||
if( ( false == GfxRenderer.Init( window ) )
|
||||
|| ( false == UILayer.init( window ) ) ) {
|
||||
try {
|
||||
if ((false == GfxRenderer.Init(window))
|
||||
|| (false == UILayer.init(window)))
|
||||
return -1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
input::Keyboard.init();
|
||||
input::Mouse.init();
|
||||
input::Gamepad.init();
|
||||
sound_man = std::make_unique<sound_manager>();
|
||||
|
||||
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
|
||||
try {
|
||||
if( false == World.Init( window ) ) {
|
||||
input::Keyboard.init();
|
||||
input::Mouse.init();
|
||||
input::Gamepad.init();
|
||||
|
||||
Global::pWorld = &World;
|
||||
if( false == World.Init( window ) ) {
|
||||
ErrorLog( "Simulation setup failed" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch( std::bad_alloc const &Error ) {
|
||||
|
||||
catch( std::bad_alloc const &Error )
|
||||
{
|
||||
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
|
||||
return -1;
|
||||
}
|
||||
catch (std::runtime_error e)
|
||||
{
|
||||
ErrorLog(e.what());
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoś zainicjowac trzeba
|
||||
#endif
|
||||
/*
|
||||
if( !joyGetNumDevs() )
|
||||
WriteLog( "No joystick" );
|
||||
*/
|
||||
if( Global::iConvertModels < 0 ) {
|
||||
Global::iConvertModels = -Global::iConvertModels;
|
||||
World.CreateE3D( "models\\" ); // rekurencyjne przeglądanie katalogów
|
||||
World.CreateE3D( "dynamic\\", true );
|
||||
World.CreateE3D( "models/" ); // rekurencyjne przeglądanie katalogów
|
||||
World.CreateE3D( "dynamic/", true );
|
||||
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
|
||||
|
||||
#ifdef _WIN32
|
||||
Console::On(); // włączenie konsoli
|
||||
#endif
|
||||
|
||||
try {
|
||||
while( ( false == glfwWindowShouldClose( window ) )
|
||||
@@ -456,17 +397,24 @@ int main(int argc, char *argv[])
|
||||
if( true == Global::InputMouse ) { input::Mouse.poll(); }
|
||||
if( true == Global::InputGamepad ) { input::Gamepad.poll(); }
|
||||
}
|
||||
}
|
||||
catch( std::bad_alloc const &Error ) {
|
||||
}
|
||||
catch (std::runtime_error e)
|
||||
{
|
||||
ErrorLog(e.what());
|
||||
return -1;
|
||||
}
|
||||
catch( std::bad_alloc const &Error ) {
|
||||
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
||||
|
||||
TPythonInterpreter::killInstance();
|
||||
|
||||
#ifdef _WIN32
|
||||
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
||||
delete pConsole;
|
||||
#endif
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
|
||||
30
EvLaunch.cpp
30
EvLaunch.cpp
@@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "EvLaunch.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
#include "Event.h"
|
||||
#include "MemCell.h"
|
||||
@@ -53,6 +53,9 @@ int vk_to_glfw_key( int const Keycode ) {
|
||||
|
||||
#ifdef _WINDOWS
|
||||
auto const code = VkKeyScan( Keycode );
|
||||
#else
|
||||
auto const code = (short int)Keycode;
|
||||
#endif
|
||||
char key = code & 0xff;
|
||||
char shiftstate = ( code & 0xff00 ) >> 8;
|
||||
|
||||
@@ -63,7 +66,6 @@ int vk_to_glfw_key( int const Keycode ) {
|
||||
key = GLFW_KEY_0 + key - '0';
|
||||
}
|
||||
return key + ( shiftstate << 8 );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TEventLauncher::Load(cParser *parser)
|
||||
@@ -150,19 +152,17 @@ bool TEventLauncher::Render()
|
||||
bool bCond = false;
|
||||
if (iKey != 0)
|
||||
{
|
||||
if( Global::bActive ) {
|
||||
// tylko jeśli okno jest aktywne
|
||||
if( iKey > 255 ) {
|
||||
// key and modifier
|
||||
auto const modifier = ( iKey & 0xff00 ) >> 8;
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) )
|
||||
&& ( modifier & 1 ? Global::shiftState : true )
|
||||
&& ( modifier & 2 ? Global::ctrlState : true );
|
||||
}
|
||||
else {
|
||||
// just key
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) ); // czy klawisz wciśnięty
|
||||
}
|
||||
// tylko jeśli okno jest aktywne
|
||||
if( iKey > 255 ) {
|
||||
// key and modifier
|
||||
auto const modifier = ( iKey & 0xff00 ) >> 8;
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) )
|
||||
&& ( modifier & 1 ? Global::shiftState : true )
|
||||
&& ( modifier & 2 ? Global::ctrlState : true );
|
||||
}
|
||||
else {
|
||||
// just key
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) ); // czy klawisz wciśnięty
|
||||
}
|
||||
}
|
||||
if (DeltaTime > 0)
|
||||
|
||||
10
Event.cpp
10
Event.cpp
@@ -17,12 +17,12 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Event.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
#include "parser.h"
|
||||
#include "Timer.h"
|
||||
#include "MemCell.h"
|
||||
#include "Ground.h"
|
||||
#include "McZapkie\mctools.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
|
||||
TEvent::TEvent( std::string const &m ) :
|
||||
asNodeName( m )
|
||||
@@ -56,7 +56,7 @@ TEvent::~TEvent()
|
||||
// SafeDeleteArray(Params[9].asText); //nie usuwać - nazwa jest zamieniana na wskaźnik do
|
||||
// submodelu
|
||||
if (Params[0].asInt == 4) // jeśli z pliku VMD
|
||||
delete[] Params[8].asPointer; // zwolnić obszar
|
||||
delete[] (char*)(Params[8].asPointer); // zwolnić obszar
|
||||
case tp_GetValues: // nic
|
||||
break;
|
||||
case tp_PutValues: // params[0].astext stores the token
|
||||
@@ -481,9 +481,9 @@ void TEvent::Load(cParser *parser, vector3 *org)
|
||||
}
|
||||
else if (token.substr(token.length() - 4, 4) == ".vmd") // na razie tu, może będzie inaczej
|
||||
{ // animacja z pliku VMD
|
||||
// TFileStream *fs = new TFileStream( "models\\" + AnsiString( token.c_str() ), fmOpenRead );
|
||||
// TFileStream *fs = new TFileStream( "models/" + AnsiString( token.c_str() ), fmOpenRead );
|
||||
{
|
||||
std::ifstream file( "models\\" + token, std::ios::binary | std::ios::ate ); file.unsetf( std::ios::skipws );
|
||||
std::ifstream file( "models/" + token, std::ios::binary | std::ios::ate ); file.unsetf( std::ios::skipws );
|
||||
auto size = file.tellg(); // ios::ate already positioned us at the end of the file
|
||||
file.seekg( 0, std::ios::beg ); // rewind the caret afterwards
|
||||
Params[ 7 ].asInt = size;
|
||||
|
||||
5
Event.h
5
Event.h
@@ -39,7 +39,8 @@ enum TEventType {
|
||||
tp_Visible,
|
||||
tp_Voltage,
|
||||
tp_Message,
|
||||
tp_Friction
|
||||
tp_Friction,
|
||||
tp_Lua
|
||||
};
|
||||
|
||||
const int update_memstring = 0x0000001; // zmodyfikować tekst (UpdateValues)
|
||||
@@ -72,7 +73,7 @@ union TParam
|
||||
bool asBool;
|
||||
double asdouble;
|
||||
int asInt;
|
||||
TTextSound *tsTextSound;
|
||||
sound *tsTextSound;
|
||||
char *asText;
|
||||
TCommandType asCommand;
|
||||
TTractionPowerSource *psPower;
|
||||
|
||||
@@ -8,7 +8,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "float3d.h"
|
||||
#include "Float3d.h"
|
||||
#include "sn_utils.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -104,11 +104,11 @@ class float4
|
||||
z = c;
|
||||
w = d;
|
||||
};
|
||||
float inline float4::LengthSquared() const
|
||||
float inline LengthSquared() const
|
||||
{
|
||||
return x * x + y * y + z * z + w * w;
|
||||
};
|
||||
float inline float4::Length() const
|
||||
float inline Length() const
|
||||
{
|
||||
return sqrt(x * x + y * y + z * z + w * w);
|
||||
};
|
||||
|
||||
17
Gauge.cpp
17
Gauge.cpp
@@ -18,7 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "parser.h"
|
||||
#include "Model3d.h"
|
||||
#include "Timer.h"
|
||||
#include "logs.h"
|
||||
#include "Logs.h"
|
||||
|
||||
void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset, double fNewFriction, double fNewValue)
|
||||
{ // ustawienie parametrów animacji submodelu
|
||||
@@ -128,13 +128,13 @@ TGauge::Load_mapping( cParser &Input ) {
|
||||
if( key == "soundinc:" ) {
|
||||
m_soundfxincrease = (
|
||||
value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
sound_man->create_sound(value) :
|
||||
nullptr );
|
||||
}
|
||||
else if( key == "sounddec:" ) {
|
||||
m_soundfxdecrease = (
|
||||
value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
sound_man->create_sound(value) :
|
||||
nullptr );
|
||||
}
|
||||
else if( key.find( "sound" ) == 0 ) {
|
||||
@@ -145,7 +145,7 @@ TGauge::Load_mapping( cParser &Input ) {
|
||||
m_soundfxvalues.emplace(
|
||||
std::stoi( key.substr( indexstart, indexend - indexstart ) ),
|
||||
( value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
sound_man->create_sound(value) :
|
||||
nullptr ) );
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void TGauge::DecValue(double fNewDesired)
|
||||
|
||||
// ustawienie wartości docelowej. plays provided fallback sound, if no sound was defined in the control itself
|
||||
void
|
||||
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
|
||||
TGauge::UpdateValue( double fNewDesired, sound* Fallbacksound ) {
|
||||
|
||||
auto const desiredtimes100 = static_cast<int>( std::round( 100.0 * fNewDesired ) );
|
||||
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == desiredtimes100 ) {
|
||||
@@ -316,13 +316,12 @@ void TGauge::UpdateValue()
|
||||
};
|
||||
|
||||
void
|
||||
TGauge::play( PSound Sound ) {
|
||||
TGauge::play( sound *Sound ) {
|
||||
|
||||
if( Sound == nullptr ) { return; }
|
||||
|
||||
Sound->SetCurrentPosition( 0 );
|
||||
Sound->SetVolume( DSBVOLUME_MAX );
|
||||
Sound->Play( 0, 0, 0 );
|
||||
Sound->stop();
|
||||
Sound->play();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
10
Gauge.h
10
Gauge.h
@@ -39,16 +39,16 @@ class TGauge {
|
||||
double *dData { nullptr };
|
||||
int *iData;
|
||||
};
|
||||
PSound m_soundfxincrease { nullptr }; // sound associated with increasing control's value
|
||||
PSound m_soundfxdecrease { nullptr }; // sound associated with decreasing control's value
|
||||
std::map<int, PSound> m_soundfxvalues; // sounds associated with specific values
|
||||
sound *m_soundfxincrease { nullptr }; // sound associated with increasing control's value
|
||||
sound *m_soundfxdecrease { nullptr }; // sound associated with decreasing control's value
|
||||
std::map<int, sound*> m_soundfxvalues; // sounds associated with specific values
|
||||
// methods
|
||||
// imports member data pair from the config file
|
||||
bool
|
||||
Load_mapping( cParser &Input );
|
||||
// plays specified sound
|
||||
void
|
||||
play( PSound Sound );
|
||||
play( sound* Sound );
|
||||
|
||||
public:
|
||||
TGauge() = default;
|
||||
@@ -59,7 +59,7 @@ class TGauge {
|
||||
void PermIncValue(double fNewDesired);
|
||||
void IncValue(double fNewDesired);
|
||||
void DecValue(double fNewDesired);
|
||||
void UpdateValue(double fNewDesired, PSound Fallbacksound = nullptr );
|
||||
void UpdateValue(double fNewDesired, sound *Fallbacksound = nullptr );
|
||||
void PutValue(double fNewDesired);
|
||||
double GetValue() const;
|
||||
void Update();
|
||||
|
||||
81
Globals.cpp
81
Globals.cpp
@@ -46,7 +46,7 @@ GLFWwindow *Global::window;
|
||||
bool Global::shiftState;
|
||||
bool Global::ctrlState;
|
||||
int Global::iCameraLast = -1;
|
||||
std::string Global::asVersion = "couldn't retrieve version string";
|
||||
std::string Global::asVersion = "UNKNOWN";
|
||||
bool Global::ControlPicking = false; // indicates controls pick mode is enabled
|
||||
bool Global::InputMouse = true; // whether control pick mode can be activated
|
||||
int Global::iTextMode = 0; // tryb pracy wyświetlacza tekstowego
|
||||
@@ -62,7 +62,7 @@ cParser *Global::pParser = NULL;
|
||||
TCamera *Global::pCamera = NULL; // parametry kamery
|
||||
TDynamicObject *Global::pUserDynamic = NULL; // pojazd użytkownika, renderowany bez trzęsienia
|
||||
TTranscripts Global::tranTexts; // obiekt obsługujący stenogramy dźwięków na ekranie
|
||||
float4 Global::UITextColor = float4( 225.0 / 255.0f, 225.0f / 255.0f, 225.0f / 255.0f, 1.0f );
|
||||
float4 Global::UITextColor = float4( 225.0f / 255.0f, 225.0f / 255.0f, 225.0f / 255.0f, 1.0f );
|
||||
|
||||
// parametry scenerii
|
||||
vector3 Global::pCameraPosition;
|
||||
@@ -74,13 +74,12 @@ std::vector<vector3> Global::FreeCameraInitAngle;
|
||||
GLfloat Global::FogColor[] = {0.6f, 0.7f, 0.8f};
|
||||
double Global::fFogStart = 1700;
|
||||
double Global::fFogEnd = 2000;
|
||||
float Global::Overcast { 0.1f }; // NOTE: all this weather stuff should be moved elsewhere
|
||||
float Global::Overcast{ 0.1f }; // NOTE: all this weather stuff should be moved elsewhere
|
||||
int Global::DynamicLightCount = 7;
|
||||
bool Global::ScaleSpecularValues = false;
|
||||
float Global::BaseDrawRange { 2500.f };
|
||||
opengl_light Global::DayLight;
|
||||
int Global::DynamicLightCount { 3 };
|
||||
bool Global::ScaleSpecularValues { true };
|
||||
bool Global::RenderShadows { false };
|
||||
bool Global::BasicRenderer { false };
|
||||
bool Global::RenderShadows { true };
|
||||
Global::shadowtune_t Global::shadowtune = { 2048, 250.f, 250.f, 500.f };
|
||||
bool Global::bRollFix = true; // czy wykonać przeliczanie przechyłki
|
||||
bool Global::bJoinEvents = false; // czy grupować eventy o tych samych nazwach
|
||||
@@ -117,7 +116,6 @@ bool Global::bEnableTraction = true;
|
||||
bool Global::bLoadTraction = true;
|
||||
bool Global::bLiveTraction = true;
|
||||
float Global::AnisotropicFiltering = 8.0f; // requested level of anisotropic filtering. TODO: move it to renderer object
|
||||
bool Global::bUseVBO = true; // czy jest VBO w karcie graficznej (czy użyć)
|
||||
std::string Global::LastGLError;
|
||||
GLint Global::iMaxTextureSize = 4096; // maksymalny rozmiar tekstury
|
||||
bool Global::bSmoothTraction = false; // wygładzanie drutów starym sposobem
|
||||
@@ -187,6 +185,11 @@ double Global::fMWDamp[2] = { 800, 1023 };
|
||||
double Global::fMWDlowVolt[2] = { 150, 1023 };
|
||||
int Global::iMWDdivider = 5;
|
||||
|
||||
opengl_light Global::DayLight;
|
||||
Global::soundmode_t Global::soundpitchmode = Global::linear;
|
||||
Global::soundmode_t Global::soundgainmode = Global::linear;
|
||||
Global::soundstopmode_t Global::soundstopmode = Global::queue;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -414,12 +417,6 @@ void Global::ConfigParse(cParser &Parser)
|
||||
Parser.getTokens( 1, false );
|
||||
Parser >> Global::AnisotropicFiltering;
|
||||
}
|
||||
else if( token == "usevbo" )
|
||||
{
|
||||
|
||||
Parser.getTokens();
|
||||
Parser >> Global::bUseVBO;
|
||||
}
|
||||
else if (token == "feedbackmode")
|
||||
{
|
||||
|
||||
@@ -499,6 +496,37 @@ void Global::ConfigParse(cParser &Parser)
|
||||
>> Global::shadowtune.depth
|
||||
>> Global::shadowtune.distance;
|
||||
}
|
||||
else if (token == "soundgainmode")
|
||||
{
|
||||
Parser.getTokens();
|
||||
Parser >> token;
|
||||
if (token == "linear")
|
||||
Global::soundgainmode = Global::linear;
|
||||
else if (token == "scaled")
|
||||
Global::soundgainmode = Global::scaled;
|
||||
else if (token == "compat")
|
||||
Global::soundgainmode = Global::compat;
|
||||
}
|
||||
else if (token == "soundstopmode")
|
||||
{
|
||||
Parser.getTokens();
|
||||
Parser >> token;
|
||||
if (token == "queue")
|
||||
Global::soundstopmode = Global::queue;
|
||||
else if (token == "playstop")
|
||||
Global::soundstopmode = Global::playstop;
|
||||
else if (token == "stop")
|
||||
Global::soundstopmode = Global::stop;
|
||||
}
|
||||
else if (token == "soundpitchmode")
|
||||
{
|
||||
Parser.getTokens();
|
||||
Parser >> token;
|
||||
if (token == "linear")
|
||||
Global::soundpitchmode = Global::linear;
|
||||
else if (token == "compat")
|
||||
Global::soundpitchmode = Global::compat;
|
||||
}
|
||||
else if (token == "smoothtraction")
|
||||
{
|
||||
// podwójna jasność ambient
|
||||
@@ -723,13 +751,6 @@ void Global::ConfigParse(cParser &Parser)
|
||||
Global::UITextColor = Global::UITextColor / 255.0f;
|
||||
Global::UITextColor.w = 1.0f;
|
||||
}
|
||||
else if (token == "pyscreenrendererpriority")
|
||||
{
|
||||
// priority of python screen renderer
|
||||
Parser.getTokens();
|
||||
Parser >> token;
|
||||
TPythonInterpreter::getInstance()->setScreenRendererPriority(token.c_str());
|
||||
}
|
||||
else if( token == "input.gamepad" ) {
|
||||
// czy grupować eventy o tych samych nazwach
|
||||
Parser.getTokens();
|
||||
@@ -860,7 +881,9 @@ void Global::ConfigParse(cParser &Parser)
|
||||
// TBD: remove, or launch depending on passed flag?
|
||||
if (qp)
|
||||
{ // to poniżej wykonywane tylko raz, jedynie po wczytaniu eu07.ini*/
|
||||
Console::ModeSet(iFeedbackMode, iFeedbackPort); // tryb pracy konsoli sterowniczej
|
||||
#ifdef _WIN32
|
||||
Console::ModeSet(iFeedbackMode, iFeedbackPort); // tryb pracy konsoli sterowniczej
|
||||
#endif
|
||||
/*iFpsRadiusMax = 0.000025 * fFpsRadiusMax *
|
||||
fFpsRadiusMax; // maksymalny promień renderowania 3000.0 -> 225
|
||||
if (iFpsRadiusMax > 400)
|
||||
@@ -1012,20 +1035,6 @@ bool Global::AddToQuery(TEvent *event, TDynamicObject *who)
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool Global::DoEvents()
|
||||
{ // wywoływać czasem, żeby nie robił wrażenia zawieszonego
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_QUIT)
|
||||
return FALSE;
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
TTranscripts::TTranscripts()
|
||||
{
|
||||
/*
|
||||
|
||||
39
Globals.h
39
Globals.h
@@ -10,10 +10,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
//#include <Windows.h>
|
||||
#include "renderer.h"
|
||||
#include "glfw/glfw3.h"
|
||||
#include "gl/glew.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <GL/glew.h>
|
||||
#include "dumb3d.h"
|
||||
|
||||
// definicje klawiszy
|
||||
@@ -121,7 +121,7 @@ class TDynamicObject;
|
||||
class TAnimModel; // obiekt terenu
|
||||
class cParser; // nowy (powolny!) parser
|
||||
class TEvent;
|
||||
class TTextSound;
|
||||
class sound;
|
||||
|
||||
class TTranscript
|
||||
{ // klasa obsługująca linijkę napisu do dźwięku
|
||||
@@ -177,8 +177,8 @@ class Global
|
||||
static bool bLoadTraction;
|
||||
static float fFriction;
|
||||
static bool bLiveTraction;
|
||||
static float Global::fMouseXScale;
|
||||
static float Global::fMouseYScale;
|
||||
static float fMouseXScale;
|
||||
static float fMouseYScale;
|
||||
static double fFogStart;
|
||||
static double fFogEnd;
|
||||
static TGround *pGround;
|
||||
@@ -203,7 +203,6 @@ class Global
|
||||
|
||||
// TODO: put these things in the renderer
|
||||
static float BaseDrawRange;
|
||||
static opengl_light DayLight;
|
||||
static int DynamicLightCount;
|
||||
static bool ScaleSpecularValues;
|
||||
static bool BasicRenderer;
|
||||
@@ -259,7 +258,8 @@ class Global
|
||||
static bool DLFont; // switch indicating presence of basic font
|
||||
static bool bGlutFont; // tekst generowany przez GLUT
|
||||
static int iPause; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie
|
||||
static bool bActive; // czy jest aktywnym oknem
|
||||
static bool bActive;
|
||||
|
||||
static int iConvertModels; // tworzenie plików binarnych
|
||||
static bool bInactivePause; // automatyczna pauza, gdy okno nieaktywne
|
||||
static int iSlowMotionMask; // maska wyłączanych właściwości
|
||||
@@ -287,7 +287,7 @@ class Global
|
||||
static float4 UITextColor; // base color of UI text
|
||||
static std::string asLang; // domyślny język - http://tools.ietf.org/html/bcp47
|
||||
static int iHiddenEvents; // czy łączyć eventy z torami poprzez nazwę toru
|
||||
static TTextSound *tsRadioBusy[10]; // zajętość kanałów radiowych (wskaźnik na odgrywany dźwięk)
|
||||
static sound *tsRadioBusy[10]; // zajętość kanałów radiowych (wskaźnik na odgrywany dźwięk)
|
||||
static int iPoKeysPWM[7]; // numery wejść dla PWM
|
||||
|
||||
//randomizacja
|
||||
@@ -300,7 +300,6 @@ class Global
|
||||
static TDynamicObject * DynamicNearest();
|
||||
static TDynamicObject * CouplerNearest();
|
||||
static bool AddToQuery(TEvent *event, TDynamicObject *who);
|
||||
static bool DoEvents();
|
||||
static std::string Bezogonkow(std::string str, bool _ = false);
|
||||
static double Min0RSpeed(double vel1, double vel2);
|
||||
|
||||
@@ -320,5 +319,25 @@ class Global
|
||||
static double fMWDamp[2];
|
||||
static double fMWDlowVolt[2];
|
||||
static int iMWDdivider;
|
||||
|
||||
static opengl_light DayLight;
|
||||
|
||||
enum soundmode_t
|
||||
{
|
||||
linear,
|
||||
scaled,
|
||||
compat,
|
||||
};
|
||||
|
||||
enum soundstopmode_t
|
||||
{
|
||||
queue,
|
||||
playstop,
|
||||
stop
|
||||
};
|
||||
|
||||
static soundmode_t soundpitchmode;
|
||||
static soundmode_t soundgainmode;
|
||||
static soundstopmode_t soundstopmode;
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
212
Ground.cpp
212
Ground.cpp
@@ -26,7 +26,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "TractionPower.h"
|
||||
#include "Traction.h"
|
||||
#include "Track.h"
|
||||
#include "RealSound.h"
|
||||
#include "AnimModel.h"
|
||||
#include "MemCell.h"
|
||||
#include "mtable.h"
|
||||
@@ -36,15 +35,18 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Driver.h"
|
||||
#include "Console.h"
|
||||
#include "Names.h"
|
||||
#include "world.h"
|
||||
#include "World.h"
|
||||
#include "uilayer.h"
|
||||
#include "sound.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifdef _WIN32
|
||||
extern "C"
|
||||
{
|
||||
GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound
|
||||
GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window );
|
||||
}
|
||||
#endif
|
||||
|
||||
bool bCondition; // McZapkie: do testowania warunku na event multiple
|
||||
std::string LogComment;
|
||||
@@ -185,13 +187,6 @@ void TGroundNode::RenderHidden()
|
||||
double mgn = SquareMagnitude(pCenter - Global::pCameraPosition);
|
||||
switch (iType)
|
||||
{
|
||||
case TP_SOUND: // McZapkie - dzwiek zapetlony w zaleznosci od odleglosci
|
||||
if ((tsStaticSound->GetStatus() & DSBSTATUS_PLAYING) == DSBPLAY_LOOPING)
|
||||
{
|
||||
tsStaticSound->Play(1, DSBPLAY_LOOPING, true, tsStaticSound->vSoundPosition);
|
||||
tsStaticSound->AdjFreq(1.0, Timer::GetDeltaTime());
|
||||
}
|
||||
return;
|
||||
case TP_EVLAUNCH:
|
||||
if (EvLaunch->Render())
|
||||
if ((EvLaunch->dRadius < 0) || (mgn < EvLaunch->dRadius))
|
||||
@@ -407,7 +402,8 @@ void TSubRect::LoadNodes() {
|
||||
vertex.texture );
|
||||
}
|
||||
node->Piece->geometry = GfxRenderer.Insert( vertices, m_geometrybank, node->iType );
|
||||
node->Piece->vertices.swap( std::vector<TGroundVertex>() ); // hipster shrink_to_fit
|
||||
node->Piece->vertices.clear();
|
||||
node->Piece->vertices.shrink_to_fit();
|
||||
// TODO: get rid of the vertex counters, they're obsolete at this point
|
||||
if( node->iType == GL_LINES ) { node->iNumVerts = 0; }
|
||||
else { node->iNumPts = 0; }
|
||||
@@ -458,7 +454,7 @@ TGroundRect::Init() {
|
||||
- glm::vec3( 500.0f, 0.0f, 500.0f ) // 'upper left' corner of rectangle
|
||||
+ glm::vec3( subrectsize * 0.5f, 0.0f, subrectsize * 0.5f ) // center of sub-rectangle
|
||||
+ glm::vec3( subrectsize * column, 0.0f, subrectsize * row );
|
||||
area.radius = subrectsize * M_SQRT2;
|
||||
area.radius = subrectsize * (float)M_SQRT2;
|
||||
// all subcells share the same geometry bank with their parent, to reduce buffer switching during render
|
||||
subcell->m_geometrybank = m_geometrybank;
|
||||
}
|
||||
@@ -528,7 +524,7 @@ TGround::TGround()
|
||||
for( int i = 0; i < TP_LAST; ++i ) {
|
||||
nRootOfType[ i ] = nullptr; // zerowanie tablic wyszukiwania
|
||||
}
|
||||
::SecureZeroMemory( TempConnectionType, sizeof( TempConnectionType ) );
|
||||
memset(TempConnectionType, 0, sizeof(TempConnectionType));
|
||||
// set bounding area information for ground rectangles
|
||||
float const rectsize = 1000.0f;
|
||||
glm::vec3 const worldcenter;
|
||||
@@ -536,7 +532,7 @@ TGround::TGround()
|
||||
for( int row = 0; row < iNumRects; ++row ) {
|
||||
auto &area = Rects[ column ][ row ].m_area;
|
||||
// NOTE: in current implementation triangles can stick out to ~200m from the area, so we add extra padding
|
||||
area.radius = ( rectsize * 0.5f * M_SQRT2 ) + 200.0f;
|
||||
area.radius = ( rectsize * 0.5f * (float)M_SQRT2 ) + 200.0f;
|
||||
area.center =
|
||||
worldcenter
|
||||
- glm::vec3( (iNumRects / 2) * rectsize, 0.0f, (iNumRects / 2) * rectsize ) // 'upper left' corner of the world
|
||||
@@ -1062,8 +1058,11 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
parser->getTokens();
|
||||
*parser >> token;
|
||||
str = token;
|
||||
//str = AnsiString(token.c_str());
|
||||
tmp->tsStaticSound = new TTextSound(str, sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->pCenter.y, tmp->pCenter.z, false, false, rmin);
|
||||
|
||||
tmp->tsStaticSound = sound_man->create_text_sound(str);
|
||||
if (tmp->tsStaticSound)
|
||||
tmp->tsStaticSound->position(tmp->pCenter).dist(sqrt(tmp->fSquareRadius));
|
||||
|
||||
if (rmin < 0.0)
|
||||
rmin = 0.0; // przywrócenie poprawnej wartości, jeśli służyła do wyłączenia efektu Dopplera
|
||||
parser->getTokens();
|
||||
@@ -1604,7 +1603,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
}
|
||||
tmp->iType = GL_LINES;
|
||||
tmp->Piece = new piece_node();
|
||||
tmp->iNumPts = importedvertices.size();
|
||||
tmp->iNumPts = (int)importedvertices.size();
|
||||
|
||||
if( false == importedvertices.empty() ) {
|
||||
|
||||
@@ -1762,6 +1761,72 @@ void TGround::FirstInit()
|
||||
WriteLog("FirstInit is done");
|
||||
};
|
||||
|
||||
void TGround::add_event(TEvent *tmp)
|
||||
{
|
||||
if (tmp->Type == tp_Unknown)
|
||||
delete tmp;
|
||||
else
|
||||
{ // najpierw sprawdzamy, czy nie ma, a potem dopisujemy
|
||||
TEvent *found = FindEvent(tmp->asName);
|
||||
if (found)
|
||||
{ // jeśli znaleziony duplikat
|
||||
auto const size = tmp->asName.size();
|
||||
if( tmp->asName[0] == '#' ) // zawsze jeden znak co najmniej jest
|
||||
{
|
||||
delete tmp;
|
||||
tmp = nullptr;
|
||||
} // utylizacja duplikatu z krzyżykiem
|
||||
else if( ( size > 8 )
|
||||
&& ( tmp->asName.substr( 0, 9 ) == "lineinfo:" ))
|
||||
// tymczasowo wyjątki
|
||||
{
|
||||
delete tmp;
|
||||
tmp = nullptr;
|
||||
} // tymczasowa utylizacja duplikatów W5
|
||||
else if( ( size > 8 )
|
||||
&& ( tmp->asName.substr( size - 8 ) == "_warning"))
|
||||
// tymczasowo wyjątki
|
||||
{
|
||||
delete tmp;
|
||||
tmp = nullptr;
|
||||
} // tymczasowa utylizacja duplikatu z trąbieniem
|
||||
else if( ( size > 4 )
|
||||
&& ( tmp->asName.substr( size - 4 ) == "_shp" ))
|
||||
// nie podlegają logowaniu
|
||||
{
|
||||
delete tmp;
|
||||
tmp = NULL;
|
||||
} // tymczasowa utylizacja duplikatu SHP
|
||||
if (tmp) // jeśli nie został zutylizowany
|
||||
if (Global::bJoinEvents)
|
||||
found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków)
|
||||
else
|
||||
{
|
||||
ErrorLog("Duplicated event: " + tmp->asName);
|
||||
found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków)
|
||||
found->Type = tp_Ignored; // dezaktywacja pierwotnego - taka proteza na
|
||||
// wsteczną zgodność
|
||||
// SafeDelete(tmp); //bezlitośnie usuwamy wszelkie duplikaty, żeby nie
|
||||
// zaśmiecać drzewka
|
||||
}
|
||||
}
|
||||
if ( nullptr != tmp )
|
||||
{ // jeśli nie duplikat
|
||||
tmp->evNext2 = RootEvent; // lista wszystkich eventów (m.in. do InitEvents)
|
||||
RootEvent = tmp;
|
||||
if (!found)
|
||||
{ // jeśli nazwa wystąpiła, to do kolejki i wyszukiwarki dodawany jest tylko pierwszy
|
||||
if( ( RootEvent->Type != tp_Ignored )
|
||||
&& ( RootEvent->asName.find( "onstart" ) != std::string::npos ) ) {
|
||||
// event uruchamiany automatycznie po starcie
|
||||
AddToQuery( RootEvent, NULL ); // dodanie do kolejki
|
||||
}
|
||||
m_eventmap.emplace( tmp->asName, tmp ); // dodanie do wyszukiwarki
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TGround::Init(std::string File)
|
||||
{ // główne wczytywanie scenerii
|
||||
if (ToLower(File).substr(0, 7) == "scenery")
|
||||
@@ -1921,68 +1986,14 @@ bool TGround::Init(std::string File)
|
||||
{
|
||||
TEvent *tmp = new TEvent();
|
||||
tmp->Load(&parser, &pOrigin);
|
||||
if (tmp->Type == tp_Unknown)
|
||||
delete tmp;
|
||||
else
|
||||
{ // najpierw sprawdzamy, czy nie ma, a potem dopisujemy
|
||||
TEvent *found = FindEvent(tmp->asName);
|
||||
if (found)
|
||||
{ // jeśli znaleziony duplikat
|
||||
auto const size = tmp->asName.size();
|
||||
if( tmp->asName[0] == '#' ) // zawsze jeden znak co najmniej jest
|
||||
{
|
||||
delete tmp;
|
||||
tmp = nullptr;
|
||||
} // utylizacja duplikatu z krzyżykiem
|
||||
else if( ( size > 8 )
|
||||
&& ( tmp->asName.substr( 0, 9 ) == "lineinfo:" ))
|
||||
// tymczasowo wyjątki
|
||||
{
|
||||
delete tmp;
|
||||
tmp = nullptr;
|
||||
} // tymczasowa utylizacja duplikatów W5
|
||||
else if( ( size > 8 )
|
||||
&& ( tmp->asName.substr( size - 8 ) == "_warning"))
|
||||
// tymczasowo wyjątki
|
||||
{
|
||||
delete tmp;
|
||||
tmp = nullptr;
|
||||
} // tymczasowa utylizacja duplikatu z trąbieniem
|
||||
else if( ( size > 4 )
|
||||
&& ( tmp->asName.substr( size - 4 ) == "_shp" ))
|
||||
// nie podlegają logowaniu
|
||||
{
|
||||
delete tmp;
|
||||
tmp = NULL;
|
||||
} // tymczasowa utylizacja duplikatu SHP
|
||||
if (tmp) // jeśli nie został zutylizowany
|
||||
if (Global::bJoinEvents)
|
||||
found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków)
|
||||
else
|
||||
{
|
||||
ErrorLog("Duplicated event: " + tmp->asName);
|
||||
found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków)
|
||||
found->Type = tp_Ignored; // dezaktywacja pierwotnego - taka proteza na
|
||||
// wsteczną zgodność
|
||||
// SafeDelete(tmp); //bezlitośnie usuwamy wszelkie duplikaty, żeby nie
|
||||
// zaśmiecać drzewka
|
||||
}
|
||||
}
|
||||
if ( nullptr != tmp )
|
||||
{ // jeśli nie duplikat
|
||||
tmp->evNext2 = RootEvent; // lista wszystkich eventów (m.in. do InitEvents)
|
||||
RootEvent = tmp;
|
||||
if (!found)
|
||||
{ // jeśli nazwa wystąpiła, to do kolejki i wyszukiwarki dodawany jest tylko pierwszy
|
||||
if( ( RootEvent->Type != tp_Ignored )
|
||||
&& ( RootEvent->asName.find( "onstart" ) != std::string::npos ) ) {
|
||||
// event uruchamiany automatycznie po starcie
|
||||
AddToQuery( RootEvent, NULL ); // dodanie do kolejki
|
||||
}
|
||||
m_eventmap.emplace( tmp->asName, tmp ); // dodanie do wyszukiwarki
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event(tmp);
|
||||
}
|
||||
else if (str == "lua")
|
||||
{
|
||||
parser.getTokens();
|
||||
std::string file;
|
||||
parser >> file;
|
||||
m_lua.interpret(subpath + file);
|
||||
}
|
||||
else if (str == "rotate")
|
||||
{
|
||||
@@ -2080,10 +2091,10 @@ bool TGround::Init(std::string File)
|
||||
WriteLog("Scenery light definition");
|
||||
parser.getTokens(3, false);
|
||||
parser
|
||||
>> Global::DayLight.direction.x
|
||||
>> Global::DayLight.direction.y
|
||||
>> Global::DayLight.direction.z;;
|
||||
Global::DayLight.direction = glm::normalize( Global::DayLight.direction );
|
||||
>> Global::DayLight.direction.x
|
||||
>> Global::DayLight.direction.y
|
||||
>> Global::DayLight.direction.z;
|
||||
Global::DayLight.direction = glm::normalize(Global::DayLight.direction);
|
||||
parser.getTokens(9, false);
|
||||
|
||||
do {
|
||||
@@ -2900,7 +2911,7 @@ bool TGround::InitLaunchers()
|
||||
if (tmp)
|
||||
EventLauncher->MemCell = tmp->MemCell; // jeśli znaleziona, dopisać
|
||||
else
|
||||
MessageBox(0, "Cannot find Memory Cell for Event Launcher", "Error", MB_OK);
|
||||
WriteLog("Cannot find Memory Cell for Event Launcher");
|
||||
}
|
||||
else
|
||||
EventLauncher->MemCell = NULL;
|
||||
@@ -3289,22 +3300,20 @@ bool TGround::CheckQuery()
|
||||
Error("Not implemented yet :(");
|
||||
break;
|
||||
case tp_Exit:
|
||||
MessageBox(0, tmpEvent->asNodeName.c_str(), " THE END ", MB_OK);
|
||||
WriteLog(tmpEvent->asNodeName.c_str());
|
||||
Global::iTextMode = -1; // wyłączenie takie samo jak sekwencja F10 -> Y
|
||||
return false;
|
||||
case tp_Sound:
|
||||
switch (tmpEvent->Params[0].asInt)
|
||||
{ // trzy możliwe przypadki:
|
||||
case 0:
|
||||
tmpEvent->Params[9].tsTextSound->Stop();
|
||||
tmpEvent->Params[9].tsTextSound->stop();
|
||||
break;
|
||||
case 1:
|
||||
tmpEvent->Params[9].tsTextSound->Play(
|
||||
1, 0, true, tmpEvent->Params[9].tsTextSound->vSoundPosition);
|
||||
tmpEvent->Params[9].tsTextSound->play();
|
||||
break;
|
||||
case -1:
|
||||
tmpEvent->Params[9].tsTextSound->Play(
|
||||
1, DSBPLAY_LOOPING, true, tmpEvent->Params[9].tsTextSound->vSoundPosition);
|
||||
tmpEvent->Params[9].tsTextSound->play();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -3483,6 +3492,9 @@ bool TGround::CheckQuery()
|
||||
break;
|
||||
case tp_Message: // wyświetlenie komunikatu
|
||||
break;
|
||||
case tp_Lua:
|
||||
((lua::eventhandler_t)tmpEvent->Params[0].asPointer)(tmpEvent, tmpEvent->Activator);
|
||||
break;
|
||||
} // switch (tmpEvent->Type)
|
||||
} // if (tmpEvent->bEnabled)
|
||||
} // while
|
||||
@@ -3829,7 +3841,7 @@ bool TGround::GetTraction(TDynamicObject *model)
|
||||
return true;
|
||||
};
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#ifdef _WIN32
|
||||
//---------------------------------------------------------------------------
|
||||
void TGround::Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{ // wysłanie komunikatu do sterującego
|
||||
@@ -3838,9 +3850,11 @@ void TGround::Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LP
|
||||
h = FindWindow(0, ClassName.c_str()); // można by to zapamiętać
|
||||
SendMessage(h, Msg, wParam, lParam);
|
||||
};
|
||||
#endif
|
||||
//--------------------------------
|
||||
void TGround::WyslijEvent(const std::string &e, const std::string &d)
|
||||
{ // Ra: jeszcze do wyczyszczenia
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' );
|
||||
r.iComm = 2; // 2 - event
|
||||
@@ -3855,10 +3869,12 @@ void TGround::WyslijEvent(const std::string &e, const std::string &d)
|
||||
cData.lpData = &r;
|
||||
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + e + " sent" );
|
||||
#endif
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
void TGround::WyslijUszkodzenia(const std::string &t, char fl)
|
||||
{ // wysłanie informacji w postaci pojedynczego tekstu
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' );
|
||||
r.iComm = 13; // numer komunikatu
|
||||
@@ -3872,10 +3888,12 @@ void TGround::WyslijUszkodzenia(const std::string &t, char fl)
|
||||
cData.lpData = &r;
|
||||
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent");
|
||||
#endif
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
void TGround::WyslijString(const std::string &t, int n)
|
||||
{ // wysłanie informacji w postaci pojedynczego tekstu
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' );
|
||||
r.iComm = n; // numer komunikatu
|
||||
@@ -3888,15 +3906,19 @@ void TGround::WyslijString(const std::string &t, int n)
|
||||
cData.lpData = &r;
|
||||
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent");
|
||||
#endif
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
void TGround::WyslijWolny(const std::string &t)
|
||||
{ // Ra: jeszcze do wyczyszczenia
|
||||
#ifdef _WIN32
|
||||
WyslijString(t, 4); // tor wolny
|
||||
#endif
|
||||
};
|
||||
//--------------------------------
|
||||
void TGround::WyslijNamiary(TGroundNode *t)
|
||||
{ // wysłanie informacji o pojeździe - (float), długość ramki będzie zwiększana w miarę potrzeby
|
||||
#ifdef _WIN32
|
||||
// WriteLog("Wysylam pojazd");
|
||||
DaneRozkaz r;
|
||||
r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' );
|
||||
@@ -3969,10 +3991,12 @@ void TGround::WyslijNamiary(TGroundNode *t)
|
||||
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||
// WriteLog("Ramka poszla!");
|
||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t->asName + " sent");
|
||||
#endif
|
||||
};
|
||||
//
|
||||
void TGround::WyslijObsadzone()
|
||||
{ // wysłanie informacji o pojeździe
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz2 r;
|
||||
r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' );
|
||||
r.iComm = 12; // kod 12
|
||||
@@ -4011,11 +4035,13 @@ void TGround::WyslijObsadzone()
|
||||
// WriteLog("Ramka gotowa");
|
||||
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||
CommLog( Now() + " " + std::to_string(r.iComm) + " obsadzone" + " sent");
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
void TGround::WyslijParam(int nr, int fl)
|
||||
{ // wysłanie parametrów symulacji w ramce (nr) z flagami (fl)
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' );
|
||||
r.iComm = nr; // zwykle 5
|
||||
@@ -4034,8 +4060,8 @@ void TGround::WyslijParam(int nr, int fl)
|
||||
cData.cbData = 12 + i; // 12+rozmiar danych
|
||||
cData.lpData = &r;
|
||||
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -4227,7 +4253,7 @@ void TGround::TerrainWrite()
|
||||
break;
|
||||
}
|
||||
}
|
||||
m->SaveToBinFile(strdup(("models\\" + Global::asTerrainModel).c_str()));
|
||||
m->SaveToBinFile(strdup(("models/" + Global::asTerrainModel).c_str()));
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
8
Ground.h
8
Ground.h
@@ -20,6 +20,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Float3d.h"
|
||||
#include "Names.h"
|
||||
#include "lightarray.h"
|
||||
#include "lua.h"
|
||||
|
||||
typedef int TGroundNodeType;
|
||||
// Ra: zmniejszone liczby, aby zrobić tabelkę i zoptymalizować wyszukiwanie
|
||||
@@ -123,7 +124,7 @@ public:
|
||||
TEventLauncher *EvLaunch; // wyzwalacz zdarzeń
|
||||
TTraction *hvTraction; // drut zasilający
|
||||
TTractionPowerSource *psTractionPowerSource; // zasilanie drutu (zaniedbane w sceneriach)
|
||||
TTextSound *tsStaticSound; // dźwięk przestrzenny
|
||||
sound *tsStaticSound; // dźwięk przestrzenny
|
||||
TGroundNode *nNode; // obiekt renderujący grupowo ma tu wskaźnik na listę obiektów
|
||||
};
|
||||
Math3D::vector3 pCenter; // współrzędne środka do przydzielenia sektora
|
||||
@@ -260,6 +261,7 @@ class TGround
|
||||
event_map m_eventmap;
|
||||
TNames<TGroundNode *> m_trackmap;
|
||||
light_array m_lights; // collection of dynamic light sources present in the scene
|
||||
lua m_lua;
|
||||
|
||||
vector3 pOrigin;
|
||||
vector3 aRotate;
|
||||
@@ -318,7 +320,9 @@ class TGround
|
||||
void convert_terrain( TGroundNode const *Terrain );
|
||||
void convert_terrain( TSubModel const *Submodel );
|
||||
void RaTriangleDivider(TGroundNode *node);
|
||||
#ifdef _WIN32
|
||||
void Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
|
||||
public:
|
||||
void WyslijEvent(const std::string &e, const std::string &d);
|
||||
@@ -340,6 +344,8 @@ class TGround
|
||||
void IsolatedBusyList();
|
||||
void IsolatedBusy(const std::string t);
|
||||
void Silence(vector3 gdzie);
|
||||
|
||||
void add_event(TEvent *event);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
22
Logs.cpp
22
Logs.cpp
@@ -20,9 +20,24 @@ char logbuffer[ 256 ];
|
||||
char endstring[10] = "\n";
|
||||
|
||||
std::string filename_date() {
|
||||
|
||||
::SYSTEMTIME st;
|
||||
|
||||
#ifdef __linux__
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
tm *tms = localtime(&ts.tv_sec);
|
||||
st.wYear = tms->tm_year;
|
||||
st.wMonth = tms->tm_mon;
|
||||
st.wDayOfWeek = tms->tm_wday;
|
||||
st.wDay = tms->tm_mday;
|
||||
st.wHour = tms->tm_hour;
|
||||
st.wMinute = tms->tm_min;
|
||||
st.wSecond = tms->tm_sec;
|
||||
st.wMilliseconds = ts.tv_nsec / 1000000;
|
||||
#elif _WIN32
|
||||
::GetLocalTime( &st );
|
||||
#endif
|
||||
|
||||
std::snprintf(
|
||||
logbuffer,
|
||||
sizeof(logbuffer),
|
||||
@@ -48,16 +63,18 @@ std::string filename_scenery() {
|
||||
}
|
||||
|
||||
void WriteConsoleOnly(const char *str, double value) {
|
||||
|
||||
#ifdef _WIN32
|
||||
std::snprintf(logbuffer , sizeof(logbuffer), "%s %f \n", str, value);
|
||||
// stdout= GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD wr = 0;
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), logbuffer, (DWORD)strlen(logbuffer), &wr, NULL);
|
||||
// WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),endstring,strlen(endstring),&wr,NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WriteConsoleOnly(const char *str, bool newline)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// printf("%n ffafaf /n",str);
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||
FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
||||
@@ -65,6 +82,7 @@ void WriteConsoleOnly(const char *str, bool newline)
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), str, (DWORD)strlen(str), &wr, NULL);
|
||||
if (newline)
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), endstring, (DWORD)strlen(endstring), &wr, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WriteLog(const char *str, double value) {
|
||||
|
||||
@@ -8,12 +8,11 @@ http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Mover.h"
|
||||
#include "../globals.h"
|
||||
#include "../logs.h"
|
||||
#include "MOVER.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Oerlikon_ESt.h"
|
||||
#include "../parser.h"
|
||||
#include "mctools.h"
|
||||
#include "parser.h"
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Ra: tu należy przenosić funcje z mover.pas, które nie są z niego wywoływane.
|
||||
@@ -6389,6 +6388,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
|
||||
WriteLog("LOAD FIZ FROM " + file);
|
||||
|
||||
std::replace(file.begin(), file.end(), '\\', '/');
|
||||
std::ifstream in(file);
|
||||
if (!in.is_open())
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ Copyright (C) 2007-2014 Maciej Cierniak
|
||||
#include "stdafx.h"
|
||||
#include "hamulce.h"
|
||||
#include <typeinfo>
|
||||
#include "Mover.h"
|
||||
#include "MOVER.h"
|
||||
#include "usefull.h"
|
||||
|
||||
//---FUNKCJE OGOLNE---
|
||||
|
||||
@@ -511,7 +511,7 @@ class TDriverHandle {
|
||||
virtual double GetPos(int i);
|
||||
virtual double GetEP(double pos);
|
||||
|
||||
inline TDriverHandle() { ::SecureZeroMemory( Sounds, sizeof( Sounds ) ); }
|
||||
inline TDriverHandle() { memset(Sounds, 0, sizeof(Sounds)); }
|
||||
};
|
||||
|
||||
class TFV4a : public TDriverHandle {
|
||||
|
||||
@@ -75,7 +75,7 @@ bool ClearFlag( int &Flag, int const Value ) {
|
||||
}
|
||||
}
|
||||
|
||||
inline double Random(double a, double b)
|
||||
double Random(double a, double b)
|
||||
{
|
||||
std::uniform_real_distribution<> dis(a, b);
|
||||
return dis(Global::random_engine);
|
||||
@@ -276,7 +276,8 @@ extract_value( bool &Variable, std::string const &Key, std::string const &Input,
|
||||
}
|
||||
|
||||
bool FileExists( std::string const &Filename ) {
|
||||
|
||||
std::ifstream file( Filename );
|
||||
std::string fn = Filename;
|
||||
std::replace(fn.begin(), fn.end(), '\\', '/');
|
||||
std::ifstream file( fn );
|
||||
return( true == file.is_open() );
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
#include "Driver.h"
|
||||
#include "Event.h"
|
||||
#include "parser.h"
|
||||
|
||||
112
Model3d.cpp
112
Model3d.cpp
@@ -16,14 +16,17 @@ Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
|
||||
#include "Model3d.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "logs.h"
|
||||
#include "mczapkie/mctools.h"
|
||||
#include "Usefull.h"
|
||||
#include "ground.h"
|
||||
#include "Logs.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
#include "usefull.h"
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "mtable.h"
|
||||
#include "sn_utils.h"
|
||||
#include "World.h"
|
||||
|
||||
extern TWorld World;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
using namespace Mtable;
|
||||
@@ -380,15 +383,6 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
|
||||
glm::length( glm::vec3( glm::column( matrix, 0 ) ) ),
|
||||
glm::length( glm::vec3( glm::column( matrix, 1 ) ) ),
|
||||
glm::length( glm::vec3( glm::column( matrix, 2 ) ) ) };
|
||||
if( ( std::abs( scale.x - 1.0f ) > 0.01 )
|
||||
|| ( std::abs( scale.y - 1.0f ) > 0.01 )
|
||||
|| ( std::abs( scale.z - 1.0f ) > 0.01 ) ) {
|
||||
ErrorLog( "Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: " + to_string( scale ) + ")" );
|
||||
m_normalizenormals = (
|
||||
( ( std::abs( scale.x - scale.y ) < 0.01f ) && ( std::abs( scale.y - scale.z ) < 0.01f ) ) ?
|
||||
rescale :
|
||||
normalize );
|
||||
}
|
||||
}
|
||||
if (eType < TP_ROTATOR)
|
||||
{ // wczytywanie wierzchołków
|
||||
@@ -874,73 +868,79 @@ TSubModel *TSubModel::GetFromName(std::string const &search, bool i)
|
||||
// WORD hbIndices[18]={3,0,1,5,4,2,1,0,4,1,5,3,2,3,5,2,4,0};
|
||||
|
||||
void TSubModel::RaAnimation(TAnimType a)
|
||||
{
|
||||
glm::mat4 m = OpenGLMatrices.data(GL_MODELVIEW);
|
||||
RaAnimation(m, a);
|
||||
glLoadMatrixf(glm::value_ptr(m));
|
||||
}
|
||||
|
||||
void TSubModel::RaAnimation(glm::mat4 &m, TAnimType a)
|
||||
{ // wykonanie animacji niezależnie od renderowania
|
||||
switch (a)
|
||||
{ // korekcja położenia, jeśli submodel jest animowany
|
||||
case at_Translate: // Ra: było "true"
|
||||
if (iAnimOwner != iInstance)
|
||||
break; // cudza animacja
|
||||
glTranslatef(v_TransVector.x, v_TransVector.y, v_TransVector.z);
|
||||
m = glm::translate(m, glm::vec3(v_TransVector.x, v_TransVector.y, v_TransVector.z));
|
||||
break;
|
||||
case at_Rotate: // Ra: było "true"
|
||||
if (iAnimOwner != iInstance)
|
||||
break; // cudza animacja
|
||||
glRotatef(f_Angle, v_RotateAxis.x, v_RotateAxis.y, v_RotateAxis.z);
|
||||
m = glm::rotate(m, glm::radians(f_Angle), glm::vec3(v_RotateAxis.x, v_RotateAxis.y, v_RotateAxis.z));
|
||||
break;
|
||||
case at_RotateXYZ:
|
||||
if (iAnimOwner != iInstance)
|
||||
break; // cudza animacja
|
||||
glTranslatef(v_TransVector.x, v_TransVector.y, v_TransVector.z);
|
||||
glRotatef(v_Angles.x, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(v_Angles.y, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(v_Angles.z, 0.0f, 0.0f, 1.0f);
|
||||
m = glm::translate(m, glm::vec3(v_TransVector.x, v_TransVector.y, v_TransVector.z));
|
||||
m = glm::rotate(m, glm::radians(v_Angles.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
m = glm::rotate(m, glm::radians(v_Angles.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
m = glm::rotate(m, glm::radians(v_Angles.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
break;
|
||||
case at_SecondsJump: // sekundy z przeskokiem
|
||||
glRotatef(simulation::Time.data().wSecond * 6.0, 0.0, 1.0, 0.0);
|
||||
m = glm::rotate(m, glm::radians(simulation::Time.data().wSecond * 6.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_MinutesJump: // minuty z przeskokiem
|
||||
glRotatef(simulation::Time.data().wMinute * 6.0, 0.0, 1.0, 0.0);
|
||||
m = glm::rotate(m, glm::radians(simulation::Time.data().wMinute * 6.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_HoursJump: // godziny skokowo 12h/360°
|
||||
glRotatef(simulation::Time.data().wHour * 30.0 * 0.5, 0.0, 1.0, 0.0);
|
||||
m = glm::rotate(m, glm::radians(simulation::Time.data().wHour * 30.0f * 0.5f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_Hours24Jump: // godziny skokowo 24h/360°
|
||||
glRotatef(simulation::Time.data().wHour * 15.0 * 0.25, 0.0, 1.0, 0.0);
|
||||
m = glm::rotate(m, glm::radians(simulation::Time.data().wHour * 15.0f * 0.25f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_Seconds: // sekundy płynnie
|
||||
glRotatef(simulation::Time.second() * 6.0, 0.0, 1.0, 0.0);
|
||||
m = glm::rotate(m, glm::radians((float)simulation::Time.second() * 6.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_Minutes: // minuty płynnie
|
||||
glRotatef(simulation::Time.data().wMinute * 6.0 + simulation::Time.second() * 0.1, 0.0, 1.0, 0.0);
|
||||
m = glm::rotate(m, glm::radians(simulation::Time.data().wMinute * 6.0f + (float)simulation::Time.second() * 0.1f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_Hours: // godziny płynnie 12h/360°
|
||||
glRotatef(2.0 * Global::fTimeAngleDeg, 0.0, 1.0, 0.0);
|
||||
// glRotatef(GlobalTime->hh*30.0+GlobalTime->mm*0.5+GlobalTime->mr/120.0,0.0,1.0,0.0);
|
||||
m = glm::rotate(m, glm::radians(2.0f * (float)Global::fTimeAngleDeg), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_Hours24: // godziny płynnie 24h/360°
|
||||
glRotatef(Global::fTimeAngleDeg, 0.0, 1.0, 0.0);
|
||||
// glRotatef(GlobalTime->hh*15.0+GlobalTime->mm*0.25+GlobalTime->mr/240.0,0.0,1.0,0.0);
|
||||
m = glm::rotate(m, glm::radians((float)Global::fTimeAngleDeg), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_Billboard: // obrót w pionie do kamery
|
||||
{
|
||||
matrix4x4 mat; mat.OpenGL_Matrix( OpenGLMatrices.data_array( GL_MODELVIEW ) );
|
||||
float3 gdzie = float3(mat[3][0], mat[3][1], mat[3][2]); // początek układu współrzędnych submodelu względem kamery
|
||||
glLoadIdentity(); // macierz jedynkowa
|
||||
glTranslatef(gdzie.x, gdzie.y, gdzie.z); // początek układu zostaje bez
|
||||
// zmian
|
||||
glRotated(atan2(gdzie.x, gdzie.z) * 180.0 / M_PI, 0.0, 1.0,
|
||||
0.0); // jedynie obracamy w pionie o kąt
|
||||
m = glm::mat4(1.0f);
|
||||
m = glm::translate(m, glm::vec3(gdzie.x, gdzie.y, gdzie.z)); // początek układu zostaje bez zmian
|
||||
m = glm::rotate(m, (float)atan2(gdzie.x, gdzie.y), glm::vec3(0.0f, 1.0f, 0.0f)); // jedynie obracamy w pionie o kąt
|
||||
}
|
||||
break;
|
||||
case at_Wind: // ruch pod wpływem wiatru (wiatr będziemy liczyć potem...)
|
||||
glRotated(1.5 * std::sin(M_PI * simulation::Time.second() / 6.0), 0.0, 1.0, 0.0);
|
||||
m = glm::rotate(m, glm::radians(1.5f * (float)sin(M_PI * simulation::Time.second() / 6.0)), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_Sky: // animacja nieba
|
||||
glRotated(Global::fLatitudeDeg, 1.0, 0.0, 0.0); // ustawienie osi OY na północ
|
||||
// glRotatef(Global::fTimeAngleDeg,0.0,1.0,0.0); //obrót dobowy osi OX
|
||||
glRotated(-fmod(Global::fTimeAngleDeg, 360.0), 0.0, 1.0, 0.0); // obrót dobowy osi OX
|
||||
m = glm::rotate(m, glm::radians((float)Global::fLatitudeDeg), glm::vec3(0.0f, 1.0f, 0.0f)); // ustawienie osi OY na północ
|
||||
m = glm::rotate(m, glm::radians((float)-fmod(Global::fTimeAngleDeg, 360.0)), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
break;
|
||||
case at_IK11: // ostatni element animacji szkieletowej (podudzie, stopa)
|
||||
glRotatef(v_Angles.z, 0.0f, 1.0f, 0.0f); // obrót względem osi pionowej (azymut)
|
||||
glRotatef(v_Angles.x, 1.0f, 0.0f, 0.0f); // obrót względem poziomu (deklinacja)
|
||||
m = glm::rotate(m, glm::radians(v_Angles.z), glm::vec3(0.0f, 1.0f, 0.0f)); // obrót względem osi pionowej (azymut)
|
||||
m = glm::rotate(m, glm::radians(v_Angles.x), glm::vec3(1.0f, 0.0f, 0.0f)); // obrót względem poziomu (deklinacja)
|
||||
break;
|
||||
case at_DigiClk: // animacja zegara cyfrowego
|
||||
{ // ustawienie animacji w submodelach potomnych
|
||||
@@ -961,7 +961,7 @@ void TSubModel::RaAnimation(TAnimType a)
|
||||
}
|
||||
if (mAnimMatrix) // można by to dać np. do at_Translate
|
||||
{
|
||||
glMultMatrixf(mAnimMatrix->readArray());
|
||||
m *= glm::make_mat4(mAnimMatrix->e);
|
||||
mAnimMatrix = NULL; // jak animator będzie potrzebował, to ustawi ponownie
|
||||
}
|
||||
};
|
||||
@@ -1296,13 +1296,13 @@ void TSubModel::serialize(std::ostream &s,
|
||||
sn_utils::ls_float32(s, fVisible);
|
||||
sn_utils::ls_float32(s, fLight);
|
||||
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Ambient[i]);
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Diffuse[i]);
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Specular[i]);
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Emision[i]);
|
||||
|
||||
sn_utils::ls_float32(s, fWireSize);
|
||||
@@ -1420,13 +1420,13 @@ void TSubModel::deserialize(std::istream &s)
|
||||
fVisible = sn_utils::ld_float32(s);
|
||||
fLight = sn_utils::ld_float32(s);
|
||||
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Ambient[i] = sn_utils::ld_float32(s);
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Diffuse[i] = sn_utils::ld_float32(s);
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Specular[i] = sn_utils::ld_float32(s);
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Emision[i] = sn_utils::ld_float32(s);
|
||||
|
||||
fWireSize = sn_utils::ld_float32(s);
|
||||
@@ -1513,11 +1513,6 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
|
||||
if( submodel.eType < TP_ROTATOR ) {
|
||||
// normal vectors debug routine
|
||||
auto normallength = glm::length2( vertex.normal );
|
||||
if( ( false == submodel.m_normalizenormals )
|
||||
&& ( std::abs( normallength - 1.0f ) > 0.01f ) ) {
|
||||
submodel.m_normalizenormals = TSubModel::normalize; // we don't know if uniform scaling would suffice
|
||||
WriteLog( "Bad model: non-unit normal vector(s) encountered during sub-model geometry deserialization" );
|
||||
}
|
||||
}
|
||||
}
|
||||
// remap geometry type for custom type submodels
|
||||
@@ -1679,15 +1674,6 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
||||
glm::length( glm::vec3( glm::column( matrix, 0 ) ) ),
|
||||
glm::length( glm::vec3( glm::column( matrix, 1 ) ) ),
|
||||
glm::length( glm::vec3( glm::column( matrix, 2 ) ) ) };
|
||||
if( ( std::abs( scale.x - 1.0f ) > 0.01 )
|
||||
|| ( std::abs( scale.y - 1.0f ) > 0.01 )
|
||||
|| ( std::abs( scale.z - 1.0f ) > 0.01 ) ) {
|
||||
ErrorLog( "Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: " + to_string( scale ) + ")" );
|
||||
m_normalizenormals = (
|
||||
( ( std::abs( scale.x - scale.y ) < 0.01f ) && ( std::abs( scale.y - scale.z ) < 0.01f ) ) ?
|
||||
rescale :
|
||||
normalize );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1695,7 +1681,9 @@ void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic)
|
||||
{ // wczytanie modelu z pliku binarnego
|
||||
WriteLog("Loading binary format 3d model data from \"" + FileName + "\"...");
|
||||
|
||||
std::ifstream file(FileName, std::ios::binary);
|
||||
std::string fn = FileName;
|
||||
std::replace(fn.begin(), fn.end(), '\\', '/');
|
||||
std::ifstream file(fn, std::ios::binary);
|
||||
|
||||
uint32_t type = sn_utils::ld_uint32(file);
|
||||
uint32_t size = sn_utils::ld_uint32(file) - 8;
|
||||
|
||||
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include "GL/glew.h"
|
||||
#include "Parser.h"
|
||||
#include "parser.h"
|
||||
#include "dumb3d.h"
|
||||
#include "Float3d.h"
|
||||
#include "VBO.h"
|
||||
@@ -50,12 +50,11 @@ enum TAnimType // rodzaj animacji
|
||||
at_Undefined = 0x800000FF // animacja chwilowo nieokreślona
|
||||
};
|
||||
|
||||
class TModel3d;
|
||||
class TGroundNode;
|
||||
|
||||
class TSubModel
|
||||
{ // klasa submodelu - pojedyncza siatka, punkt świetlny albo grupa punktów
|
||||
//m7todo: zrobić normalną serializację
|
||||
|
||||
friend class opengl_renderer;
|
||||
friend class TModel3d; // temporary workaround. TODO: clean up class content/hierarchy
|
||||
friend class TDynamicObject; // temporary etc
|
||||
@@ -148,6 +147,7 @@ public:
|
||||
private:
|
||||
int SeekFaceNormal( std::vector<unsigned int> const &Masks, int const Startface, unsigned int const Mask, glm::vec3 const &Position, vertex_array const &Vertices );
|
||||
void RaAnimation(TAnimType a);
|
||||
void RaAnimation(glm::mat4 &m, TAnimType a);
|
||||
|
||||
public:
|
||||
static size_t iInstance; // identyfikator egzemplarza, który aktualnie renderuje model
|
||||
|
||||
78
PyInt.cpp
78
PyInt.cpp
@@ -11,20 +11,30 @@ TPythonInterpreter *TPythonInterpreter::_instance = NULL;
|
||||
|
||||
//#define _PY_INT_MORE_LOG
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
#endif
|
||||
|
||||
TPythonInterpreter::TPythonInterpreter()
|
||||
{
|
||||
WriteLog("Loading Python ...");
|
||||
#ifdef _WIN32
|
||||
if (sizeof(void*) == 8)
|
||||
Py_SetPythonHome("python64");
|
||||
else
|
||||
Py_SetPythonHome("python");
|
||||
#elif __linux__
|
||||
if (sizeof(void*) == 8)
|
||||
Py_SetPythonHome("linuxpython64");
|
||||
else
|
||||
Py_SetPythonHome("linuxpython");
|
||||
#endif
|
||||
Py_Initialize();
|
||||
_main = PyImport_ImportModule("__main__");
|
||||
if (_main == NULL)
|
||||
{
|
||||
WriteLog("Cannot import Python module __main__");
|
||||
}
|
||||
_screenRendererPriority = THREAD_PRIORITY_NORMAL; // domyslny priorytet normalny
|
||||
PyObject *cStringModule = PyImport_ImportModule("cStringIO");
|
||||
_stdErr = NULL;
|
||||
if (cStringModule == NULL)
|
||||
@@ -111,7 +121,7 @@ FILE *TPythonInterpreter::_getFile( std::string const &lookupPath, std::string c
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
if( nullptr != file ) { return file; }
|
||||
}
|
||||
std::string sourcefilepath = "python\\local\\" + className + ".py";
|
||||
std::string sourcefilepath = "python/local/" + className + ".py";
|
||||
FILE *file = fopen( sourcefilepath.c_str(), "r" );
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog( sourceFilePath );
|
||||
@@ -136,7 +146,7 @@ FILE *TPythonInterpreter::_getFile( std::string const &lookupPath, std::string c
|
||||
return file;
|
||||
}
|
||||
}
|
||||
char *basePath = "python\\local\\";
|
||||
char *basePath = "python/local/";
|
||||
sourceFilePath = (char *)calloc(strlen(basePath) + strlen(className) + 4, sizeof(char));
|
||||
strcat(sourceFilePath, basePath);
|
||||
strcat(sourceFilePath, className);
|
||||
@@ -233,38 +243,6 @@ PyObject *TPythonInterpreter::newClass(std::string const &className, PyObject *a
|
||||
return object;
|
||||
}
|
||||
|
||||
void TPythonInterpreter::setScreenRendererPriority(const char *priority)
|
||||
{
|
||||
if (strncmp(priority, "normal", 6) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_NORMAL;
|
||||
//#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Normal");
|
||||
//#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
else if (strncmp(priority, "lower", 5) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_BELOW_NORMAL;
|
||||
//#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Lower");
|
||||
//#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
else if (strncmp(priority, "lowest", 6) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_LOWEST;
|
||||
//#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Lowest");
|
||||
//#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
else if (strncmp(priority, "idle", 4) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_IDLE;
|
||||
//#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Idle");
|
||||
//#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
}
|
||||
|
||||
TPythonScreenRenderer::TPythonScreenRenderer(int textureId, PyObject *renderer)
|
||||
{
|
||||
_textureId = textureId;
|
||||
@@ -379,6 +357,10 @@ void TPythonScreenRenderer::render(PyObject *trainState)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
TPythonScreenRenderer::~TPythonScreenRenderer()
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
@@ -419,8 +401,9 @@ void TPythonScreens::reset(void *train)
|
||||
if (_thread != NULL)
|
||||
{
|
||||
// WriteLog("Awaiting python thread to end");
|
||||
WaitForSingleObject(_thread, INFINITE);
|
||||
_thread = NULL;
|
||||
_thread->join();
|
||||
delete _thread;
|
||||
_thread = nullptr;
|
||||
}
|
||||
_terminationFlag = false;
|
||||
_cleanupReadyFlag = false;
|
||||
@@ -553,7 +536,11 @@ void TPythonScreens::run()
|
||||
_renderReadyFlag = true;
|
||||
while (!_cleanupReadyFlag && !_terminationFlag)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Sleep(100);
|
||||
#elif __linux__
|
||||
usleep(100*1000);
|
||||
#endif
|
||||
}
|
||||
if (_terminationFlag)
|
||||
{
|
||||
@@ -568,33 +555,20 @@ void TPythonScreens::finish()
|
||||
_thread = NULL;
|
||||
}
|
||||
|
||||
DWORD WINAPI ScreenRendererThread(LPVOID lpParam)
|
||||
void ScreenRendererThread(TPythonScreens* renderer)
|
||||
{
|
||||
TPythonScreens *renderer = (TPythonScreens *)lpParam;
|
||||
renderer->run();
|
||||
renderer->finish();
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python Screen Renderer Thread Ends");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
return true;
|
||||
}
|
||||
|
||||
void TPythonScreens::start()
|
||||
{
|
||||
if (_screens.size() > 0)
|
||||
{
|
||||
_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ScreenRendererThread, this,
|
||||
CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&_threadId));
|
||||
if (_thread != NULL)
|
||||
{
|
||||
SetThreadPriority(_thread,
|
||||
TPythonInterpreter::getInstance()->getScreenRendererPriotity());
|
||||
if (ResumeThread(_thread) != (DWORD)-1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
WriteLog("Python Screen Renderer Thread Did Not Start");
|
||||
_thread = new std::thread(ScreenRendererThread, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
25
PyInt.h
25
PyInt.h
@@ -1,9 +1,13 @@
|
||||
#ifndef PyIntH
|
||||
#define PyIntH
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#ifdef _POSIX_C_SOURCE
|
||||
#undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
|
||||
#ifdef _XOPEN_SOURCE
|
||||
#undef _XOPEN_SOURCE
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu
|
||||
@@ -12,6 +16,12 @@
|
||||
#else
|
||||
#include "Python.h"
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include "parser.h"
|
||||
#include "Model3d.h"
|
||||
|
||||
@@ -36,7 +46,6 @@ class TPythonInterpreter
|
||||
TPythonInterpreter();
|
||||
~TPythonInterpreter() {}
|
||||
static TPythonInterpreter *_instance;
|
||||
int _screenRendererPriority = 0;
|
||||
// std::set<const char *, ltstr> _classes;
|
||||
std::set<std::string> _classes;
|
||||
PyObject *_main;
|
||||
@@ -53,11 +62,6 @@ class TPythonInterpreter
|
||||
*/ bool loadClassFile( std::string const &lookupPath, std::string const &className );
|
||||
PyObject *newClass( std::string const &className );
|
||||
PyObject *newClass( std::string const &className, PyObject *argsTuple );
|
||||
int getScreenRendererPriotity()
|
||||
{
|
||||
return _screenRendererPriority;
|
||||
};
|
||||
void setScreenRendererPriority(const char *priority);
|
||||
void handleError();
|
||||
};
|
||||
|
||||
@@ -84,8 +88,7 @@ class TPythonScreens
|
||||
bool _cleanupReadyFlag;
|
||||
bool _renderReadyFlag;
|
||||
bool _terminationFlag;
|
||||
void *_thread;
|
||||
unsigned int _threadId;
|
||||
std::thread *_thread;
|
||||
std::vector<TPythonScreenRenderer *> _screens;
|
||||
std::string _lookupPath;
|
||||
void *_train;
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
# maszyna
|
||||
[](https://ci.appveyor.com/project/Milek7/maszyna/branch/mover_in_c++)
|
||||
|
||||
MaSzyna Train Simulator
|
||||
|
||||
278
RealSound.cpp
278
RealSound.cpp
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
/*
|
||||
MaSzyna EU07 locomotive simulator
|
||||
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
|
||||
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "RealSound.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
//#include "math.h"
|
||||
#include "Timer.h"
|
||||
#include "mczapkie/mctools.h"
|
||||
#include "usefull.h"
|
||||
|
||||
TRealSound::TRealSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
|
||||
bool freqmod, double rmin)
|
||||
{
|
||||
Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
|
||||
}
|
||||
|
||||
TRealSound::~TRealSound()
|
||||
{
|
||||
// if (this) if (pSound) pSound->Stop();
|
||||
}
|
||||
|
||||
void TRealSound::Free()
|
||||
{
|
||||
}
|
||||
|
||||
void TRealSound::Init(std::string const &SoundName, double DistanceAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod, double rmin)
|
||||
{
|
||||
// Nazwa=SoundName; //to tak raczej nie zadziała, (SoundName) jest tymczasowe
|
||||
pSound = TSoundsManager::GetFromName(SoundName, Dynamic, &fFrequency);
|
||||
if (pSound)
|
||||
{
|
||||
if (freqmod)
|
||||
if (fFrequency != 22050.0)
|
||||
{ // dla modulowanych nie może być zmiany mnożnika, bo częstotliwość w nagłówku byłą
|
||||
// ignorowana, a mogła być inna niż 22050
|
||||
fFrequency = 22050.0;
|
||||
ErrorLog("Bad sound: " + SoundName + ", as modulated, should have 22.05kHz in header");
|
||||
}
|
||||
AM = 1.0;
|
||||
pSound->SetVolume(DSBVOLUME_MIN);
|
||||
}
|
||||
else
|
||||
{ // nie ma dźwięku, to jest wysyp
|
||||
AM = 0;
|
||||
ErrorLog("Missed sound: " + SoundName);
|
||||
}
|
||||
if (DistanceAttenuation > 0.0)
|
||||
{
|
||||
dSoundAtt = DistanceAttenuation * DistanceAttenuation;
|
||||
vSoundPosition.x = X;
|
||||
vSoundPosition.y = Y;
|
||||
vSoundPosition.z = Z;
|
||||
if (rmin < 0)
|
||||
iDoppler = 1; // wyłączenie efektu Dopplera, np. dla dźwięku ptaków
|
||||
}
|
||||
else
|
||||
dSoundAtt = -1;
|
||||
};
|
||||
|
||||
double TRealSound::ListenerDistance(vector3 ListenerPosition)
|
||||
{
|
||||
if (dSoundAtt == -1)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SquareMagnitude(ListenerPosition - vSoundPosition);
|
||||
}
|
||||
}
|
||||
|
||||
void TRealSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition)
|
||||
{
|
||||
if (!pSound)
|
||||
return;
|
||||
long int vol;
|
||||
double dS = 0.0;
|
||||
// double Distance;
|
||||
DWORD stat;
|
||||
if ((Global::bSoundEnabled) && (AM != 0))
|
||||
{
|
||||
if (Volume > 1.0)
|
||||
Volume = 1.0;
|
||||
fPreviousDistance = fDistance;
|
||||
fDistance = 0.0; //??
|
||||
if (dSoundAtt > 0.0)
|
||||
{
|
||||
vSoundPosition = NewPosition;
|
||||
dS = dSoundAtt; //*dSoundAtt; //bo odleglosc podawana w kwadracie
|
||||
fDistance = ListenerDistance(Global::pCameraPosition);
|
||||
if (ListenerInside) // osłabianie dźwięków z odległością
|
||||
Volume = Volume * dS / (dS + fDistance);
|
||||
else
|
||||
Volume = Volume * dS / (dS + 2 * fDistance); // podwójne dla ListenerInside=false
|
||||
}
|
||||
if (iDoppler) //
|
||||
{ // Ra 2014-07: efekt Dopplera nie zawsze jest wskazany
|
||||
// if (FreeFlyModeFlag) //gdy swobodne latanie - nie sprawdza się to
|
||||
fPreviousDistance = fDistance; // to efektu Dopplera nie będzie
|
||||
}
|
||||
if (Looping) // dźwięk zapętlony można wyłączyć i zostanie włączony w miarę potrzeby
|
||||
bLoopPlay = true; // dźwięk wyłączony
|
||||
// McZapkie-010302 - babranie tylko z niezbyt odleglymi dźwiękami
|
||||
if ((dSoundAtt == -1) || (fDistance < 20.0 * dS))
|
||||
{
|
||||
// vol=2*Volume+1;
|
||||
// if (vol<1) vol=1;
|
||||
// vol=10000*(log(vol)-1);
|
||||
// vol=10000*(vol-1);
|
||||
// int glos=1;
|
||||
// Volume=Volume*glos; //Ra: whatta hella is this
|
||||
if (Volume < 0.0)
|
||||
Volume = 0.0;
|
||||
vol = -5000.0 + 5000.0 * Volume;
|
||||
if (vol >= 0)
|
||||
vol = -1;
|
||||
if (Timer::GetSoundTimer() || !Looping) // Ra: po co to jest?
|
||||
pSound->SetVolume(vol); // Attenuation, in hundredths of a decibel (dB).
|
||||
pSound->GetStatus(&stat);
|
||||
if (!(stat & DSBSTATUS_PLAYING))
|
||||
pSound->Play(0, 0, Looping);
|
||||
}
|
||||
else // wylacz dzwiek bo daleko
|
||||
{ // Ra 2014-09: oddalanie się nie może być powodem do wyłączenie dźwięku
|
||||
/*
|
||||
// Ra: stara wersja, ale podobno lepsza
|
||||
pSound->GetStatus(&stat);
|
||||
if (bLoopPlay) //jeśli zapętlony, to zostanie ponownie włączony, o ile znajdzie się
|
||||
bliżej
|
||||
if (stat&DSBSTATUS_PLAYING)
|
||||
pSound->Stop();
|
||||
// Ra: wyłączyłem, bo podobno jest gorzej niż wcześniej
|
||||
//ZiomalCl: dźwięk po wyłączeniu sam się nie włączy, gdy wrócimy w rejon odtwarzania
|
||||
pSound->SetVolume(DSBVOLUME_MIN); //dlatego lepiej go wyciszyć na czas oddalenia się
|
||||
pSound->GetStatus(&stat);
|
||||
if (!(stat&DSBSTATUS_PLAYING))
|
||||
pSound->Play(0,0,Looping); //ZiomalCl: włączenie odtwarzania rownież i tu, gdyż
|
||||
jesli uruchamiamy dźwięk poza promieniem, nie uruchomi się on w ogóle
|
||||
*/
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void TRealSound::Start(){
|
||||
// włączenie dźwięku
|
||||
|
||||
};
|
||||
|
||||
void TRealSound::Stop()
|
||||
{
|
||||
DWORD stat;
|
||||
if (pSound)
|
||||
if ((Global::bSoundEnabled) && (AM != 0))
|
||||
{
|
||||
bLoopPlay = false; // dźwięk wyłączony
|
||||
pSound->GetStatus(&stat);
|
||||
if (stat & DSBSTATUS_PLAYING)
|
||||
pSound->Stop();
|
||||
}
|
||||
};
|
||||
|
||||
void TRealSound::AdjFreq(double Freq, double dt) // McZapkie TODO: dorobic tu efekt Dopplera
|
||||
// Freq moze byc liczba dodatnia mniejsza od 1 lub wieksza od 1
|
||||
{
|
||||
float df, Vlist;
|
||||
if ((Global::bSoundEnabled) && (AM != 0) && (pSound != nullptr))
|
||||
{
|
||||
if (dt > 0)
|
||||
// efekt Dopplera
|
||||
{
|
||||
Vlist = (sqrt(fPreviousDistance) - sqrt(fDistance)) / dt;
|
||||
df = Freq * (1 + Vlist / 299.8);
|
||||
}
|
||||
else
|
||||
df = Freq;
|
||||
if (Timer::GetSoundTimer())
|
||||
{
|
||||
df = fFrequency * df; // TODO - brac czestotliwosc probkowania z wav
|
||||
pSound->SetFrequency( clamp( df, static_cast<float>(DSBFREQUENCY_MIN), static_cast<float>(DSBFREQUENCY_MAX) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double TRealSound::GetWaveTime() // McZapkie: na razie tylko dla 22KHz/8bps
|
||||
{ // używana do pomiaru czasu dla dźwięków z początkiem i końcem
|
||||
if (!pSound)
|
||||
return 0.0;
|
||||
double WaveTime;
|
||||
DSBCAPS caps;
|
||||
caps.dwSize = sizeof(caps);
|
||||
pSound->GetCaps(&caps);
|
||||
WaveTime = caps.dwBufferBytes;
|
||||
return WaveTime /
|
||||
fFrequency; //(pSound->); // wielkosc w bajtach przez czestotliwosc probkowania
|
||||
}
|
||||
|
||||
void TRealSound::SetPan(int Pan)
|
||||
{
|
||||
pSound->SetPan(Pan);
|
||||
}
|
||||
|
||||
int TRealSound::GetStatus()
|
||||
{
|
||||
DWORD stat;
|
||||
if ((Global::bSoundEnabled) && (AM != 0))
|
||||
{
|
||||
pSound->GetStatus(&stat);
|
||||
return stat;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TRealSound::ResetPosition()
|
||||
{
|
||||
if (pSound) // Ra: znowu jakiś badziew!
|
||||
pSound->SetCurrentPosition(0);
|
||||
}
|
||||
|
||||
TTextSound::TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod, double rmin)
|
||||
: TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin)
|
||||
{
|
||||
Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
|
||||
}
|
||||
|
||||
void TTextSound::Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod, double rmin)
|
||||
{ // dodatkowo doczytuje plik tekstowy
|
||||
//TRealSound::Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
|
||||
fTime = GetWaveTime();
|
||||
std::string txt(SoundName);
|
||||
txt.erase( txt.rfind( '.' ) ); // obcięcie rozszerzenia
|
||||
for (size_t i = txt.length(); i > 0; --i)
|
||||
if (txt[i] == '/')
|
||||
txt[i] = '\\'; // bo nie rozumi
|
||||
txt += "-" + Global::asLang + ".txt"; // już może być w różnych językach
|
||||
if (!FileExists(txt))
|
||||
txt = "sounds\\" + txt; //ścieżka może nie być podana
|
||||
if (FileExists(txt))
|
||||
{ // wczytanie
|
||||
/* TFileStream *ts = new TFileStream(txt, fmOpenRead);
|
||||
asText = AnsiString::StringOfChar(' ', ts->Size);
|
||||
ts->Read(asText.c_str(), ts->Size);
|
||||
delete ts;
|
||||
*/ std::ifstream inputfile( txt );
|
||||
asText.assign( std::istreambuf_iterator<char>( inputfile ), std::istreambuf_iterator<char>() );
|
||||
}
|
||||
};
|
||||
void TTextSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition)
|
||||
{
|
||||
if (false == asText.empty())
|
||||
{ // jeśli ma powiązany tekst
|
||||
DWORD stat;
|
||||
pSound->GetStatus(&stat);
|
||||
if (!(stat & DSBSTATUS_PLAYING)) {
|
||||
// jeśli nie jest aktualnie odgrywany
|
||||
Global::tranTexts.Add( asText, fTime, true );
|
||||
}
|
||||
}
|
||||
TRealSound::Play(Volume, Looping, ListenerInside, NewPosition);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
83
RealSound.h
83
RealSound.h
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef RealSoundH
|
||||
#define RealSoundH
|
||||
|
||||
#include <string>
|
||||
#include "Sound.h"
|
||||
#include "Geometry.h"
|
||||
|
||||
class TRealSound
|
||||
{
|
||||
protected:
|
||||
PSound pSound = nullptr;
|
||||
// char *Nazwa; // dla celow odwszawiania NOTE: currently not used anywhere
|
||||
double fDistance = 0.0,
|
||||
fPreviousDistance = 0.0; // dla liczenia Dopplera
|
||||
float fFrequency = 22050.0; // częstotliwość samplowania pliku
|
||||
int iDoppler = 0; // Ra 2014-07: możliwość wyłączenia efektu Dopplera np. dla śpiewu ptaków
|
||||
public:
|
||||
vector3 vSoundPosition; // polozenie zrodla dzwieku
|
||||
double dSoundAtt = -1.0; // odleglosc polowicznego zaniku dzwieku
|
||||
double AM = 0.0; // mnoznik amplitudy
|
||||
double AA = 0.0; // offset amplitudy
|
||||
double FM = 0.0; // mnoznik czestotliwosci
|
||||
double FA = 0.0; // offset czestotliwosci
|
||||
bool bLoopPlay = false; // czy zapętlony dźwięk jest odtwarzany
|
||||
TRealSound() = default;
|
||||
TRealSound( std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
|
||||
bool freqmod = false, double rmin = 0.0);
|
||||
~TRealSound();
|
||||
void Free();
|
||||
void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
|
||||
bool freqmod = false, double rmin = 0.0);
|
||||
double ListenerDistance(vector3 ListenerPosition);
|
||||
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
|
||||
void Start();
|
||||
void Stop();
|
||||
void AdjFreq(double Freq, double dt);
|
||||
void SetPan(int Pan);
|
||||
double GetWaveTime(); // McZapkie TODO: dorobic dla roznych bps
|
||||
int GetStatus();
|
||||
void ResetPosition();
|
||||
// void FreqReset(float f=22050.0) {fFrequency=f;};
|
||||
bool Empty() { return ( pSound == nullptr ); }
|
||||
};
|
||||
|
||||
class TTextSound : public TRealSound
|
||||
{ // dźwięk ze stenogramem
|
||||
std::string asText;
|
||||
float fTime; // czas trwania
|
||||
public:
|
||||
TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod = false, double rmin = 0.0);
|
||||
void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod = false, double rmin = 0.0);
|
||||
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
|
||||
};
|
||||
|
||||
class TSynthSound
|
||||
{ // klasa generująca sygnał odjazdu (Rp12, Rp13), potem rozbudować o pracę manewrowego...
|
||||
int iIndex[44]; // indeksy początkowe, gdy mamy kilka wariantów dźwięków składowych
|
||||
// 0..9 - cyfry 0..9
|
||||
// 10..19 - liczby 10..19
|
||||
// 21..29 - dziesiątki (*21==*10?)
|
||||
// 31..39 - setki 100,200,...,800,900
|
||||
// 40 - "tysiąc"
|
||||
// 41 - "tysiące"
|
||||
// 42 - indeksy początkowe dla "odjazd"
|
||||
// 43 - indeksy początkowe dla "gotów"
|
||||
PSound *sSound; // posortowana tablica dźwięków, rozmiar zależny od liczby znalezionych plików
|
||||
// a może zamiast wielu plików/dźwięków zrobić jeden połączony plik i posługiwać się czasem
|
||||
// od..do?
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
#include "Track.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
50
Sound.h
50
Sound.h
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stack>
|
||||
#include <dsound.h>
|
||||
|
||||
typedef LPDIRECTSOUNDBUFFER PSound;
|
||||
|
||||
class TSoundContainer
|
||||
{
|
||||
public:
|
||||
int Concurrent;
|
||||
int Oldest;
|
||||
std::string m_name;
|
||||
LPDIRECTSOUNDBUFFER DSBuffer;
|
||||
float fSamplingRate; // częstotliwość odczytana z pliku
|
||||
int iBitsPerSample; // ile bitów na próbkę
|
||||
TSoundContainer *Next;
|
||||
std::stack<LPDIRECTSOUNDBUFFER> DSBuffers;
|
||||
|
||||
TSoundContainer(LPDIRECTSOUND pDS, std::string const &Directory, std::string const &Filename, int NConcurrent);
|
||||
~TSoundContainer();
|
||||
LPDIRECTSOUNDBUFFER GetUnique( LPDIRECTSOUND pDS );
|
||||
};
|
||||
|
||||
class TSoundsManager
|
||||
{
|
||||
private:
|
||||
static LPDIRECTSOUND pDS;
|
||||
static LPDIRECTSOUNDNOTIFY pDSNotify;
|
||||
static TSoundContainer *First;
|
||||
static int Count;
|
||||
|
||||
static TSoundContainer * LoadFromFile( std::string const &Directory, std::string const &FileName, int Concurrent);
|
||||
|
||||
public:
|
||||
~TSoundsManager();
|
||||
static bool Init( HWND hWnd );
|
||||
static void Free();
|
||||
static LPDIRECTSOUNDBUFFER GetFromName( std::string const &Name, bool Dynamic, float *fSamplingRate = NULL );
|
||||
static void RestoreAll();
|
||||
};
|
||||
@@ -11,13 +11,11 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "classes.hpp"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "geometry.h"
|
||||
#include "Spline.h"
|
||||
#include "usefull.h"
|
||||
#include "maptextfile.hpp"
|
||||
|
||||
//#define asSplinesPatch AnsiString("Scenery\\")
|
||||
|
||||
bool Connect(TKnot *k1, TKnot *k2)
|
||||
{
|
||||
if (k1 && k2)
|
||||
|
||||
88
Texture.cpp
88
Texture.cpp
@@ -14,16 +14,17 @@ http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "texture.h"
|
||||
#include "Texture.h"
|
||||
|
||||
#include <ddraw.h>
|
||||
#include "GL/glew.h"
|
||||
|
||||
#include "usefull.h"
|
||||
#include "globals.h"
|
||||
#include "logs.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "sn_utils.h"
|
||||
|
||||
#include <png.h>
|
||||
|
||||
#define EU07_DEFERRED_TEXTURE_UPLOAD
|
||||
|
||||
texture_manager::texture_manager() {
|
||||
@@ -47,6 +48,7 @@ opengl_texture::load() {
|
||||
|
||||
if( extension == "dds" ) { load_DDS(); }
|
||||
else if( extension == "tga" ) { load_TGA(); }
|
||||
else if( extension == "png" ) { load_PNG(); }
|
||||
else if( extension == "bmp" ) { load_BMP(); }
|
||||
else if( extension == "tex" ) { load_TEX(); }
|
||||
else { goto fail; }
|
||||
@@ -73,6 +75,51 @@ fail:
|
||||
return;
|
||||
}
|
||||
|
||||
void opengl_texture::load_PNG()
|
||||
{
|
||||
png_image png;
|
||||
memset(&png, 0, sizeof(png_image));
|
||||
png.version = PNG_IMAGE_VERSION;
|
||||
|
||||
png_image_begin_read_from_file(&png, name.c_str());
|
||||
if (png.warning_or_error)
|
||||
{
|
||||
data_state = resource_state::failed;
|
||||
ErrorLog(name + " error: " + std::string(png.message));
|
||||
return;
|
||||
}
|
||||
|
||||
if (png.format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
data_format = GL_RGBA;
|
||||
data_components = GL_RGBA;
|
||||
png.format = PNG_FORMAT_RGBA;
|
||||
}
|
||||
else
|
||||
{
|
||||
data_format = GL_RGB;
|
||||
data_components = GL_RGB;
|
||||
png.format = PNG_FORMAT_RGB;
|
||||
}
|
||||
data_width = png.width;
|
||||
data_height = png.height;
|
||||
|
||||
data.resize(PNG_IMAGE_SIZE(png));
|
||||
|
||||
png_image_finish_read(&png, nullptr,
|
||||
(void*)&data[0], -data_width * PNG_IMAGE_PIXEL_SIZE(png.format), nullptr);
|
||||
|
||||
if (png.warning_or_error)
|
||||
{
|
||||
data_state = resource_state::failed;
|
||||
ErrorLog(name + " error: " + std::string(png.message));
|
||||
return;
|
||||
}
|
||||
|
||||
data_mapcount = 1;
|
||||
data_state = resource_state::good;
|
||||
}
|
||||
|
||||
void
|
||||
opengl_texture::load_BMP() {
|
||||
|
||||
@@ -561,8 +608,8 @@ opengl_texture::create() {
|
||||
for( int maplevel = 0; maplevel < data_mapcount; ++maplevel ) {
|
||||
|
||||
if( ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT )
|
||||
|| ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT )
|
||||
|| ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ) ) {
|
||||
|| ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT )
|
||||
|| ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ) ) {
|
||||
// compressed dds formats
|
||||
int const datablocksize =
|
||||
( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ?
|
||||
@@ -589,7 +636,9 @@ opengl_texture::create() {
|
||||
}
|
||||
}
|
||||
|
||||
data = std::vector<char>();
|
||||
// TBD, TODO: keep the texture data if we start doing some gpu data cleaning down the road
|
||||
data.clear();
|
||||
data.shrink_to_fit();
|
||||
data_state = resource_state::none;
|
||||
is_ready = true;
|
||||
}
|
||||
@@ -719,22 +768,9 @@ texture_manager::create( std::string Filename, bool const Loadnow ) {
|
||||
if( Filename.rfind( '.' ) != std::string::npos )
|
||||
Filename.erase( Filename.rfind( '.' ) ); // trim extension if there's one
|
||||
|
||||
for( char &c : Filename ) {
|
||||
// change forward slashes to windows ones. NOTE: probably not strictly necessary, but eh
|
||||
c = ( c == '/' ? '\\' : c );
|
||||
}
|
||||
/*
|
||||
std::transform(
|
||||
Filename.begin(), Filename.end(),
|
||||
Filename.begin(),
|
||||
[]( char Char ){ return Char == '/' ? '\\' : Char; } );
|
||||
*/
|
||||
if( Filename.find( '\\' ) == std::string::npos ) {
|
||||
// jeśli bieżaca ścieżka do tekstur nie została dodana to dodajemy domyślną
|
||||
Filename = szTexturePath + Filename;
|
||||
}
|
||||
std::replace(Filename.begin(), Filename.end(), '\\', '/'); // fix slashes
|
||||
|
||||
std::vector<std::string> extensions{ { ".dds" }, { ".tga" }, { ".bmp" }, { ".ext" } };
|
||||
std::vector<std::string> extensions{ { ".dds" }, { ".tga" }, { ".png" }, { ".bmp" }, { ".ext" } };
|
||||
|
||||
// try to locate requested texture in the databank
|
||||
auto lookup = find_in_databank( Filename + Global::szDefaultExt );
|
||||
@@ -911,14 +947,14 @@ texture_manager::find_in_databank( std::string const &Texturename ) const {
|
||||
|
||||
auto lookup = m_texturemappings.find( Texturename );
|
||||
if( lookup != m_texturemappings.end() ) {
|
||||
return lookup->second;
|
||||
return (int)lookup->second;
|
||||
}
|
||||
// jeszcze próba z dodatkową ścieżką
|
||||
lookup = m_texturemappings.find( szTexturePath + Texturename );
|
||||
lookup = m_texturemappings.find( global_texture_path + Texturename );
|
||||
|
||||
return (
|
||||
lookup != m_texturemappings.end() ?
|
||||
lookup->second :
|
||||
(int)lookup->second :
|
||||
npos );
|
||||
}
|
||||
|
||||
@@ -928,7 +964,7 @@ texture_manager::find_on_disk( std::string const &Texturename ) const {
|
||||
|
||||
return(
|
||||
FileExists( Texturename ) ? Texturename :
|
||||
FileExists( szTexturePath + Texturename ) ? szTexturePath + Texturename :
|
||||
FileExists( global_texture_path + Texturename ) ? global_texture_path + Texturename :
|
||||
"" );
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include <istream>
|
||||
#include <ddraw.h>
|
||||
#include "winheaders.h"
|
||||
#include <string>
|
||||
#include "GL/glew.h"
|
||||
#include "ResourceManager.h"
|
||||
@@ -57,6 +57,7 @@ struct opengl_texture {
|
||||
private:
|
||||
// methods
|
||||
void load_BMP();
|
||||
void load_PNG();
|
||||
void load_DDS();
|
||||
void load_TEX();
|
||||
void load_TGA();
|
||||
|
||||
19
Timer.cpp
19
Timer.cpp
@@ -65,12 +65,19 @@ void ResetTimers()
|
||||
fSoundTimer = 0.0;
|
||||
};
|
||||
|
||||
LONGLONG fr, count, oldCount;
|
||||
|
||||
void UpdateTimers(bool pause) {
|
||||
uint64_t fr, count, oldCount;
|
||||
|
||||
void UpdateTimers(bool pause)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
QueryPerformanceFrequency((LARGE_INTEGER *)&fr);
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&count);
|
||||
#elif __linux__
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||
count = (uint64_t)ts.tv_sec * 1000000000 + (uint64_t)ts.tv_nsec;
|
||||
fr = 1000000000;
|
||||
#endif
|
||||
DeltaRenderTime = double(count - oldCount) / double(fr);
|
||||
if (!pause)
|
||||
{
|
||||
@@ -87,9 +94,11 @@ void UpdateTimers(bool pause) {
|
||||
|
||||
oldCount = count;
|
||||
// Keep track of the time lapse and frame count
|
||||
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
#if __linux__
|
||||
double fTime = (double)(count / 1000000000);
|
||||
#elif _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
double fTime = ::GetTickCount64() * 0.001f; // Get current time in seconds
|
||||
#else
|
||||
#elif _WIN32
|
||||
double fTime = ::GetTickCount() * 0.001f; // Get current time in seconds
|
||||
#endif
|
||||
++dwFrames; // licznik ramek
|
||||
|
||||
10
Track.cpp
10
Track.cpp
@@ -16,12 +16,12 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Track.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "Ground.h"
|
||||
#include "parser.h"
|
||||
#include "Mover.h"
|
||||
#include "MOVER.h"
|
||||
#include "DynObj.h"
|
||||
#include "AnimModel.h"
|
||||
#include "MemCell.h"
|
||||
@@ -1812,11 +1812,11 @@ void TTrack::EnvironmentSet()
|
||||
glColor3f(1.0f, 1.0f, 1.0f); // Ra: potrzebne to?
|
||||
switch( eEnvironment ) {
|
||||
case e_canyon: {
|
||||
Global::DayLight.apply_intensity( 0.4f );
|
||||
Global::DayLight.apply_intensity(0.4f);
|
||||
break;
|
||||
}
|
||||
case e_tunnel: {
|
||||
Global::DayLight.apply_intensity( 0.2f );
|
||||
Global::DayLight.apply_intensity(0.2f);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -1830,7 +1830,7 @@ void TTrack::EnvironmentReset()
|
||||
switch( eEnvironment ) {
|
||||
case e_canyon:
|
||||
case e_tunnel: {
|
||||
Global::DayLight.apply_intensity();
|
||||
Global::DayLight.apply_intensity();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "Traction.h"
|
||||
#include "Globals.h"
|
||||
#include "logs.h"
|
||||
#include "Logs.h"
|
||||
#include "mctools.h"
|
||||
#include "TractionPower.h"
|
||||
|
||||
@@ -476,10 +476,11 @@ TTraction::wire_color() const {
|
||||
}
|
||||
default: {break; }
|
||||
}
|
||||
color *= 0.2;
|
||||
// w zaleźności od koloru swiatła
|
||||
color.r *= Global::DayLight.ambient[ 0 ];
|
||||
color.g *= Global::DayLight.ambient[ 1 ];
|
||||
color.b *= Global::DayLight.ambient[ 2 ];
|
||||
//color.r *= Global::daylight.ambient.x;
|
||||
//color.g *= Global::daylight.ambient.y;
|
||||
//color.b *= Global::daylight.ambient.z;
|
||||
}
|
||||
else {
|
||||
// tymczasowo pokazanie zasilanych odcinków
|
||||
|
||||
@@ -34,9 +34,9 @@ class TTraction
|
||||
float NominalVoltage { 0.0f };
|
||||
float MaxCurrent { 0.0f };
|
||||
float fResistivity { 0.0f }; //[om/m], przeliczone z [om/km]
|
||||
DWORD Material { 0 }; // 1: Cu, 2: Al
|
||||
unsigned int Material { 0 }; // 1: Cu, 2: Al
|
||||
float WireThickness { 0.0f };
|
||||
DWORD DamageFlag { 0 }; // 1: zasniedziale, 128: zerwana
|
||||
unsigned int DamageFlag { 0 }; // 1: zasniedziale, 128: zerwana
|
||||
int Wires { 2 };
|
||||
float WireOffset { 0.0f };
|
||||
std::string asPowerSupplyName; // McZapkie: nazwa podstacji trakcyjnej
|
||||
|
||||
77
Train.h
77
Train.h
@@ -14,7 +14,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Button.h"
|
||||
#include "Gauge.h"
|
||||
#include "Spring.h"
|
||||
#include "AdvSound.h"
|
||||
#include "PyInt.h"
|
||||
#include "command.h"
|
||||
|
||||
@@ -111,8 +110,8 @@ class TTrain
|
||||
bool initialize_button(cParser &Parser, std::string const &Label, int const Cabindex);
|
||||
// plays specified sound, or fallback sound if the primary sound isn't presend
|
||||
// NOTE: temporary routine until sound system is sorted out and paired with switches
|
||||
void play_sound( PSound Sound, int const Volume = DSBVOLUME_MAX, DWORD const Flags = 0 );
|
||||
void play_sound( PSound Sound, PSound Fallbacksound, int const Volume, DWORD const Flags );
|
||||
void play_sound( sound* Sound, float gain = 1.0f);
|
||||
void play_sound( sound* Sound, sound* Fallbacksound, float gain = 1.0f );
|
||||
// helper, returns true for EMU with oerlikon brake
|
||||
bool is_eztoer() const;
|
||||
// command handlers
|
||||
@@ -389,48 +388,48 @@ public: // reszta może by?publiczna
|
||||
double fMechRoll;
|
||||
double fMechPitch;
|
||||
|
||||
PSound dsbNastawnikJazdy;
|
||||
PSound dsbNastawnikBocz; // hunter-081211
|
||||
PSound dsbRelay;
|
||||
PSound dsbPneumaticRelay;
|
||||
PSound dsbSwitch;
|
||||
PSound dsbPneumaticSwitch;
|
||||
PSound dsbReverserKey; // hunter-121211
|
||||
sound* dsbNastawnikJazdy = nullptr;
|
||||
sound* dsbNastawnikBocz = nullptr; // hunter-081211
|
||||
sound* dsbRelay = nullptr;
|
||||
sound* dsbPneumaticRelay = nullptr;
|
||||
sound* dsbSwitch = nullptr;
|
||||
sound* dsbPneumaticSwitch = nullptr;
|
||||
sound* dsbReverserKey = nullptr; // hunter-121211
|
||||
|
||||
PSound dsbCouplerAttach; // Ra: w kabinie????
|
||||
PSound dsbCouplerDetach; // Ra: w kabinie???
|
||||
sound* dsbCouplerAttach = nullptr; // Ra: w kabinie????
|
||||
sound* dsbCouplerDetach = nullptr; // Ra: w kabinie???
|
||||
|
||||
PSound dsbDieselIgnition; // Ra: w kabinie???
|
||||
sound* dsbDieselIgnition = nullptr; // Ra: w kabinie???
|
||||
|
||||
PSound dsbDoorClose; // Ra: w kabinie???
|
||||
PSound dsbDoorOpen; // Ra: w kabinie???
|
||||
sound* dsbDoorClose = nullptr; // Ra: w kabinie???
|
||||
sound* dsbDoorOpen = nullptr; // Ra: w kabinie???
|
||||
|
||||
// Winger 010304
|
||||
PSound dsbPantUp;
|
||||
PSound dsbPantDown;
|
||||
sound* dsbPantUp = nullptr;
|
||||
sound* dsbPantDown = nullptr;
|
||||
|
||||
PSound dsbWejscie_na_bezoporow;
|
||||
PSound dsbWejscie_na_drugi_uklad; // hunter-081211: poprawka literowki
|
||||
sound* dsbWejscie_na_bezoporow = nullptr;
|
||||
sound* dsbWejscie_na_drugi_uklad = nullptr; // hunter-081211: poprawka literowki
|
||||
|
||||
// PSound dsbHiss1;
|
||||
// PSound dsbHiss2;
|
||||
// sound* dsbHiss1;
|
||||
// sound* dsbHiss2;
|
||||
|
||||
// McZapkie-280302
|
||||
TRealSound rsBrake;
|
||||
TRealSound rsSlippery;
|
||||
TRealSound rsHiss; // upuszczanie
|
||||
TRealSound rsHissU; // napelnianie
|
||||
TRealSound rsHissE; // nagle
|
||||
TRealSound rsHissX; // fala
|
||||
TRealSound rsHissT; // czasowy
|
||||
TRealSound rsSBHiss;
|
||||
TRealSound rsRunningNoise;
|
||||
TRealSound rsEngageSlippery;
|
||||
TRealSound rsFadeSound;
|
||||
sound* rsBrake = nullptr;
|
||||
sound* rsSlippery = nullptr;
|
||||
sound* rsHiss = nullptr; // upuszczanie
|
||||
sound* rsHissU = nullptr; // napelnianie
|
||||
sound* rsHissE = nullptr; // nagle
|
||||
sound* rsHissX = nullptr; // fala
|
||||
sound* rsHissT = nullptr; // czasowy
|
||||
sound* rsSBHiss = nullptr;
|
||||
sound* rsRunningNoise = nullptr;
|
||||
sound* rsEngageSlippery = nullptr;
|
||||
sound* rsFadeSound = nullptr;
|
||||
|
||||
PSound dsbHasler;
|
||||
PSound dsbBuzzer;
|
||||
PSound dsbSlipAlarm; // Bombardier 011010: alarm przy poslizgu dla 181/182
|
||||
sound* dsbHasler = nullptr;
|
||||
sound* dsbBuzzer = nullptr;
|
||||
sound* dsbSlipAlarm = nullptr; // Bombardier 011010: alarm przy poslizgu dla 181/182
|
||||
|
||||
int iCabLightFlag; // McZapkie:120503: oswietlenie kabiny (0: wyl, 1: przyciemnione, 2: pelne)
|
||||
bool bCabLight; // hunter-091012: czy swiatlo jest zapalone?
|
||||
@@ -440,10 +439,10 @@ public: // reszta może by?publiczna
|
||||
vector3 MirrorPosition(bool lewe);
|
||||
|
||||
private:
|
||||
// PSound dsbBuzzer;
|
||||
PSound dsbCouplerStretch;
|
||||
PSound dsbEN57_CouplerStretch;
|
||||
PSound dsbBufferClamp;
|
||||
sound* dsbCouplerStretch = nullptr;
|
||||
sound* dsbEN57_CouplerStretch = nullptr;
|
||||
sound* dsbBufferClamp = nullptr;
|
||||
|
||||
double fBlinkTimer;
|
||||
float fHaslerTimer;
|
||||
float fConverterTimer; // hunter-261211: dla przekaznika
|
||||
|
||||
@@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#define TrkFollH
|
||||
|
||||
#include "Track.h"
|
||||
#include "McZapkie\MOVER.h"
|
||||
#include "McZapkie/MOVER.h"
|
||||
|
||||
class TTrackFollower
|
||||
{ // oś poruszająca się po torze
|
||||
|
||||
1
VBO.h
1
VBO.h
@@ -8,6 +8,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shader.h"
|
||||
|
||||
#include "openglgeometrybank.h"
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Sound.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "usefull.h"
|
||||
#include "mczapkie/mctools.h"
|
||||
#include "WavRead.h"
|
||||
#include "wavread.h"
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
{ \
|
||||
75
World.cpp
75
World.cpp
@@ -21,7 +21,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "mtable.h"
|
||||
#include "Sound.h"
|
||||
#include "sound.h"
|
||||
#include "Camera.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "Event.h"
|
||||
@@ -46,10 +46,12 @@ simulation_time Time;
|
||||
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
extern "C"
|
||||
{
|
||||
GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound
|
||||
GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window );
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
simulation_time::init() {
|
||||
@@ -63,7 +65,21 @@ simulation_time::init() {
|
||||
WORD const requestedhour = m_time.wHour;
|
||||
WORD const requestedminute = m_time.wMinute;
|
||||
|
||||
#ifdef __linux__
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
tm *tms = localtime(&ts.tv_sec);
|
||||
m_time.wYear = tms->tm_year;
|
||||
m_time.wMonth = tms->tm_mon;
|
||||
m_time.wDayOfWeek = tms->tm_wday;
|
||||
m_time.wDay = tms->tm_mday;
|
||||
m_time.wHour = tms->tm_hour;
|
||||
m_time.wMinute = tms->tm_min;
|
||||
m_time.wSecond = tms->tm_sec;
|
||||
m_time.wMilliseconds = ts.tv_nsec / 1000000;
|
||||
#elif _WIN32
|
||||
::GetLocalTime( &m_time );
|
||||
#endif
|
||||
|
||||
if( Global::fMoveLight > 0.0 ) {
|
||||
// day and month of the year can be overriden by scenario setup
|
||||
@@ -197,7 +213,6 @@ TWorld::~TWorld()
|
||||
{
|
||||
TrainDelete();
|
||||
// Ground.Free(); //Ra: usunięcie obiektów przed usunięciem dźwięków - sypie się
|
||||
TSoundsManager::Free();
|
||||
}
|
||||
|
||||
void TWorld::TrainDelete(TDynamicObject *d)
|
||||
@@ -223,22 +238,13 @@ bool TWorld::Init( GLFWwindow *Window ) {
|
||||
|
||||
WriteLog( "\nStarting MaSzyna rail vehicle simulator (release: " + Global::asVersion + ")" );
|
||||
WriteLog( "For online documentation and additional files refer to: http://eu07.pl");
|
||||
WriteLog( "Authors: Marcin_EU, McZapkie, ABu, Winger, Tolaris, nbmx, OLO_EU, Bart, Quark-t, "
|
||||
"ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter, szociu, Stele, Q, firleju and others\n" );
|
||||
|
||||
UILayer.set_background( "logo" );
|
||||
|
||||
if( true == TSoundsManager::Init( glfwGetWin32Window( window ) ) ) {
|
||||
WriteLog( "Sound subsystem setup complete" );
|
||||
}
|
||||
else {
|
||||
ErrorLog( "Sound subsystem setup failed" );
|
||||
return false;
|
||||
}
|
||||
|
||||
glfwSetWindowTitle( window, ( Global::AppName + " (" + Global::SceneryFile + ")" ).c_str() ); // nazwa scenerii
|
||||
UILayer.set_progress(0.01);
|
||||
UILayer.set_progress( "Loading scenery / Wczytywanie scenerii" );
|
||||
|
||||
GfxRenderer.Render();
|
||||
|
||||
WriteLog( "World setup..." );
|
||||
@@ -608,8 +614,7 @@ void TWorld::OnKeyDown(int cKey)
|
||||
{ // i potwierdzenie
|
||||
if( cKey == GLFW_KEY_Y ) {
|
||||
// flaga wyjścia z programu
|
||||
::PostQuitMessage( 0 );
|
||||
// Global::iTextMode = -1;
|
||||
glfwSetWindowShouldClose(window, 1);
|
||||
}
|
||||
return; // nie przekazujemy do pociągu
|
||||
}
|
||||
@@ -619,6 +624,7 @@ void TWorld::OnKeyDown(int cKey)
|
||||
{
|
||||
if (cKey == GLFW_KEY_1)
|
||||
Global::iWriteLogEnabled ^= 1; // włącz/wyłącz logowanie do pliku
|
||||
#ifdef _WIN32
|
||||
else if (cKey == GLFW_KEY_2)
|
||||
{ // włącz/wyłącz okno konsoli
|
||||
Global::iWriteLogEnabled ^= 2;
|
||||
@@ -629,6 +635,7 @@ void TWorld::OnKeyDown(int cKey)
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// else if (cKey=='3') Global::iWriteLogEnabled^=4; //wypisywanie nazw torów
|
||||
}
|
||||
}
|
||||
@@ -685,8 +692,7 @@ void TWorld::OnKeyDown(int cKey)
|
||||
temp->MoverParameters->DecBrakeMult())
|
||||
if (Train)
|
||||
{ // dźwięk oczywiście jest w kabinie
|
||||
Train->dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
||||
Train->dsbSwitch->Play(0, 0, 0);
|
||||
Train->dsbSwitch->gain(1.0f).play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -715,8 +721,7 @@ void TWorld::OnKeyDown(int cKey)
|
||||
tmp->iLights[CouplNr] = (tmp->iLights[CouplNr] & ~mask) | set;
|
||||
if (Train)
|
||||
{ // Ra: ten dźwięk z kabiny to przegięcie, ale na razie zostawiam
|
||||
Train->dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
||||
Train->dsbSwitch->Play(0, 0, 0);
|
||||
Train->dsbSwitch->gain(1.0f).play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -736,8 +741,7 @@ void TWorld::OnKeyDown(int cKey)
|
||||
if (temp->MoverParameters->IncLocalBrakeLevelFAST())
|
||||
if (Train)
|
||||
{ // dźwięk oczywiście jest w kabinie
|
||||
Train->dsbPneumaticRelay->SetVolume(-80);
|
||||
Train->dsbPneumaticRelay->Play(0, 0, 0);
|
||||
Train->dsbPneumaticRelay->gain(Global::soundgainmode == Global::compat ? 0.9f : 0.5f).play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -756,8 +760,7 @@ void TWorld::OnKeyDown(int cKey)
|
||||
if (temp->MoverParameters->DecLocalBrakeLevelFAST())
|
||||
if (Train)
|
||||
{ // dźwięk oczywiście jest w kabinie
|
||||
Train->dsbPneumaticRelay->SetVolume(-80);
|
||||
Train->dsbPneumaticRelay->Play(0, 0, 0);
|
||||
Train->dsbPneumaticRelay->gain(Global::soundgainmode == Global::compat ? 0.9f : 0.5f).play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -945,7 +948,9 @@ bool TWorld::Update()
|
||||
// tak można np. moc silników itp., ale ruch musi być przeliczany w każdej klatce, bo
|
||||
// inaczej skacze
|
||||
Global::tranTexts.Update(); // obiekt obsługujący stenogramy dźwięków na ekranie
|
||||
#ifdef _WIN32
|
||||
Console::Update(); // obsługa cykli PoKeys (np. aktualizacja wyjść analogowych)
|
||||
#endif
|
||||
double iter =
|
||||
ceil(fTimeBuffer / fMaxDt); // ile kroków się zmieściło od ostatniego sprawdzania?
|
||||
int n = int(iter); // ile kroków jako int
|
||||
@@ -1049,6 +1054,18 @@ bool TWorld::Update()
|
||||
|
||||
Ground.Update_Lights();
|
||||
|
||||
{
|
||||
glm::dmat4 cam_matrix;
|
||||
Camera.SetMatrix(cam_matrix);
|
||||
|
||||
glm::vec3 pos(Camera.Pos.x, Camera.Pos.y, Camera.Pos.z);
|
||||
glm::vec3 at = glm::vec3(0.0, 0.0, -1.0) * glm::mat3(cam_matrix);
|
||||
glm::vec3 up = glm::vec3(0.0, 1.0, 0.0) * glm::mat3(cam_matrix);
|
||||
|
||||
sound_man->set_listener(pos, at, up);
|
||||
sound_man->update(dt);
|
||||
}
|
||||
|
||||
// render time routines follow:
|
||||
|
||||
dt = Timer::GetDeltaRenderTime(); // nie uwzględnia pauzowania ani mnożenia czasu
|
||||
@@ -1057,7 +1074,9 @@ bool TWorld::Update()
|
||||
|
||||
fTime50Hz += dt; // w pauzie też trzeba zliczać czas, bo przy dużym FPS będzie problem z odczytem ramek
|
||||
while( fTime50Hz >= 1.0 / 50.0 ) {
|
||||
#ifdef _WIN32
|
||||
Console::Update(); // to i tak trzeba wywoływać
|
||||
#endif
|
||||
Update_UI();
|
||||
// decelerate camera
|
||||
Camera.Velocity *= 0.65;
|
||||
@@ -1569,12 +1588,8 @@ TWorld::Update_UI() {
|
||||
uitextline1 += " (slowmotion " + to_string( Global::iSlowMotion ) + ")";
|
||||
}
|
||||
|
||||
uitextline2 =
|
||||
std::string( "Rendering mode: " )
|
||||
+ ( Global::bUseVBO ?
|
||||
"VBO" :
|
||||
"Display Lists" )
|
||||
+ " ";
|
||||
|
||||
|
||||
// dump last opengl error, if any
|
||||
GLenum glerror = ::glGetError();
|
||||
if( glerror != GL_NO_ERROR ) {
|
||||
@@ -2154,7 +2169,7 @@ TWorld::ToggleDaylight() {
|
||||
|
||||
void
|
||||
world_environment::init() {
|
||||
|
||||
// m_skydome.init();
|
||||
m_sun.init();
|
||||
m_moon.init();
|
||||
m_stars.init();
|
||||
|
||||
7
World.h
7
World.h
@@ -18,7 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "moon.h"
|
||||
#include "stars.h"
|
||||
#include "skydome.h"
|
||||
#include "mczapkie/mover.h"
|
||||
#include "McZapkie/MOVER.h"
|
||||
|
||||
// wrapper for simulation time
|
||||
class simulation_time {
|
||||
@@ -60,6 +60,8 @@ extern simulation_time Time;
|
||||
|
||||
}
|
||||
|
||||
class opengl_renderer;
|
||||
|
||||
// wrapper for environment elements -- sky, sun, stars, clouds etc
|
||||
class world_environment {
|
||||
|
||||
@@ -119,7 +121,6 @@ private:
|
||||
|
||||
TCamera Camera;
|
||||
TCamera DebugCamera;
|
||||
TGround Ground;
|
||||
world_environment Environment;
|
||||
TTrain *Train;
|
||||
TDynamicObject *pDynamicNearest;
|
||||
@@ -144,6 +145,8 @@ private:
|
||||
void CabChange(TDynamicObject *old, TDynamicObject *now);
|
||||
// handles vehicle change flag
|
||||
void ChangeDynamic();
|
||||
|
||||
TGround Ground; //m7todo: tmp
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
42
appveyor.yml
Normal file
42
appveyor.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
version: '{build}'
|
||||
branches:
|
||||
except:
|
||||
- master
|
||||
- dp
|
||||
image: Visual Studio 2015
|
||||
clone_depth: 1
|
||||
build_script:
|
||||
- cmd: >-
|
||||
cd builds
|
||||
|
||||
cmake_win32.bat
|
||||
|
||||
cd build_win32
|
||||
|
||||
cmake --build . --config RelWithDebInfo
|
||||
|
||||
cd ..
|
||||
|
||||
cmake_win64.bat
|
||||
|
||||
cd build_win64
|
||||
|
||||
cmake --build . --config RelWithDebInfo
|
||||
|
||||
cd ..
|
||||
|
||||
7z a symbols.zip build_win32/RelWithDebInfo/eu07++ng.pdb build_win64/RelWithDebInfo/eu07++ng.pdb
|
||||
test: off
|
||||
deploy: off
|
||||
artifacts:
|
||||
- path: builds/build_win32/RelWithDebInfo/eu07++ng.exe
|
||||
name: release_win32
|
||||
- path: builds/build_win64/RelWithDebInfo/eu07++ng.exe
|
||||
name: release_win64
|
||||
- path: shaders
|
||||
name: shaders
|
||||
type: zip
|
||||
- path: builds/symbols.zip
|
||||
name: symbols
|
||||
cache:
|
||||
- builds/deps_win -> builds/download_windeps.bat
|
||||
21
builds/cmake_win32.bat
Normal file
21
builds/cmake_win32.bat
Normal file
@@ -0,0 +1,21 @@
|
||||
if not exist deps_win call %~dp0download_windeps.bat
|
||||
set DEPS_DIR="%cd%/deps_win"
|
||||
if not exist build_win32 mkdir build_win32
|
||||
pushd build_win32
|
||||
cmake ../.. -T v140_xp ^
|
||||
-DGLEW_INCLUDE_DIR=%DEPS_DIR%/glew-2.0.0/include ^
|
||||
-DGLEW_LIBRARY=%DEPS_DIR%/glew-2.0.0/lib/Release/Win32/glew32.lib ^
|
||||
-DGLFW3_ROOT_PATH=%DEPS_DIR%/glfw-3.2.1.bin.WIN32 ^
|
||||
-DGLUT_INCLUDE_DIR=%DEPS_DIR%/freeglut/include ^
|
||||
-DGLUT_glut_LIBRARY=%DEPS_DIR%/freeglut/lib/freeglut.lib ^
|
||||
-DPNG_PNG_INCLUDE_DIR=%DEPS_DIR%/libpng/include ^
|
||||
-DPNG_LIBRARY=%DEPS_DIR%/libpng/lib/win32/libpng16.lib ^
|
||||
-DZLIB_INCLUDE_DIR=%DEPS_DIR%/zlib-1.2.11 ^
|
||||
-DGLM_ROOT_DIR=%DEPS_DIR%/glm-0.9.8.4 ^
|
||||
-DOPENAL_INCLUDE_DIR=%DEPS_DIR%/openal/include ^
|
||||
-DOPENAL_LIBRARY=%DEPS_DIR%/openal/lib/win32/OpenAL32.lib ^
|
||||
-DLIBSNDFILE_INCLUDE_DIR=%DEPS_DIR%/libsndfile/include ^
|
||||
-DLIBSNDFILE_LIBRARY=%DEPS_DIR%/libsndfile/lib/win32/libsndfile-1.lib ^
|
||||
-DLUAJIT_INCLUDE_DIR=%DEPS_DIR%/luajit/include ^
|
||||
-DLUAJIT_LIBRARIES=%DEPS_DIR%/luajit/lib/win32/lua51.lib
|
||||
popd
|
||||
21
builds/cmake_win64.bat
Normal file
21
builds/cmake_win64.bat
Normal file
@@ -0,0 +1,21 @@
|
||||
if not exist deps_win call %~dp0download_windeps.bat
|
||||
set DEPS_DIR="%cd%/deps_win"
|
||||
if not exist build_win64 mkdir build_win64
|
||||
pushd build_win64
|
||||
cmake ../.. -A x64 ^
|
||||
-DGLEW_INCLUDE_DIR=%DEPS_DIR%/glew-2.0.0/include ^
|
||||
-DGLEW_LIBRARY=%DEPS_DIR%/glew-2.0.0/lib/Release/x64/glew32.lib ^
|
||||
-DGLFW3_ROOT_PATH=%DEPS_DIR%/glfw-3.2.1.bin.WIN64 ^
|
||||
-DGLUT_INCLUDE_DIR=%DEPS_DIR%/freeglut/include ^
|
||||
-DGLUT_glut_LIBRARY=%DEPS_DIR%/freeglut/lib/x64/freeglut.lib ^
|
||||
-DPNG_PNG_INCLUDE_DIR=%DEPS_DIR%/libpng/include ^
|
||||
-DPNG_LIBRARY=%DEPS_DIR%/libpng/lib/win64/libpng16.lib ^
|
||||
-DZLIB_INCLUDE_DIR=%DEPS_DIR%/zlib-1.2.11 ^
|
||||
-DGLM_ROOT_DIR=%DEPS_DIR%/glm-0.9.8.4 ^
|
||||
-DOPENAL_INCLUDE_DIR=%DEPS_DIR%/openal/include ^
|
||||
-DOPENAL_LIBRARY=%DEPS_DIR%/openal/lib/win64/OpenAL32.lib ^
|
||||
-DLIBSNDFILE_INCLUDE_DIR=%DEPS_DIR%/libsndfile/include ^
|
||||
-DLIBSNDFILE_LIBRARY=%DEPS_DIR%/libsndfile/lib/win64/libsndfile-1.lib ^
|
||||
-DLUAJIT_INCLUDE_DIR=%DEPS_DIR%/luajit/include ^
|
||||
-DLUAJIT_LIBRARIES=%DEPS_DIR%/luajit/lib/win64/lua51.lib
|
||||
popd
|
||||
2
builds/download_windeps.bat
Normal file
2
builds/download_windeps.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
powershell "$wc = New-Object System.Net.WebClient; $wc.DownloadFile(\"https://milek7.pl/.stuff/eu07exe/builddep3.zip\", \"%cd%\deps_win.zip\")"
|
||||
powershell "$s = New-Object -ComObject shell.application; $z = $s.Namespace(\"%cd%\deps_win.zip\"); foreach ($i in $z.items()) { $s.Namespace(\"%cd%\").CopyHere($i) }"
|
||||
2
color.h
2
color.h
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "float3d.h"
|
||||
#include "Float3d.h"
|
||||
|
||||
inline
|
||||
glm::vec3
|
||||
|
||||
@@ -10,9 +10,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "command.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "logs.h"
|
||||
#include "timer.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace simulation {
|
||||
|
||||
|
||||
2
dumb3d.h
2
dumb3d.h
@@ -127,7 +127,7 @@ class matrix4x4
|
||||
public:
|
||||
matrix4x4(void)
|
||||
{
|
||||
::SecureZeroMemory( e, sizeof( e ) );
|
||||
memset(e, 0, sizeof(e));
|
||||
}
|
||||
|
||||
// When defining matrices in C arrays, it is easiest to define them with
|
||||
|
||||
@@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "float3d.h"
|
||||
#include "Float3d.h"
|
||||
#include "dumb3d.h"
|
||||
|
||||
std::vector<glm::vec4> const ndcfrustumshapepoints {
|
||||
|
||||
@@ -9,8 +9,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "gamepadinput.h"
|
||||
#include "logs.h"
|
||||
#include "timer.h"
|
||||
#include "Logs.h"
|
||||
#include "Timer.h"
|
||||
#include "usefull.h"
|
||||
|
||||
glm::vec2 circle_to_square( glm::vec2 const &Point, int const Roundness = 0 ) {
|
||||
@@ -40,7 +40,7 @@ glm::vec2 circle_to_square( glm::vec2 const &Point, int const Roundness = 0 ) {
|
||||
// Find the inner-roundness scaling factor and LERP
|
||||
auto const length = glm::length( Point );
|
||||
auto const factor = std::pow( length, Roundness );
|
||||
return interpolate( Point, squared, factor );
|
||||
return interpolate( Point, squared, (float)factor );
|
||||
}
|
||||
|
||||
gamepad_input::gamepad_input() {
|
||||
|
||||
@@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "geometry.h"
|
||||
|
||||
inline double sqr(double a)
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "keyboardinput.h"
|
||||
#include "logs.h"
|
||||
#include "Logs.h"
|
||||
#include "parser.h"
|
||||
#include "world.h"
|
||||
#include "World.h"
|
||||
|
||||
extern TWorld World;
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "lightarray.h"
|
||||
#include "dynobj.h"
|
||||
#include "driver.h"
|
||||
#include "DynObj.h"
|
||||
#include "Driver.h"
|
||||
|
||||
void
|
||||
light_array::insert( TDynamicObject const *Owner ) {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include <vector>
|
||||
#include "dumb3d.h"
|
||||
#include "float3d.h"
|
||||
#include "dynobj.h"
|
||||
#include "Float3d.h"
|
||||
#include "DynObj.h"
|
||||
|
||||
// collection of virtual light sources present in the scene
|
||||
// used by the renderer to determine most suitable placement for actual light sources during render
|
||||
|
||||
176
lua.cpp
Normal file
176
lua.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
#include "stdafx.h"
|
||||
#include "lua.h"
|
||||
#include "Event.h"
|
||||
#include "Logs.h"
|
||||
#include "MemCell.h"
|
||||
#include "World.h"
|
||||
#include "Driver.h"
|
||||
#include "lua_ffi.h"
|
||||
|
||||
extern TWorld World;
|
||||
|
||||
lua::lua()
|
||||
{
|
||||
state = luaL_newstate();
|
||||
if (!state)
|
||||
throw std::runtime_error("cannot create lua state");
|
||||
lua_atpanic(state, atpanic);
|
||||
luaL_openlibs(state);
|
||||
|
||||
lua_getglobal(state, "package");
|
||||
lua_pushstring(state, "preload");
|
||||
lua_gettable(state, -2);
|
||||
lua_pushcclosure(state, openffi, 0);
|
||||
lua_setfield(state, -2, "eu07.events");
|
||||
lua_settop(state, 0);
|
||||
}
|
||||
|
||||
lua::~lua()
|
||||
{
|
||||
lua_close(state);
|
||||
state = nullptr;
|
||||
}
|
||||
|
||||
void lua::interpret(std::string file)
|
||||
{
|
||||
if (luaL_dofile(state, file.c_str()))
|
||||
throw std::runtime_error(lua_tostring(state, -1));
|
||||
}
|
||||
|
||||
// NOTE: we cannot throw exceptions in callbacks
|
||||
// because it is not supported by LuaJIT on x86 windows
|
||||
|
||||
int lua::atpanic(lua_State *s)
|
||||
{
|
||||
ErrorLog(std::string(lua_tostring(s, -1)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua::openffi(lua_State *s)
|
||||
{
|
||||
if (luaL_dostring(s, lua_ffi))
|
||||
{
|
||||
ErrorLog(std::string(lua_tostring(s, -1)));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
EXPORT TEvent* scriptapi_event_create(const char* name, lua::eventhandler_t handler, double delay)
|
||||
{
|
||||
TEvent *event = new TEvent();
|
||||
event->bEnabled = true;
|
||||
event->Type = tp_Lua;
|
||||
event->asName = std::string(name);
|
||||
event->fDelay = delay;
|
||||
event->Params[0].asPointer = (void*)handler;
|
||||
World.Ground.add_event(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
EXPORT TEvent* scriptapi_event_find(const char* name)
|
||||
{
|
||||
std::string str(name);
|
||||
TEvent *e = World.Ground.FindEvent(str);
|
||||
if (e)
|
||||
return e;
|
||||
else
|
||||
WriteLog("missing event: " + str);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EXPORT TTrack* scriptapi_track_find(const char* name)
|
||||
{
|
||||
std::string str(name);
|
||||
TGroundNode *n = World.Ground.FindGroundNode(str, TP_TRACK);
|
||||
if (n)
|
||||
return n->pTrack;
|
||||
else
|
||||
WriteLog("missing track: " + str);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EXPORT bool scriptapi_track_isoccupied(TTrack* track)
|
||||
{
|
||||
if (track)
|
||||
return !track->IsEmpty();
|
||||
return false;
|
||||
}
|
||||
|
||||
EXPORT const char* scriptapi_event_getname(TEvent *e)
|
||||
{
|
||||
if (e)
|
||||
return e->asName.c_str();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EXPORT const char* scriptapi_train_getname(TDynamicObject *dyn)
|
||||
{
|
||||
if (dyn && dyn->Mechanik)
|
||||
return dyn->Mechanik->TrainName().c_str();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EXPORT void scriptapi_event_dispatch(TEvent *e, TDynamicObject *activator)
|
||||
{
|
||||
if (e)
|
||||
World.Ground.AddToQuery(e, activator);
|
||||
}
|
||||
|
||||
EXPORT double scriptapi_random(double a, double b)
|
||||
{
|
||||
return Random(a, b);
|
||||
}
|
||||
|
||||
EXPORT void scriptapi_writelog(const char* txt)
|
||||
{
|
||||
WriteLog("lua log: " + std::string(txt));
|
||||
}
|
||||
|
||||
struct memcell_values { const char *str; double num1; double num2; };
|
||||
|
||||
EXPORT TMemCell* scriptapi_memcell_find(const char *name)
|
||||
{
|
||||
std::string str(name);
|
||||
TGroundNode *n = World.Ground.FindGroundNode(str, TP_MEMCELL);
|
||||
if (n)
|
||||
return n->MemCell;
|
||||
else
|
||||
WriteLog("missing memcell: " + str);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EXPORT memcell_values scriptapi_memcell_read(TMemCell *mc)
|
||||
{
|
||||
if (!mc)
|
||||
return { nullptr, 0.0, 0.0 };
|
||||
return { mc->Text().c_str(), mc->Value1(), mc->Value2() };
|
||||
}
|
||||
|
||||
EXPORT void scriptapi_memcell_update(TMemCell *mc, const char *str, double num1, double num2)
|
||||
{
|
||||
if (!mc)
|
||||
return;
|
||||
mc->UpdateValues(std::string(str), num1, num2,
|
||||
update_memstring | update_memval1 | update_memval2);
|
||||
}
|
||||
|
||||
EXPORT void scriptapi_dynobj_putvalues(TDynamicObject *dyn, const char *str, double num1, double num2)
|
||||
{
|
||||
if (!dyn)
|
||||
return;
|
||||
TLocation loc;
|
||||
if (dyn->Mechanik)
|
||||
dyn->Mechanik->PutCommand(std::string(str), num1, num2, nullptr);
|
||||
else
|
||||
dyn->MoverParameters->PutCommand(std::string(str), num1, num2, loc);
|
||||
}
|
||||
}
|
||||
21
lua.h
Normal file
21
lua.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <lua.hpp>
|
||||
|
||||
class TEvent;
|
||||
class TDynamicObject;
|
||||
|
||||
class lua
|
||||
{
|
||||
lua_State *state;
|
||||
|
||||
static int atpanic(lua_State *s);
|
||||
static int openffi(lua_State *s);
|
||||
|
||||
public:
|
||||
lua();
|
||||
~lua();
|
||||
|
||||
void interpret(std::string file);
|
||||
|
||||
typedef void (*eventhandler_t)(TEvent*, TDynamicObject*);
|
||||
};
|
||||
78
lua_ffi.h
Normal file
78
lua_ffi.h
Normal file
@@ -0,0 +1,78 @@
|
||||
const char lua_ffi[] = "local ffi = require(\"ffi\")\n"
|
||||
"ffi.cdef[[\n"
|
||||
"struct memcell_values { const char *str; double num1; double num2; };\n"
|
||||
"\n"
|
||||
"typedef struct TEvent TEvent;\n"
|
||||
"typedef struct TTrack TTrack;\n"
|
||||
"typedef struct TDynamicObject TDynamicObject;\n"
|
||||
"typedef struct TMemCell TMemCell;\n"
|
||||
"typedef struct memcell_values memcell_values;\n"
|
||||
"\n"
|
||||
"TEvent* scriptapi_event_create(const char* name, void (*handler)(TEvent*, TDynamicObject*), double delay);\n"
|
||||
"TEvent* scriptapi_event_find(const char* name);\n"
|
||||
"const char* scriptapi_event_getname(TEvent *e);\n"
|
||||
"void scriptapi_event_dispatch(TEvent *e, TDynamicObject *activator);\n"
|
||||
"\n"
|
||||
"TTrack* scriptapi_track_find(const char* name);\n"
|
||||
"bool scriptapi_track_isoccupied(TTrack *track);\n"
|
||||
"\n"
|
||||
"const char* scriptapi_train_getname(TDynamicObject *dyn);\n"
|
||||
"void scriptapi_dynobj_putvalues(TDynamicObject *dyn, const char *str, double num1, double num2);\n"
|
||||
"\n"
|
||||
"TMemCell* scriptapi_memcell_find(const char *name);\n"
|
||||
"memcell_values scriptapi_memcell_read(TMemCell *mc);\n"
|
||||
"void scriptapi_memcell_update(TMemCell *mc, const char *str, double num1, double num2);\n"
|
||||
"\n"
|
||||
"double scriptapi_random(double a, double b);\n"
|
||||
"void scriptapi_writelog(const char* txt);\n"
|
||||
"]]\n"
|
||||
"\n"
|
||||
"local ns = ffi.C\n"
|
||||
"\n"
|
||||
"local module = {}\n"
|
||||
"\n"
|
||||
"module.event_create = ns.scriptapi_event_create\n"
|
||||
"module.event_find = ns.scriptapi_event_find\n"
|
||||
"function module.event_getname(a)\n"
|
||||
" return ffi.string(ns.scriptapi_event_getname(a))\n"
|
||||
"end\n"
|
||||
"module.event_dispatch = ns.scriptapi_event_dispatch\n"
|
||||
"function module.event_dispatch_n(a, b)\n"
|
||||
" ns.scriptapi_event_dispatch(ns.scriptapi_event_find(a), b)\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"module.track_find = ns.scriptapi_track_find\n"
|
||||
"module.track_isoccupied = ns.scriptapi_track_isoccupied\n"
|
||||
"function module.track_isoccupied_n(a)\n"
|
||||
" return ns.scriptapi_track_isoccupied(ns.scriptapi_track_find(a))\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"function module.train_getname(a)\n"
|
||||
" return ffi.string(ns.scriptapi_train_getname(a))\n"
|
||||
"end\n"
|
||||
"function module.dynobj_putvalues(a, b)\n"
|
||||
" ns.scriptapi_dynobj_putvalues(a, b.str, b.num1, b.num2)\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"module.memcell_find = ns.scriptapi_memcell_find\n"
|
||||
"function module.memcell_read(a)\n"
|
||||
" native = ns.scriptapi_memcell_read(a)\n"
|
||||
" mc = { }\n"
|
||||
" mc.str = ffi.string(native.str)\n"
|
||||
" mc.num1 = native.num1\n"
|
||||
" mc.num2 = native.num2\n"
|
||||
" return mc\n"
|
||||
"end\n"
|
||||
"function module.memcell_read_n(a)\n"
|
||||
" return module.memcell_read(ns.scriptapi_memcell_find(a))\n"
|
||||
"end\n"
|
||||
"function module.memcell_update(a, b)\n"
|
||||
" ns.scriptapi_memcell_update(a, b.str, b.num1, b.num2)\n"
|
||||
"end\n"
|
||||
"function module.memcell_update_n(a, b)\n"
|
||||
" ns.scriptapi_memcell_update(ns.scriptapi_memcell_find(a), b.str, b.num1, b.num2)\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"module.random = ns.scriptapi_random\n"
|
||||
"module.writelog = ns.scriptapi_writelog\n"
|
||||
"\nreturn module\n";
|
||||
16
material.cpp
16
material.cpp
@@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "material.h"
|
||||
#include "renderer.h"
|
||||
#include "usefull.h"
|
||||
#include "globals.h"
|
||||
#include "Globals.h"
|
||||
|
||||
bool
|
||||
opengl_material::deserialize( cParser &Input, bool const Loadnow ) {
|
||||
@@ -71,13 +71,11 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
||||
}
|
||||
filename += ".mat";
|
||||
|
||||
for( char &c : filename ) {
|
||||
// change forward slashes to windows ones. NOTE: probably not strictly necessary, but eh
|
||||
c = ( c == '/' ? '\\' : c );
|
||||
}
|
||||
if( filename.find( '\\' ) == std::string::npos ) {
|
||||
std::replace(filename.begin(), filename.end(), '\\', '/'); // fix slashes
|
||||
|
||||
if( filename.find( '/' ) == std::string::npos ) {
|
||||
// jeśli bieżaca ścieżka do tekstur nie została dodana to dodajemy domyślną
|
||||
filename = szTexturePath + filename;
|
||||
filename = global_texture_path + filename;
|
||||
}
|
||||
|
||||
// try to locate requested material in the databank
|
||||
@@ -121,7 +119,7 @@ material_manager::find_in_databank( std::string const &Materialname ) const {
|
||||
return lookup->second;
|
||||
}
|
||||
// jeszcze próba z dodatkową ścieżką
|
||||
lookup = m_materialmappings.find( szTexturePath + Materialname );
|
||||
lookup = m_materialmappings.find( global_texture_path + Materialname );
|
||||
|
||||
return (
|
||||
lookup != m_materialmappings.end() ?
|
||||
@@ -136,7 +134,7 @@ material_manager::find_on_disk( std::string const &Materialname ) const {
|
||||
|
||||
return(
|
||||
FileExists( Materialname ) ? Materialname :
|
||||
FileExists( szTexturePath + Materialname ) ? szTexturePath + Materialname :
|
||||
FileExists( global_texture_path + Materialname ) ? global_texture_path + Materialname :
|
||||
"" );
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "texture.h"
|
||||
#include "Texture.h"
|
||||
#include "parser.h"
|
||||
|
||||
typedef int material_handle;
|
||||
|
||||
18
moon.cpp
18
moon.cpp
@@ -1,10 +1,10 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "moon.h"
|
||||
#include "globals.h"
|
||||
#include "Globals.h"
|
||||
#include "mtable.h"
|
||||
#include "usefull.h"
|
||||
#include "world.h"
|
||||
#include "World.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cSun -- class responsible for dynamic calculation of position and intensity of the Sun,
|
||||
@@ -15,9 +15,17 @@ cMoon::cMoon() {
|
||||
m_observer.press = 1013.0; // surface pressure, millibars
|
||||
m_observer.temp = 15.0; // ambient dry-bulb temperature, degrees C
|
||||
|
||||
TIME_ZONE_INFORMATION timezoneinfo; // TODO: timezone dependant on geographic location
|
||||
::GetTimeZoneInformation( &timezoneinfo );
|
||||
m_observer.timezone = -timezoneinfo.Bias / 60.0f;
|
||||
#ifdef _WIN32
|
||||
TIME_ZONE_INFORMATION timezoneinfo; // TODO: timezone dependant on geographic location
|
||||
::GetTimeZoneInformation( &timezoneinfo );
|
||||
m_observer.timezone = -timezoneinfo.Bias / 60.0f;
|
||||
#elif __linux__
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
time_t local = mktime(localtime(&ts.tv_sec));
|
||||
time_t utc = mktime(gmtime(&ts.tv_sec));
|
||||
m_observer.timezone = (local - utc) / 3600.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
cMoon::~cMoon() { gluDeleteQuadric( moonsphere ); }
|
||||
|
||||
3
moon.h
3
moon.h
@@ -1,9 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "windows.h"
|
||||
#include "GL/glew.h"
|
||||
#include "GL/wglew.h"
|
||||
|
||||
|
||||
// TODO: sun and moon share code as celestial bodies, we could make a base class out of it
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "mouseinput.h"
|
||||
#include "usefull.h"
|
||||
#include "globals.h"
|
||||
#include "timer.h"
|
||||
#include "world.h"
|
||||
#include "train.h"
|
||||
#include "Globals.h"
|
||||
#include "Timer.h"
|
||||
#include "World.h"
|
||||
#include "Train.h"
|
||||
#include "renderer.h"
|
||||
|
||||
extern TWorld World;
|
||||
|
||||
@@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "mtable.h"
|
||||
#include "mczapkie/mctools.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
|
||||
double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/
|
||||
// zwraca różnicę czasu
|
||||
@@ -241,6 +241,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
||||
ConversionError = 666;
|
||||
vActual = -1;
|
||||
s = scnpath + TrainName + ".txt";
|
||||
std::replace(s.begin(), s.end(), '\\', '/');
|
||||
// Ra 2014-09: ustalić zasady wyznaczenia pierwotnego pliku przy przesuniętych rozkładach
|
||||
// (kolejny pociąg dostaje numer +2)
|
||||
fin.open(s.c_str()); // otwieranie pliku
|
||||
|
||||
2
mtable.h
2
mtable.h
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "world.h"
|
||||
#include "World.h"
|
||||
|
||||
namespace Mtable
|
||||
{
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Classes.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma package(smart_init)
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
/*
|
||||
MaSzyna EU07 locomotive simulator
|
||||
Copyright (C) 2001-2004 Marcin Wozniak and others
|
||||
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "FadeSound.h"
|
||||
#include "Timer.h"
|
||||
|
||||
TFadeSound::~TFadeSound()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
void TFadeSound::Free()
|
||||
{
|
||||
}
|
||||
|
||||
void TFadeSound::Init(std::string const &Name, float fNewFade)
|
||||
{
|
||||
Sound = TSoundsManager::GetFromName(Name, false);
|
||||
if (Sound)
|
||||
Sound->SetVolume(0);
|
||||
fFade = fNewFade;
|
||||
fTime = 0;
|
||||
}
|
||||
|
||||
void TFadeSound::TurnOn()
|
||||
{
|
||||
State = ss_Starting;
|
||||
Sound->Play(0, 0, DSBPLAY_LOOPING);
|
||||
fTime = fFade;
|
||||
}
|
||||
|
||||
void TFadeSound::TurnOff()
|
||||
{
|
||||
State = ss_ShuttingDown;
|
||||
}
|
||||
|
||||
void TFadeSound::Update()
|
||||
{
|
||||
|
||||
if (State == ss_Starting)
|
||||
{
|
||||
fTime += Timer::GetDeltaTime();
|
||||
// SoundStart->SetVolume(-1000*(4-fTime)/4);
|
||||
if (fTime >= fFade)
|
||||
{
|
||||
fTime = fFade;
|
||||
State = ss_Commencing;
|
||||
Sound->SetVolume(-2000 * (fFade - fTime) / fFade);
|
||||
Sound->SetFrequency(44100 - 500 + 500 * (fTime) / fFade);
|
||||
}
|
||||
else if (Timer::GetSoundTimer())
|
||||
{
|
||||
Sound->SetVolume(-2000 * (fFade - fTime) / fFade);
|
||||
Sound->SetFrequency(44100 - 500 + 500 * (fTime) / fFade);
|
||||
}
|
||||
}
|
||||
else if (State == ss_ShuttingDown)
|
||||
{
|
||||
fTime -= Timer::GetDeltaTime();
|
||||
|
||||
if (fTime <= 0)
|
||||
{
|
||||
State = ss_Off;
|
||||
fTime = 0;
|
||||
Sound->Stop();
|
||||
}
|
||||
if (Timer::GetSoundTimer())
|
||||
{ // DSBVOLUME_MIN
|
||||
Sound->SetVolume(-2000 * (fFade - fTime) / fFade);
|
||||
Sound->SetFrequency(44100 - 500 + 500 * fTime / fFade);
|
||||
}
|
||||
}
|
||||
}
|
||||
void TFadeSound::Volume(long vol)
|
||||
{
|
||||
float glos = 1;
|
||||
Sound->SetVolume(vol * glos);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef FadeSoundH
|
||||
#define FadeSoundH
|
||||
|
||||
#include "Sound.h"
|
||||
#include "AdvSound.h"
|
||||
|
||||
class TFadeSound
|
||||
{
|
||||
PSound Sound = nullptr;
|
||||
float fFade = 0.0f;
|
||||
float dt = 0.0f,
|
||||
fTime = 0.0f;
|
||||
TSoundState State = ss_Off;
|
||||
|
||||
public:
|
||||
TFadeSound() = default;
|
||||
~TFadeSound();
|
||||
void Init(std::string const &Name, float fNewFade);
|
||||
void TurnOn();
|
||||
void TurnOff();
|
||||
bool Playing()
|
||||
{
|
||||
return (State == ss_Commencing || State == ss_Starting);
|
||||
};
|
||||
void Free();
|
||||
void Update();
|
||||
void Volume(long vol);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Forth.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma package(smart_init)
|
||||
|
||||
/* Ra: Forth jest prostym językiem programowania, funkcjonującym na dosyć
|
||||
niskim poziomie. Może być zarówno interpretowany jak i kompilowany, co
|
||||
pozwala szybko działać skompilowanym programom, jak również wykonywać
|
||||
polecenia wprowadzane z klawiatury. Za pomocą zdefiniowanych kompilatorów
|
||||
można definiować nowe funkcje, można również tworzyć nowe struktury jezyka,
|
||||
np. wykraczające poza dotychczasową składnię. Prostota i wydajność są okupione
|
||||
nieco specyficzną składnią, wynikającą z użycia stosu do obliczeń (tzw. odwrotna
|
||||
notacja polska).
|
||||
|
||||
Forth ma być używany jako:
|
||||
1. Alternatywna postać eventów. Dotychczasowe eventy w sceneriach mogą być
|
||||
traktowane jako funkcje języka Forth. Jednocześnie można uzyskać uelastycznienie
|
||||
składni, poprzez np. połączenie w jednym wpisie różnych typów eventów wraz z
|
||||
dodaniem warunków dostępnych tylko dla Multiple. Również można będzie używać
|
||||
wyrażeń języka Forth, czyli dokonywać obliczeń.
|
||||
2. Jako docelowa postać schematów obwodów Ladder Diagram. Można zrobić tak, by
|
||||
program źródłowy w Forth (przy pewnych ograniczeniach) był wyświetlany graficznie
|
||||
jako Ladder Diagram. Jednocześnie graficzne modyfikacje schematu można by
|
||||
przełożyć na postać tekstową Forth i skompilować na kod niskiego poziomu.
|
||||
3. Jako algorytm funkcjonowania AI, możliwy do zaprogramowania na zewnątzr EXE.
|
||||
Każdy użytkownik będzie mógł swój własny styl jazdy.
|
||||
4. Jako algorytm sterowania ruchem (zależności na stacji).
|
||||
5. Jako AI stacji, zarządzające ruchem na stacji zależnie w czasie rzeczywistym.
|
||||
|
||||
Względem pierwotnego języka Forth, użyty tutaj będzie miał pewne odstępstwa:
|
||||
1. Operacje na liczbach czterobajtowych float. Należy we własnym zakresie dbać
|
||||
o zgodność użytych funkcji z typem argumentu na stosie.
|
||||
2. Jedynym typem całkowitym jest czterobajtowy int.
|
||||
3. Do wyszukiwania obiektów w scenerii po nazwie (torów, eventów), używane jest
|
||||
drzewo zamiast listy.
|
||||
|
||||
Wpisy w scenerii, przetwarzane jako komendy Forth, nie mogą używać średnika jako
|
||||
separatora słów. Uniemożliwia to używanie średnika jako słowa.
|
||||
*/
|
||||
17
old/Forth.h
17
old/Forth.h
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef ForthH
|
||||
#define ForthH
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class Forth
|
||||
{ // klasa obsługi języka
|
||||
};
|
||||
#endif
|
||||
127
old/Geom.cpp
127
old/Geom.cpp
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "system.hpp"
|
||||
#include "classes.hpp"
|
||||
#include <gl/gl.h>
|
||||
#include <gl/glu.h>
|
||||
#include "GL/glut.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Texture.h"
|
||||
#include "usefull.h"
|
||||
#include "Globals.h"
|
||||
#include "Geom.h"
|
||||
|
||||
TGeometry::TGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
TGeometry::~TGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
bool TGeometry::Init()
|
||||
{
|
||||
}
|
||||
|
||||
vector3 TGeometry::Load(TQueryParserComp *Parser)
|
||||
{
|
||||
str = Parser->GetNextSymbol().LowerCase();
|
||||
tmp->TextureID = TTexturesManager::GetTextureID(str.c_str());
|
||||
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
tf = Parser->GetNextSymbol().ToDouble();
|
||||
TempVerts[i].Point.x = tf;
|
||||
tf = Parser->GetNextSymbol().ToDouble();
|
||||
TempVerts[i].Point.y = tf;
|
||||
tf = Parser->GetNextSymbol().ToDouble();
|
||||
TempVerts[i].Point.z = tf;
|
||||
tf = Parser->GetNextSymbol().ToDouble();
|
||||
TempVerts[i].Normal.x = tf;
|
||||
tf = Parser->GetNextSymbol().ToDouble();
|
||||
TempVerts[i].Normal.y = tf;
|
||||
tf = Parser->GetNextSymbol().ToDouble();
|
||||
TempVerts[i].Normal.z = tf;
|
||||
|
||||
str = Parser->GetNextSymbol().LowerCase();
|
||||
if (str == "x")
|
||||
TempVerts[i].tu = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) /
|
||||
Parser->GetNextSymbol().ToDouble();
|
||||
else if (str == "y")
|
||||
TempVerts[i].tu = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) /
|
||||
Parser->GetNextSymbol().ToDouble();
|
||||
else if (str == "z")
|
||||
TempVerts[i].tu = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) /
|
||||
Parser->GetNextSymbol().ToDouble();
|
||||
else
|
||||
TempVerts[i].tu = str.ToDouble();
|
||||
;
|
||||
|
||||
str = Parser->GetNextSymbol().LowerCase();
|
||||
if (str == "x")
|
||||
TempVerts[i].tv = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) /
|
||||
Parser->GetNextSymbol().ToDouble();
|
||||
else if (str == "y")
|
||||
TempVerts[i].tv = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) /
|
||||
Parser->GetNextSymbol().ToDouble();
|
||||
else if (str == "z")
|
||||
TempVerts[i].tv = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) /
|
||||
Parser->GetNextSymbol().ToDouble();
|
||||
else
|
||||
TempVerts[i].tv = str.ToDouble();
|
||||
;
|
||||
|
||||
// tf= Parser->GetNextSymbol().ToDouble();
|
||||
// TempVerts[i].tu= tf;
|
||||
// tf= Parser->GetNextSymbol().ToDouble();
|
||||
// TempVerts[i].tv= tf;
|
||||
|
||||
TempVerts[i].Point.RotateZ(aRotate.z / 180 * M_PI);
|
||||
TempVerts[i].Point.RotateX(aRotate.x / 180 * M_PI);
|
||||
TempVerts[i].Point.RotateY(aRotate.y / 180 * M_PI);
|
||||
TempVerts[i].Normal.RotateZ(aRotate.z / 180 * M_PI);
|
||||
TempVerts[i].Normal.RotateX(aRotate.x / 180 * M_PI);
|
||||
TempVerts[i].Normal.RotateY(aRotate.y / 180 * M_PI);
|
||||
|
||||
TempVerts[i].Point += pOrigin;
|
||||
tmp->pCenter += TempVerts[i].Point;
|
||||
|
||||
i++;
|
||||
|
||||
// }
|
||||
} while (Parser->GetNextSymbol().LowerCase() != "endtri");
|
||||
|
||||
nv = i;
|
||||
tmp->Init(nv);
|
||||
tmp->pCenter /= (nv > 0 ? nv : 1);
|
||||
|
||||
// memcpy(tmp->Vertices,TempVerts,nv*sizeof(TGroundVertex));
|
||||
|
||||
r = 0;
|
||||
for (int i = 0; i < nv; i++)
|
||||
{
|
||||
tmp->Vertices[i] = TempVerts[i];
|
||||
tf = SquareMagnitude(tmp->Vertices[i].Point - tmp->pCenter);
|
||||
if (tf > r)
|
||||
r = tf;
|
||||
}
|
||||
|
||||
// tmp->fSquareRadius= 2000*2000+r;
|
||||
tmp->fSquareRadius += r;
|
||||
}
|
||||
|
||||
bool TGeometry::Render()
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma package(smart_init)
|
||||
46
old/Geom.h
46
old/Geom.h
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef GeomH
|
||||
#define GeomH
|
||||
|
||||
#include <gl/gl.h>
|
||||
#include "QueryParserComp.hpp"
|
||||
|
||||
struct TGeomVertex
|
||||
{
|
||||
vector3 Point;
|
||||
vector3 Normal;
|
||||
double tu, tv;
|
||||
};
|
||||
|
||||
class TGeometry
|
||||
{
|
||||
private:
|
||||
GLuint iType;
|
||||
union
|
||||
{
|
||||
int iNumVerts;
|
||||
int iNumPts;
|
||||
};
|
||||
GLuint TextureID;
|
||||
TMaterialColor Ambient;
|
||||
TMaterialColor Diffuse;
|
||||
TMaterialColor Specular;
|
||||
|
||||
public:
|
||||
TGeometry();
|
||||
~TGeometry();
|
||||
bool Init();
|
||||
vector3 Load(TQueryParserComp *Parser);
|
||||
bool Render();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
906
old/Mover.hpp
906
old/Mover.hpp
@@ -1,906 +0,0 @@
|
||||
// Borland C++ Builder
|
||||
// Copyright (c) 1995, 1999 by Borland International
|
||||
// All rights reserved
|
||||
|
||||
// (DO NOT EDIT: machine generated header) '_mover.pas' rev: 5.00
|
||||
//Ra: eee... tam, sam si<73> generuje b<><62>dnie i trzeba r<>cznie poprawia<69>!
|
||||
|
||||
#ifndef _moverHPP
|
||||
#define _moverHPP
|
||||
|
||||
#pragma delphiheader begin
|
||||
#pragma option push -w-
|
||||
#pragma option push -Vx
|
||||
#include "Oerlikon_ESt.h" // Pascal unit
|
||||
#include "hamulce.h" // Pascal unit
|
||||
#include <SysUtils.hpp> // Pascal unit
|
||||
#include <mctools.hpp> // Pascal unit
|
||||
#include <SysInit.hpp> // Pascal unit
|
||||
#include <System.hpp> // Pascal unit
|
||||
|
||||
//-- user supplied -----------------------------------------------------------
|
||||
|
||||
namespace _mover
|
||||
{
|
||||
//-- type declarations -------------------------------------------------------
|
||||
struct TLocation
|
||||
{
|
||||
double X;
|
||||
double Y;
|
||||
double Z;
|
||||
} ;
|
||||
|
||||
struct TRotation
|
||||
{
|
||||
double Rx;
|
||||
double Ry;
|
||||
double Rz;
|
||||
} ;
|
||||
|
||||
struct TDimension
|
||||
{
|
||||
double W;
|
||||
double L;
|
||||
double H;
|
||||
} ;
|
||||
|
||||
struct TCommand
|
||||
{
|
||||
AnsiString Command;
|
||||
double Value1;
|
||||
double Value2;
|
||||
TLocation Location;
|
||||
} ;
|
||||
|
||||
struct TTrackShape
|
||||
{
|
||||
double R;
|
||||
double Len;
|
||||
double dHtrack;
|
||||
double dHrail;
|
||||
} ;
|
||||
|
||||
struct TTrackParam
|
||||
{
|
||||
double Width;
|
||||
double friction;
|
||||
Byte CategoryFlag;
|
||||
Byte QualityFlag;
|
||||
Byte DamageFlag;
|
||||
double Velmax;
|
||||
} ;
|
||||
|
||||
struct TTractionParam
|
||||
{
|
||||
double TractionVoltage;
|
||||
double TractionFreq;
|
||||
double TractionMaxCurrent;
|
||||
double TractionResistivity;
|
||||
} ;
|
||||
|
||||
#pragma option push -b-
|
||||
enum TBrakeSystem { Individual, Pneumatic, ElectroPneumatic };
|
||||
#pragma option pop
|
||||
|
||||
#pragma option push -b-
|
||||
enum TBrakeSubSystem { ss_None, ss_W, ss_K, ss_KK, ss_Hik, ss_ESt, ss_KE, ss_LSt, ss_MT, ss_Dako };
|
||||
#pragma option pop
|
||||
|
||||
#pragma option push -b-
|
||||
enum TBrakeValve { NoValve, W, W_Lu_VI, W_Lu_L, W_Lu_XR, K, Kg, Kp, Kss, Kkg, Kkp, Kks, Hikg1, Hikss,
|
||||
Hikp1, KE, SW, EStED, NESt3, ESt3, LSt, ESt4, ESt3AL2, EP1, EP2, M483, CV1_L_TR, CV1, CV1_R, Other
|
||||
};
|
||||
#pragma option pop
|
||||
|
||||
#pragma option push -b-
|
||||
enum TBrakeHandle {
|
||||
NoHandle, West, FV4a, M394, M254, FVel1, FVel6, D2, Knorr, FD1, BS2, testH, St113,
|
||||
MHZ_P, MHZ_T, MHZ_EN57 };
|
||||
#pragma option pop
|
||||
|
||||
#pragma option push -b-
|
||||
enum TLocalBrake { NoBrake, ManualBrake, PneumaticBrake, HydraulicBrake };
|
||||
#pragma option pop
|
||||
|
||||
typedef double TBrakeDelayTable[4];
|
||||
|
||||
struct TBrakePressure
|
||||
{
|
||||
double PipePressureVal;
|
||||
double BrakePressureVal;
|
||||
double FlowSpeedVal;
|
||||
TBrakeSystem BrakeType;
|
||||
} ;
|
||||
|
||||
typedef TBrakePressure TBrakePressureTable[13];
|
||||
|
||||
#pragma option push -b-
|
||||
enum TEngineTypes { None, Dumb, WheelsDriven, ElectricSeriesMotor, ElectricInductionMotor, DieselEngine,
|
||||
SteamEngine, DieselElectric };
|
||||
#pragma option pop
|
||||
|
||||
#pragma option push -b-
|
||||
enum TPowerType { NoPower, BioPower, MechPower, ElectricPower, SteamPower };
|
||||
#pragma option pop
|
||||
|
||||
#pragma option push -b-
|
||||
enum TFuelType { Undefined, Coal, Oil };
|
||||
#pragma option pop
|
||||
|
||||
struct TGrateType
|
||||
{
|
||||
TFuelType FuelType;
|
||||
double GrateSurface;
|
||||
double FuelTransportSpeed;
|
||||
double IgnitionTemperature;
|
||||
double MaxTemperature;
|
||||
} ;
|
||||
|
||||
struct TBoilerType
|
||||
{
|
||||
double BoilerVolume;
|
||||
double BoilerHeatSurface;
|
||||
double SuperHeaterSurface;
|
||||
double MaxWaterVolume;
|
||||
double MinWaterVolume;
|
||||
double MaxPressure;
|
||||
} ;
|
||||
|
||||
struct TCurrentCollector
|
||||
{
|
||||
int CollectorsNo;
|
||||
double MinH;
|
||||
double MaxH;
|
||||
double CSW;
|
||||
double MinV;
|
||||
double MaxV;
|
||||
double OVP;
|
||||
double InsetV;
|
||||
double MinPress;
|
||||
double MaxPress;
|
||||
} ;
|
||||
|
||||
#pragma option push -b-
|
||||
enum TPowerSource { NotDefined, InternalSource, Transducer, Generator, Accumulator, CurrentCollector,
|
||||
PowerCable, Heater };
|
||||
#pragma option pop
|
||||
|
||||
struct _mover__1
|
||||
{
|
||||
double MaxCapacity;
|
||||
TPowerSource RechargeSource;
|
||||
} ;
|
||||
|
||||
struct _mover__2
|
||||
{
|
||||
TPowerType PowerTrans;
|
||||
double SteamPressure;
|
||||
} ;
|
||||
|
||||
struct _mover__3
|
||||
{
|
||||
TGrateType Grate;
|
||||
TBoilerType Boiler;
|
||||
} ;
|
||||
|
||||
struct TPowerParameters
|
||||
{
|
||||
double MaxVoltage;
|
||||
double MaxCurrent;
|
||||
double IntR;
|
||||
TPowerSource SourceType;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
_mover__3 RHeater;
|
||||
|
||||
};
|
||||
struct
|
||||
{
|
||||
_mover__2 RPowerCable;
|
||||
|
||||
};
|
||||
struct
|
||||
{
|
||||
TCurrentCollector CollectorParameters;
|
||||
|
||||
};
|
||||
struct
|
||||
{
|
||||
_mover__1 RAccumulator;
|
||||
|
||||
};
|
||||
struct
|
||||
{
|
||||
TEngineTypes GeneratorEngine;
|
||||
|
||||
};
|
||||
struct
|
||||
{
|
||||
double InputVoltage;
|
||||
|
||||
};
|
||||
struct
|
||||
{
|
||||
TPowerType PowerType;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
} ;
|
||||
|
||||
struct TScheme
|
||||
{
|
||||
Byte Relay;
|
||||
double R;
|
||||
Byte Bn;
|
||||
Byte Mn;
|
||||
bool AutoSwitch;
|
||||
Byte ScndAct;
|
||||
} ;
|
||||
|
||||
typedef TScheme TSchemeTable[65];
|
||||
|
||||
struct TDEScheme
|
||||
{
|
||||
double RPM;
|
||||
double GenPower;
|
||||
double Umax;
|
||||
double Imax;
|
||||
} ;
|
||||
|
||||
typedef TDEScheme TDESchemeTable[33];
|
||||
|
||||
struct TShuntScheme
|
||||
{
|
||||
double Umin;
|
||||
double Umax;
|
||||
double Pmin;
|
||||
double Pmax;
|
||||
} ;
|
||||
|
||||
typedef TShuntScheme TShuntSchemeTable[33];
|
||||
|
||||
struct TMPTRelay
|
||||
{
|
||||
double Iup;
|
||||
double Idown;
|
||||
} ;
|
||||
|
||||
typedef TMPTRelay TMPTRelayTable[8];
|
||||
|
||||
struct TMotorParameters
|
||||
{
|
||||
double mfi;
|
||||
double mIsat;
|
||||
double mfi0;
|
||||
double fi;
|
||||
double Isat;
|
||||
double fi0;
|
||||
bool AutoSwitch;
|
||||
} ;
|
||||
|
||||
struct TSecuritySystem
|
||||
{
|
||||
Byte SystemType;
|
||||
double AwareDelay;
|
||||
double AwareMinSpeed;
|
||||
double SoundSignalDelay;
|
||||
double EmergencyBrakeDelay;
|
||||
Byte Status;
|
||||
double SystemTimer;
|
||||
double SystemSoundCATimer;
|
||||
double SystemSoundSHPTimer;
|
||||
double SystemBrakeCATimer;
|
||||
double SystemBrakeSHPTimer;
|
||||
double SystemBrakeCATestTimer;
|
||||
int VelocityAllowed;
|
||||
int NextVelocityAllowed;
|
||||
bool RadioStop;
|
||||
} ;
|
||||
|
||||
struct TTransmision
|
||||
{
|
||||
Byte NToothM;
|
||||
Byte NToothW;
|
||||
double Ratio;
|
||||
} ;
|
||||
|
||||
#pragma option push -b-
|
||||
enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic };
|
||||
#pragma option pop
|
||||
|
||||
class DELPHICLASS T_MoverParameters;
|
||||
struct TCoupling
|
||||
{
|
||||
double SpringKB;
|
||||
double SpringKC;
|
||||
double beta;
|
||||
double DmaxB;
|
||||
double FmaxB;
|
||||
double DmaxC;
|
||||
double FmaxC;
|
||||
TCouplerType CouplerType;
|
||||
Byte CouplingFlag;
|
||||
int AllowedFlag;
|
||||
bool Render;
|
||||
double CoupleDist;
|
||||
T_MoverParameters* Connected;
|
||||
Byte ConnectedNr;
|
||||
double CForce;
|
||||
double Dist;
|
||||
bool CheckCollision;
|
||||
} ;
|
||||
|
||||
class PASCALIMPLEMENTATION T_MoverParameters : public System::TObject
|
||||
{
|
||||
typedef System::TObject inherited;
|
||||
|
||||
public:
|
||||
double dMoveLen;
|
||||
AnsiString filename;
|
||||
Byte CategoryFlag;
|
||||
AnsiString TypeName;
|
||||
int TrainType;
|
||||
TEngineTypes EngineType;
|
||||
TPowerParameters EnginePowerSource;
|
||||
TPowerParameters SystemPowerSource;
|
||||
TPowerParameters HeatingPowerSource;
|
||||
TPowerParameters AlterHeatPowerSource;
|
||||
TPowerParameters LightPowerSource;
|
||||
TPowerParameters AlterLightPowerSource;
|
||||
double Vmax;
|
||||
double Mass;
|
||||
double Power;
|
||||
double Mred;
|
||||
double TotalMass;
|
||||
double HeatingPower;
|
||||
double LightPower;
|
||||
double BatteryVoltage;
|
||||
bool Battery;
|
||||
bool EpFuse;
|
||||
bool Signalling;
|
||||
bool DoorSignalling;
|
||||
bool Radio;
|
||||
double NominalBatteryVoltage;
|
||||
TDimension Dim;
|
||||
double Cx;
|
||||
double Floor;
|
||||
double WheelDiameter;
|
||||
double WheelDiameterL;
|
||||
double WheelDiameterT;
|
||||
double TrackW;
|
||||
double AxleInertialMoment;
|
||||
AnsiString AxleArangement;
|
||||
Byte NPoweredAxles;
|
||||
Byte NAxles;
|
||||
Byte BearingType;
|
||||
double ADist;
|
||||
double BDist;
|
||||
Byte NBpA;
|
||||
int SandCapacity;
|
||||
TBrakeSystem BrakeSystem;
|
||||
TBrakeSubSystem BrakeSubsystem;
|
||||
TBrakeValve BrakeValve;
|
||||
TBrakeHandle BrakeHandle;
|
||||
TBrakeHandle BrakeLocHandle;
|
||||
double MBPM;
|
||||
Hamulce::TBrake* Hamulec;
|
||||
Hamulce::THandle* Handle;
|
||||
Hamulce::THandle* LocHandle;
|
||||
Hamulce::TReservoir* Pipe;
|
||||
Hamulce::TReservoir* Pipe2;
|
||||
TLocalBrake LocalBrake;
|
||||
TBrakePressure BrakePressureTable[13];
|
||||
TBrakePressure BrakePressureActual;
|
||||
Byte ASBType;
|
||||
Byte TurboTest;
|
||||
double MaxBrakeForce;
|
||||
double MaxBrakePress[5];
|
||||
double P2FTrans;
|
||||
double TrackBrakeForce;
|
||||
Byte BrakeMethod;
|
||||
double HighPipePress;
|
||||
double LowPipePress;
|
||||
double DeltaPipePress;
|
||||
double CntrlPipePress;
|
||||
double BrakeVolume;
|
||||
double BrakeVVolume;
|
||||
double VeselVolume;
|
||||
int BrakeCylNo;
|
||||
double BrakeCylRadius;
|
||||
double BrakeCylDist;
|
||||
double BrakeCylMult[3];
|
||||
Byte LoadFlag;
|
||||
double BrakeCylSpring;
|
||||
double BrakeSlckAdj;
|
||||
double BrakeRigEff;
|
||||
double RapidMult;
|
||||
int BrakeValveSize;
|
||||
AnsiString BrakeValveParams;
|
||||
double Spg;
|
||||
double MinCompressor;
|
||||
double MaxCompressor;
|
||||
double CompressorSpeed;
|
||||
double BrakeDelay[4];
|
||||
Byte BrakeCtrlPosNo;
|
||||
Byte MainCtrlPosNo;
|
||||
Byte ScndCtrlPosNo;
|
||||
Byte LightsPosNo;
|
||||
Byte LightsDefPos;
|
||||
bool LightsWrap;
|
||||
Byte Lights[2][16];
|
||||
bool ScndInMain;
|
||||
bool MBrake;
|
||||
double StopBrakeDecc;
|
||||
TSecuritySystem SecuritySystem;
|
||||
TScheme RList[65];
|
||||
int RlistSize;
|
||||
TMotorParameters MotorParam[11];
|
||||
TTransmision Transmision;
|
||||
double NominalVoltage;
|
||||
double WindingRes;
|
||||
double u;
|
||||
double CircuitRes;
|
||||
int IminLo;
|
||||
int IminHi;
|
||||
int ImaxLo;
|
||||
int ImaxHi;
|
||||
double nmax;
|
||||
double InitialCtrlDelay;
|
||||
double CtrlDelay;
|
||||
double CtrlDownDelay;
|
||||
Byte FastSerialCircuit;
|
||||
Byte AutoRelayType;
|
||||
bool CoupledCtrl;
|
||||
bool IsCoupled;
|
||||
Byte DynamicBrakeType;
|
||||
Byte RVentType;
|
||||
double RVentnmax;
|
||||
double RVentCutOff;
|
||||
int CompressorPower;
|
||||
int SmallCompressorPower;
|
||||
bool Trafo;
|
||||
double dizel_Mmax;
|
||||
double dizel_nMmax;
|
||||
double dizel_Mnmax;
|
||||
double dizel_nmax;
|
||||
double dizel_nominalfill;
|
||||
double dizel_Mstand;
|
||||
double dizel_nmax_cutoff;
|
||||
double dizel_nmin;
|
||||
double dizel_minVelfullengage;
|
||||
double dizel_AIM;
|
||||
double dizel_engageDia;
|
||||
double dizel_engageMaxForce;
|
||||
double dizel_engagefriction;
|
||||
double AnPos;
|
||||
bool AnalogCtrl;
|
||||
bool AnMainCtrl;
|
||||
bool ShuntModeAllow;
|
||||
bool ShuntMode;
|
||||
bool Flat;
|
||||
double Vhyp;
|
||||
TDEScheme DElist[33];
|
||||
double Vadd;
|
||||
TMPTRelay MPTRelay[8];
|
||||
Byte RelayType;
|
||||
TShuntScheme SST[33];
|
||||
double PowerCorRatio;
|
||||
double Ftmax;
|
||||
double eimc[26];
|
||||
int MaxLoad;
|
||||
AnsiString LoadAccepted;
|
||||
AnsiString LoadQuantity;
|
||||
double OverLoadFactor;
|
||||
double LoadSpeed;
|
||||
double UnLoadSpeed;
|
||||
Byte DoorOpenCtrl;
|
||||
Byte DoorCloseCtrl;
|
||||
double DoorStayOpen;
|
||||
bool DoorClosureWarning;
|
||||
double DoorOpenSpeed;
|
||||
double DoorCloseSpeed;
|
||||
double DoorMaxShiftL;
|
||||
double DoorMaxShiftR;
|
||||
double DoorMaxPlugShift;
|
||||
Byte DoorOpenMethod;
|
||||
double PlatformSpeed;
|
||||
double PlatformMaxShift;
|
||||
Byte PlatformOpenMethod;
|
||||
bool ScndS;
|
||||
TLocation Loc;
|
||||
TRotation Rot;
|
||||
AnsiString Name;
|
||||
TCoupling Couplers[2];
|
||||
double HVCouplers[2][2];
|
||||
int ScanCounter;
|
||||
bool EventFlag;
|
||||
Byte SoundFlag;
|
||||
double DistCounter;
|
||||
double V;
|
||||
double Vel;
|
||||
double AccS;
|
||||
double AccN;
|
||||
double AccV;
|
||||
double nrot;
|
||||
double EnginePower;
|
||||
double dL;
|
||||
double Fb;
|
||||
double Ff;
|
||||
double FTrain;
|
||||
double FStand;
|
||||
double FTotal;
|
||||
double UnitBrakeForce;
|
||||
double Ntotal;
|
||||
bool SlippingWheels;
|
||||
bool SandDose;
|
||||
double Sand;
|
||||
double BrakeSlippingTimer;
|
||||
double dpBrake;
|
||||
double dpPipe;
|
||||
double dpMainValve;
|
||||
double dpLocalValve;
|
||||
double ScndPipePress;
|
||||
double BrakePress;
|
||||
double LocBrakePress;
|
||||
double PipeBrakePress;
|
||||
double PipePress;
|
||||
double EqvtPipePress;
|
||||
double Volume;
|
||||
double CompressedVolume;
|
||||
double PantVolume;
|
||||
double Compressor;
|
||||
bool CompressorFlag;
|
||||
bool PantCompFlag;
|
||||
bool CompressorAllow;
|
||||
bool ConverterFlag;
|
||||
bool ConverterAllow;
|
||||
int BrakeCtrlPos;
|
||||
double BrakeCtrlPosR;
|
||||
double BrakeCtrlPos2;
|
||||
Byte LocalBrakePos;
|
||||
Byte ManualBrakePos;
|
||||
double LocalBrakePosA;
|
||||
Byte BrakeStatus;
|
||||
bool EmergencyBrakeFlag;
|
||||
Byte BrakeDelayFlag;
|
||||
Byte BrakeDelays;
|
||||
Byte BrakeOpModeFlag;
|
||||
Byte BrakeOpModes;
|
||||
bool DynamicBrakeFlag;
|
||||
double LimPipePress;
|
||||
double ActFlowSpeed;
|
||||
Byte DamageFlag;
|
||||
Byte EngDmgFlag;
|
||||
Byte DerailReason;
|
||||
TCommand CommandIn;
|
||||
AnsiString CommandOut;
|
||||
AnsiString CommandLast;
|
||||
double ValueOut;
|
||||
TTrackShape RunningShape;
|
||||
TTrackParam RunningTrack;
|
||||
double OffsetTrackH;
|
||||
double OffsetTrackV;
|
||||
bool Mains;
|
||||
Byte MainCtrlPos;
|
||||
Byte ScndCtrlPos;
|
||||
Byte LightsPos;
|
||||
int ActiveDir;
|
||||
int CabNo;
|
||||
int DirAbsolute;
|
||||
int ActiveCab;
|
||||
double LastSwitchingTime;
|
||||
bool DepartureSignal;
|
||||
bool InsideConsist;
|
||||
TTractionParam RunningTraction;
|
||||
double enrot;
|
||||
double Im;
|
||||
double Itot;
|
||||
double IHeating;
|
||||
double ITraction;
|
||||
double TotalCurrent;
|
||||
double Mm;
|
||||
double Mw;
|
||||
double Fw;
|
||||
double Ft;
|
||||
int Imin;
|
||||
int Imax;
|
||||
double Voltage;
|
||||
Byte MainCtrlActualPos;
|
||||
Byte ScndCtrlActualPos;
|
||||
bool DelayCtrlFlag;
|
||||
double LastRelayTime;
|
||||
bool AutoRelayFlag;
|
||||
bool FuseFlag;
|
||||
bool ConvOvldFlag;
|
||||
bool StLinFlag;
|
||||
bool ResistorsFlag;
|
||||
double RventRot;
|
||||
bool UnBrake;
|
||||
double PantPress;
|
||||
bool s_CAtestebrake;
|
||||
double dizel_fill;
|
||||
double dizel_engagestate;
|
||||
double dizel_engage;
|
||||
double dizel_automaticgearstatus;
|
||||
bool dizel_enginestart;
|
||||
double dizel_engagedeltaomega;
|
||||
double eimv[21];
|
||||
double PulseForce;
|
||||
double PulseForceTimer;
|
||||
int PulseForceCount;
|
||||
double eAngle;
|
||||
int Load;
|
||||
AnsiString LoadType;
|
||||
Byte LoadStatus;
|
||||
double LastLoadChangeTime;
|
||||
bool DoorBlocked;
|
||||
bool DoorLeftOpened;
|
||||
bool DoorRightOpened;
|
||||
bool PantFrontUp;
|
||||
bool PantRearUp;
|
||||
bool PantFrontSP;
|
||||
bool PantRearSP;
|
||||
int PantFrontStart;
|
||||
int PantRearStart;
|
||||
double PantFrontVolt;
|
||||
double PantRearVolt;
|
||||
AnsiString PantSwitchType;
|
||||
AnsiString ConvSwitchType;
|
||||
bool Heating;
|
||||
int DoubleTr;
|
||||
bool PhysicActivation;
|
||||
double FrictConst1;
|
||||
double FrictConst2s;
|
||||
double FrictConst2d;
|
||||
double TotalMassxg;
|
||||
double __fastcall GetTrainsetVoltage(void);
|
||||
bool __fastcall Physic_ReActivation(void);
|
||||
double __fastcall LocalBrakeRatio(void);
|
||||
double __fastcall ManualBrakeRatio(void);
|
||||
double __fastcall PipeRatio(void);
|
||||
double __fastcall RealPipeRatio(void);
|
||||
double __fastcall BrakeVP(void);
|
||||
bool __fastcall DynamicBrakeSwitch(bool Switch);
|
||||
bool __fastcall SendCtrlBroadcast(AnsiString CtrlCommand, double ctrlvalue);
|
||||
bool __fastcall SendCtrlToNext(AnsiString CtrlCommand, double ctrlvalue, double dir);
|
||||
bool __fastcall CabActivisation(void);
|
||||
bool __fastcall CabDeactivisation(void);
|
||||
bool __fastcall IncMainCtrl(int CtrlSpeed);
|
||||
bool __fastcall DecMainCtrl(int CtrlSpeed);
|
||||
bool __fastcall IncScndCtrl(int CtrlSpeed);
|
||||
bool __fastcall DecScndCtrl(int CtrlSpeed);
|
||||
bool __fastcall AddPulseForce(int Multipler);
|
||||
bool __fastcall SandDoseOn(void);
|
||||
bool __fastcall SecuritySystemReset(void);
|
||||
void __fastcall SecuritySystemCheck(double dt);
|
||||
bool __fastcall BatterySwitch(bool State);
|
||||
bool __fastcall EpFuseSwitch(bool State);
|
||||
bool __fastcall IncBrakeLevelOld(void);
|
||||
bool __fastcall DecBrakeLevelOld(void);
|
||||
bool __fastcall IncLocalBrakeLevel(Byte CtrlSpeed);
|
||||
bool __fastcall DecLocalBrakeLevel(Byte CtrlSpeed);
|
||||
bool __fastcall IncLocalBrakeLevelFAST(void);
|
||||
bool __fastcall DecLocalBrakeLevelFAST(void);
|
||||
bool __fastcall IncManualBrakeLevel(Byte CtrlSpeed);
|
||||
bool __fastcall DecManualBrakeLevel(Byte CtrlSpeed);
|
||||
bool __fastcall EmergencyBrakeSwitch(bool Switch);
|
||||
bool __fastcall AntiSlippingBrake(void);
|
||||
bool __fastcall BrakeReleaser(Byte state);
|
||||
bool __fastcall SwitchEPBrake(Byte state);
|
||||
bool __fastcall AntiSlippingButton(void);
|
||||
bool __fastcall IncBrakePress(double &brake, double PressLimit, double dp);
|
||||
bool __fastcall DecBrakePress(double &brake, double PressLimit, double dp);
|
||||
bool __fastcall BrakeDelaySwitch(Byte BDS);
|
||||
bool __fastcall IncBrakeMult(void);
|
||||
bool __fastcall DecBrakeMult(void);
|
||||
void __fastcall UpdateBrakePressure(double dt);
|
||||
void __fastcall UpdatePipePressure(double dt);
|
||||
void __fastcall CompressorCheck(double dt);
|
||||
//void __fastcall UpdatePantVolume(double dt);
|
||||
void __fastcall UpdateScndPipePressure(double dt);
|
||||
void __fastcall UpdateBatteryVoltage(double dt);
|
||||
double __fastcall GetDVc(double dt);
|
||||
void __fastcall ComputeConstans(void);
|
||||
double __fastcall ComputeMass(void);
|
||||
double __fastcall Adhesive(double staticfriction);
|
||||
double __fastcall TractionForce(double dt);
|
||||
double __fastcall FrictionForce(double R, Byte TDamage);
|
||||
double __fastcall BrakeForce(const TTrackParam &Track);
|
||||
double __fastcall CouplerForce(Byte CouplerN, double dt);
|
||||
void __fastcall CollisionDetect(Byte CouplerN, double dt);
|
||||
double __fastcall ComputeRotatingWheel(double WForce, double dt, double n);
|
||||
bool __fastcall SetInternalCommand(AnsiString NewCommand, double NewValue1, double NewValue2);
|
||||
double __fastcall GetExternalCommand(AnsiString &Command);
|
||||
bool __fastcall RunCommand(AnsiString command, double CValue1, double CValue2);
|
||||
bool __fastcall RunInternalCommand(void);
|
||||
void __fastcall PutCommand(AnsiString NewCommand, double NewValue1, double NewValue2, const TLocation
|
||||
&NewLocation);
|
||||
bool __fastcall DirectionBackward(void);
|
||||
bool __fastcall MainSwitch(bool State);
|
||||
bool __fastcall ConverterSwitch(bool State);
|
||||
bool __fastcall CompressorSwitch(bool State);
|
||||
bool __fastcall FuseOn(void);
|
||||
bool __fastcall FuseFlagCheck(void);
|
||||
void __fastcall FuseOff(void);
|
||||
int __fastcall ShowCurrent(Byte AmpN);
|
||||
double __fastcall v2n(void);
|
||||
double __fastcall current(double n, double U);
|
||||
double __fastcall Momentum(double I);
|
||||
double __fastcall MomentumF(double I, double Iw, Byte SCP);
|
||||
bool __fastcall CutOffEngine(void);
|
||||
bool __fastcall MaxCurrentSwitch(bool State);
|
||||
bool __fastcall ResistorsFlagCheck(void);
|
||||
bool __fastcall MinCurrentSwitch(bool State);
|
||||
bool __fastcall AutoRelaySwitch(bool State);
|
||||
bool __fastcall AutoRelayCheck(void);
|
||||
bool __fastcall dizel_EngageSwitch(double state);
|
||||
bool __fastcall dizel_EngageChange(double dt);
|
||||
bool __fastcall dizel_AutoGearCheck(void);
|
||||
double __fastcall dizel_fillcheck(Byte mcp);
|
||||
double __fastcall dizel_Momentum(double dizel_fill, double n, double dt);
|
||||
bool __fastcall dizel_Update(double dt);
|
||||
bool __fastcall LoadingDone(double LSpeed, AnsiString LoadInit);
|
||||
void __fastcall ComputeTotalForce(double dt, double dt1, bool FullVer);
|
||||
double __fastcall ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track
|
||||
, TTractionParam &ElectricTraction, const TLocation &NewLoc, TRotation &NewRot);
|
||||
double __fastcall FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, const
|
||||
TLocation &NewLoc, TRotation &NewRot);
|
||||
bool __fastcall ChangeOffsetH(double DeltaOffset);
|
||||
__fastcall T_MoverParameters(double VelInitial, AnsiString TypeNameInit, AnsiString NameInit, int LoadInitial
|
||||
, AnsiString LoadTypeInitial, int Cab);
|
||||
bool __fastcall LoadChkFile(AnsiString chkpath);
|
||||
bool __fastcall CheckLocomotiveParameters(bool ReadyFlag, int Dir);
|
||||
AnsiString __fastcall EngineDescription(int what);
|
||||
bool __fastcall DoorLeft(bool State);
|
||||
bool __fastcall DoorRight(bool State);
|
||||
bool __fastcall DoorBlockedFlag(void);
|
||||
bool __fastcall PantFront(bool State);
|
||||
bool __fastcall PantRear(bool State);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Create */ inline __fastcall T_MoverParameters(void) : System::TObject() { }
|
||||
#pragma option pop
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~T_MoverParameters(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-- var, const, procedure ---------------------------------------------------
|
||||
static const bool Go = true;
|
||||
static const bool Hold = false;
|
||||
static const Shortint ResArraySize = 0x40;
|
||||
static const Shortint MotorParametersArraySize = 0xa;
|
||||
static const Shortint maxcc = 0x4;
|
||||
static const Shortint LocalBrakePosNo = 0xa;
|
||||
static const Shortint MainBrakeMaxPos = 0xa;
|
||||
static const Shortint ManualBrakePosNo = 0x14;
|
||||
static const Shortint LightsSwitchPosNo = 0x10;
|
||||
static const Shortint dtrack_railwear = 0x2;
|
||||
static const Shortint dtrack_freerail = 0x4;
|
||||
static const Shortint dtrack_thinrail = 0x8;
|
||||
static const Shortint dtrack_railbend = 0x10;
|
||||
static const Shortint dtrack_plants = 0x20;
|
||||
static const Shortint dtrack_nomove = 0x40;
|
||||
static const Byte dtrack_norail = 0x80;
|
||||
static const Shortint dtrain_thinwheel = 0x1;
|
||||
static const Shortint dtrain_loadshift = 0x1;
|
||||
static const Shortint dtrain_wheelwear = 0x2;
|
||||
static const Shortint dtrain_bearing = 0x4;
|
||||
static const Shortint dtrain_coupling = 0x8;
|
||||
static const Shortint dtrain_ventilator = 0x10;
|
||||
static const Shortint dtrain_loaddamage = 0x10;
|
||||
static const Shortint dtrain_engine = 0x20;
|
||||
static const Shortint dtrain_loaddestroyed = 0x20;
|
||||
static const Shortint dtrain_axle = 0x40;
|
||||
static const Byte dtrain_out = 0x80;
|
||||
#define p_elengproblem (1.000000E-02)
|
||||
#define p_elengdamage (1.000000E-01)
|
||||
#define p_coupldmg (2.000000E-02)
|
||||
#define p_derail (1.000000E-03)
|
||||
#define p_accn (1.000000E-01)
|
||||
#define p_slippdmg (1.000000E-03)
|
||||
static const Shortint ctrain_virtual = 0x0;
|
||||
static const Shortint ctrain_coupler = 0x1;
|
||||
static const Shortint ctrain_pneumatic = 0x2;
|
||||
static const Shortint ctrain_controll = 0x4;
|
||||
static const Shortint ctrain_power = 0x8;
|
||||
static const Shortint ctrain_passenger = 0x10;
|
||||
static const Shortint ctrain_scndpneumatic = 0x20;
|
||||
static const Shortint ctrain_heating = 0x40;
|
||||
static const Byte ctrain_depot = 0x80;
|
||||
static const Shortint dbrake_none = 0x0;
|
||||
static const Shortint dbrake_passive = 0x1;
|
||||
static const Shortint dbrake_switch = 0x2;
|
||||
static const Shortint dbrake_reversal = 0x4;
|
||||
static const Shortint dbrake_automatic = 0x8;
|
||||
static const Shortint s_waiting = 0x1;
|
||||
static const Shortint s_aware = 0x2;
|
||||
static const Shortint s_active = 0x4;
|
||||
static const Shortint s_CAalarm = 0x8;
|
||||
static const Shortint s_SHPalarm = 0x10;
|
||||
static const Shortint s_CAebrake = 0x20;
|
||||
static const Shortint s_SHPebrake = 0x40;
|
||||
static const Byte s_CAtest = 0x80;
|
||||
static const Shortint sound_none = 0x0;
|
||||
static const Shortint sound_loud = 0x1;
|
||||
static const Shortint sound_couplerstretch = 0x2;
|
||||
static const Shortint sound_bufferclamp = 0x4;
|
||||
static const Shortint sound_bufferbump = 0x8;
|
||||
static const Shortint sound_relay = 0x10;
|
||||
static const Shortint sound_manyrelay = 0x20;
|
||||
static const Shortint sound_brakeacc = 0x40;
|
||||
extern PACKAGE bool PhysicActivationFlag;
|
||||
static const Shortint dt_Default = 0x0;
|
||||
static const Shortint dt_EZT = 0x1;
|
||||
static const Shortint dt_ET41 = 0x2;
|
||||
static const Shortint dt_ET42 = 0x4;
|
||||
static const Shortint dt_PseudoDiesel = 0x8;
|
||||
static const Shortint dt_ET22 = 0x10;
|
||||
static const Shortint dt_SN61 = 0x20;
|
||||
static const Shortint dt_EP05 = 0x40;
|
||||
static const Byte dt_ET40 = 0x80;
|
||||
static const Word dt_181 = 0x100;
|
||||
static const Shortint eimc_s_dfic = 0x0;
|
||||
static const Shortint eimc_s_dfmax = 0x1;
|
||||
static const Shortint eimc_s_p = 0x2;
|
||||
static const Shortint eimc_s_cfu = 0x3;
|
||||
static const Shortint eimc_s_cim = 0x4;
|
||||
static const Shortint eimc_s_icif = 0x5;
|
||||
static const Shortint eimc_f_Uzmax = 0x7;
|
||||
static const Shortint eimc_f_uzh = 0x8;
|
||||
static const Shortint eimc_f_DU = 0x9;
|
||||
static const Shortint eimc_f_I0 = 0xa;
|
||||
static const Shortint eimc_f_cfu = 0xb;
|
||||
static const Shortint eimc_p_F0 = 0xd;
|
||||
static const Shortint eimc_p_a1 = 0xe;
|
||||
static const Shortint eimc_p_Pmax = 0xf;
|
||||
static const Shortint eimc_p_Fh = 0x10;
|
||||
static const Shortint eimc_p_Ph = 0x11;
|
||||
static const Shortint eimc_p_Vh0 = 0x12;
|
||||
static const Shortint eimc_p_Vh1 = 0x13;
|
||||
static const Shortint eimc_p_Imax = 0x14;
|
||||
static const Shortint eimc_p_abed = 0x15;
|
||||
static const Shortint eimc_p_eped = 0x16;
|
||||
static const Shortint eimv_FMAXMAX = 0x0;
|
||||
static const Shortint eimv_Fmax = 0x1;
|
||||
static const Shortint eimv_ks = 0x2;
|
||||
static const Shortint eimv_df = 0x3;
|
||||
static const Shortint eimv_fp = 0x4;
|
||||
static const Shortint eimv_U = 0x5;
|
||||
static const Shortint eimv_pole = 0x6;
|
||||
static const Shortint eimv_Ic = 0x7;
|
||||
static const Shortint eimv_If = 0x8;
|
||||
static const Shortint eimv_M = 0x9;
|
||||
static const Shortint eimv_Fr = 0xa;
|
||||
static const Shortint eimv_Ipoj = 0xb;
|
||||
static const Shortint eimv_Pm = 0xc;
|
||||
static const Shortint eimv_Pe = 0xd;
|
||||
static const Shortint eimv_eta = 0xe;
|
||||
static const Shortint eimv_fkr = 0xf;
|
||||
static const Shortint eimv_Uzsmax = 0x10;
|
||||
static const Shortint eimv_Pmax = 0x11;
|
||||
static const Shortint eimv_Fzad = 0x12;
|
||||
static const Shortint eimv_Imax = 0x13;
|
||||
static const Shortint eimv_Fful = 0x14;
|
||||
static const Shortint bom_PS = 0x1;
|
||||
static const Shortint bom_PN = 0x2;
|
||||
static const Shortint bom_EP = 0x4;
|
||||
static const Shortint bom_MED = 0x8;
|
||||
extern PACKAGE double __fastcall Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension
|
||||
&Dim1, const TDimension &Dim2);
|
||||
|
||||
} /* namespace _mover */
|
||||
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
|
||||
using namespace _mover;
|
||||
#endif
|
||||
#pragma option pop // -w-
|
||||
#pragma option pop // -Vx
|
||||
|
||||
#pragma delphiheader end.
|
||||
//-- end unit ----------------------------------------------------------------
|
||||
#endif // _mover
|
||||
@@ -1,293 +0,0 @@
|
||||
// Borland C++ Builder
|
||||
// Copyright (c) 1995, 1999 by Borland International
|
||||
// All rights reserved
|
||||
|
||||
// (DO NOT EDIT: machine generated header) 'Oerlikon_ESt.pas' rev: 5.00
|
||||
|
||||
#ifndef Oerlikon_EStHPP
|
||||
#define Oerlikon_EStHPP
|
||||
|
||||
#pragma delphiheader begin
|
||||
#pragma option push -w-
|
||||
#pragma option push -Vx
|
||||
#include <hamulce.h> // Pascal unit
|
||||
#include <friction.h> // Pascal unit
|
||||
#include <SysUtils.hpp> // Pascal unit
|
||||
#include <mctools.h> // Pascal unit
|
||||
#include <SysInit.hpp> // Pascal unit
|
||||
#include <System.hpp> // Pascal unit
|
||||
|
||||
//-- user supplied -----------------------------------------------------------
|
||||
|
||||
namespace Oerlikon_est
|
||||
{
|
||||
//-- type declarations -------------------------------------------------------
|
||||
class DELPHICLASS TPrzekladnik;
|
||||
class PASCALIMPLEMENTATION TPrzekladnik : public TReservoir
|
||||
{
|
||||
typedef TReservoir inherited;
|
||||
|
||||
public:
|
||||
TReservoir* *BrakeRes;
|
||||
TReservoir* *Next;
|
||||
virtual void __fastcall Update(double dt);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TPrzekladnik(void) : TReservoir() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TPrzekladnik(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TRura;
|
||||
class PASCALIMPLEMENTATION TRura : public TPrzekladnik
|
||||
{
|
||||
typedef TPrzekladnik inherited;
|
||||
|
||||
public:
|
||||
virtual double __fastcall P(void);
|
||||
virtual void __fastcall Update(double dt);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TRura(void) : TPrzekladnik() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TRura(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TPrzeciwposlizg;
|
||||
class PASCALIMPLEMENTATION TPrzeciwposlizg : public TRura
|
||||
{
|
||||
typedef TRura inherited;
|
||||
|
||||
private:
|
||||
bool Poslizg;
|
||||
|
||||
public:
|
||||
void __fastcall SetPoslizg(bool flag);
|
||||
virtual void __fastcall Update(double dt);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TPrzeciwposlizg(void) : TRura() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TPrzeciwposlizg(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TRapid;
|
||||
class PASCALIMPLEMENTATION TRapid : public TPrzekladnik
|
||||
{
|
||||
typedef TPrzekladnik inherited;
|
||||
|
||||
private:
|
||||
bool RapidStatus;
|
||||
double RapidMult;
|
||||
double DN;
|
||||
double DL;
|
||||
|
||||
public:
|
||||
void __fastcall SetRapidParams(double mult, double size);
|
||||
void __fastcall SetRapidStatus(bool rs);
|
||||
virtual void __fastcall Update(double dt);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TRapid(void) : TPrzekladnik() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TRapid(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TPrzekCiagly;
|
||||
class PASCALIMPLEMENTATION TPrzekCiagly : public TPrzekladnik
|
||||
{
|
||||
typedef TPrzekladnik inherited;
|
||||
|
||||
private:
|
||||
double Mult;
|
||||
|
||||
public:
|
||||
void __fastcall SetMult(double m);
|
||||
virtual void __fastcall Update(double dt);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TPrzekCiagly(void) : TPrzekladnik() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TPrzekCiagly(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TPrzek_PZZ;
|
||||
class PASCALIMPLEMENTATION TPrzek_PZZ : public TPrzekladnik
|
||||
{
|
||||
typedef TPrzekladnik inherited;
|
||||
|
||||
private:
|
||||
double LBP;
|
||||
|
||||
public:
|
||||
void __fastcall SetLBP(double P);
|
||||
virtual void __fastcall Update(double dt);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TPrzek_PZZ(void) : TPrzekladnik() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TPrzek_PZZ(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TPrzekZalamany;
|
||||
class PASCALIMPLEMENTATION TPrzekZalamany : public TPrzekladnik
|
||||
{
|
||||
typedef TPrzekladnik inherited;
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TPrzekZalamany(void) : TPrzekladnik() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TPrzekZalamany(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TPrzekED;
|
||||
class PASCALIMPLEMENTATION TPrzekED : public TRura
|
||||
{
|
||||
typedef TRura inherited;
|
||||
|
||||
private:
|
||||
double MaxP;
|
||||
|
||||
public:
|
||||
void __fastcall SetP(double P);
|
||||
virtual void __fastcall Update(double dt);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TReservoir.Create */ inline __fastcall TPrzekED(void) : TRura() { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TPrzekED(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DELPHICLASS TNESt3;
|
||||
class PASCALIMPLEMENTATION TNESt3 : public Hamulce::TBrake
|
||||
{
|
||||
typedef Hamulce::TBrake inherited;
|
||||
|
||||
private:
|
||||
double Nozzles[11];
|
||||
Hamulce::TReservoir* CntrlRes;
|
||||
double BVM;
|
||||
bool Zamykajacy;
|
||||
bool Przys_blok;
|
||||
Hamulce::TReservoir* Miedzypoj;
|
||||
TPrzekladnik* Przekladniki[3];
|
||||
bool RapidStatus;
|
||||
bool RapidStaly;
|
||||
double LoadC;
|
||||
double TareM;
|
||||
double LoadM;
|
||||
double TareBP;
|
||||
double HBG300;
|
||||
double Podskok;
|
||||
bool autom;
|
||||
double LBP;
|
||||
|
||||
public:
|
||||
virtual double __fastcall GetPF(double PP, double dt, double Vel);
|
||||
void __fastcall EStParams(double i_crc);
|
||||
virtual void __fastcall Init(double PP, double HPP, double LPP, double BP, Byte BDF);
|
||||
virtual double __fastcall GetCRP(void);
|
||||
void __fastcall CheckState(double BCP, double &dV1);
|
||||
void __fastcall CheckReleaser(double dt);
|
||||
double __fastcall CVs(double bp);
|
||||
double __fastcall BVs(double BCP);
|
||||
void __fastcall SetSize(int size, AnsiString params);
|
||||
void __fastcall PLC(double mass);
|
||||
void __fastcall SetLP(double TM, double LM, double TBP);
|
||||
virtual void __fastcall ForceEmptiness(void);
|
||||
void __fastcall SetLBP(double P);
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TBrake.Create */ inline __fastcall TNESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc
|
||||
, Byte i_bcn, Byte i_BD, Byte i_mat, Byte i_ba, Byte i_nbpa) : Hamulce::TBrake(i_mbp, i_bcr, i_bcd
|
||||
, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { }
|
||||
#pragma option pop
|
||||
|
||||
public:
|
||||
#pragma option push -w-inl
|
||||
/* TObject.Destroy */ inline __fastcall virtual ~TNESt3(void) { }
|
||||
#pragma option pop
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-- var, const, procedure ---------------------------------------------------
|
||||
static const Shortint dMAX = 0xa;
|
||||
static const Shortint dON = 0x0;
|
||||
static const Shortint dOO = 0x1;
|
||||
static const Shortint dTN = 0x2;
|
||||
static const Shortint dTO = 0x3;
|
||||
static const Shortint dP = 0x4;
|
||||
static const Shortint dSd = 0x5;
|
||||
static const Shortint dSm = 0x6;
|
||||
static const Shortint dPd = 0x7;
|
||||
static const Shortint dPm = 0x8;
|
||||
static const Shortint dPO = 0x9;
|
||||
static const Shortint dPT = 0xa;
|
||||
static const Shortint p_none = 0x0;
|
||||
static const Shortint p_rapid = 0x1;
|
||||
static const Shortint p_pp = 0x2;
|
||||
static const Shortint p_al2 = 0x3;
|
||||
static const Shortint p_ppz = 0x4;
|
||||
static const Shortint P_ed = 0x5;
|
||||
extern PACKAGE double __fastcall d2A(double d);
|
||||
|
||||
} /* namespace Oerlikon_est */
|
||||
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
|
||||
using namespace Oerlikon_est;
|
||||
#endif
|
||||
#pragma option pop // -w-
|
||||
#pragma option pop // -Vx
|
||||
|
||||
#pragma delphiheader end.
|
||||
//-- end unit ----------------------------------------------------------------
|
||||
#endif // Oerlikon_ESt
|
||||
@@ -1,805 +0,0 @@
|
||||
unit Oerlikon_ESt; {fizyka hamulcow Oerlikon ESt dla symulatora}
|
||||
|
||||
(*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*)
|
||||
(*
|
||||
MaSzyna EU07 - SPKS
|
||||
Brakes. Oerlikon ESt.
|
||||
Copyright (C) 2007-2014 Maciej Cierniak
|
||||
*)
|
||||
|
||||
|
||||
(*
|
||||
(C) youBy
|
||||
Co jest:
|
||||
- glowny przyrzad rozrzadczy
|
||||
- napelniacz zbiornika pomocniczego
|
||||
- napelniacz zbiornika sterujacego
|
||||
- zawor podskoku
|
||||
- nibyprzyspieszacz
|
||||
- tylko 16",14",12",10"
|
||||
- nieprzekladnik rura
|
||||
- przekladnik 1:1
|
||||
- przekladniki AL2
|
||||
- przeciwposlizgi
|
||||
- rapid REL2
|
||||
- HGB300
|
||||
- inne srednice
|
||||
Co brakuje:
|
||||
- dobry przyspieszacz
|
||||
- mozliwosc zasilania z wysokiego cisnienia ESt4
|
||||
- ep: EP1 i EP2
|
||||
- samoczynne ep
|
||||
- PZZ dla dodatkowego
|
||||
*)
|
||||
|
||||
interface
|
||||
|
||||
uses mctools,sysutils,friction,hamulce;//,klasy_ham;
|
||||
|
||||
CONST
|
||||
dMAX=10; //dysze
|
||||
dON = 0; //osobowy napelnianie (+ZP)
|
||||
dOO = 1; //osobowy oproznianie
|
||||
dTN = 2; //towarowy napelnianie (+ZP)
|
||||
dTO = 3; //towarowy oproznianie
|
||||
dP = 4; //zbiornik pomocniczy
|
||||
dSd = 5; //zbiornik sterujacy
|
||||
dSm = 6; //zbiornik sterujacy
|
||||
dPd = 7; //duzy przelot zamykajcego
|
||||
dPm = 8; //maly przelot zamykajacego
|
||||
dPO = 9; //zasilanie pomocniczego O
|
||||
dPT =10; //zasilanie pomocniczego T
|
||||
|
||||
//przekladniki
|
||||
p_none = 0;
|
||||
p_rapid = 1;
|
||||
p_pp = 2;
|
||||
p_al2 = 3;
|
||||
p_ppz = 4;
|
||||
P_ed = 5;
|
||||
|
||||
|
||||
|
||||
TYPE
|
||||
TPrzekladnik= class(TReservoir) //przekladnik (powtarzacz)
|
||||
private
|
||||
public
|
||||
BrakeRes: PReservoir;
|
||||
Next: PReservoir;
|
||||
procedure Update(dt:real); virtual;
|
||||
end;
|
||||
|
||||
TRura= class(TPrzekladnik) //nieprzekladnik, rura laczaca
|
||||
private
|
||||
public
|
||||
function P: real; override;
|
||||
procedure Update(dt:real); override;
|
||||
end;
|
||||
|
||||
TPrzeciwposlizg= class(TRura) //przy napelnianiu - rura, przy poslizgu - upust
|
||||
private
|
||||
Poslizg: boolean;
|
||||
public
|
||||
procedure SetPoslizg(flag: boolean);
|
||||
procedure Update(dt:real); override;
|
||||
end;
|
||||
|
||||
TRapid= class(TPrzekladnik) //przekladnik dwustopniowy
|
||||
private
|
||||
RapidStatus: boolean; //status rapidu
|
||||
RapidMult: real; //przelozenie (w dol)
|
||||
// Komora2: real;
|
||||
DN,DL: real; //srednice dysz napelniania i luzowania
|
||||
public
|
||||
procedure SetRapidParams(mult: real; size: real);
|
||||
procedure SetRapidStatus(rs: boolean);
|
||||
procedure Update(dt:real); override;
|
||||
end;
|
||||
|
||||
TPrzekCiagly= class(TPrzekladnik) //AL2
|
||||
private
|
||||
Mult: real;
|
||||
public
|
||||
procedure SetMult(m: real);
|
||||
procedure Update(dt:real); override;
|
||||
end;
|
||||
|
||||
TPrzek_PZZ= class(TPrzekladnik) //podwojny zawor zwrotny
|
||||
private
|
||||
LBP: real;
|
||||
public
|
||||
procedure SetLBP(P: real);
|
||||
procedure Update(dt:real); override;
|
||||
end;
|
||||
|
||||
TPrzekZalamany= class(TPrzekladnik) //Knicksventil
|
||||
private
|
||||
public
|
||||
end;
|
||||
|
||||
TPrzekED= class(TRura) //przy napelnianiu - rura, przy hamowaniu - upust
|
||||
private
|
||||
MaxP: real;
|
||||
public
|
||||
procedure SetP(P: real);
|
||||
procedure Update(dt:real); override;
|
||||
end;
|
||||
|
||||
TNESt3= class(TBrake)
|
||||
private
|
||||
Nozzles: array[0..dMAX] of real; //dysze
|
||||
CntrlRes: TReservoir; //zbiornik steruj¹cy
|
||||
BVM: real; //przelozenie PG-CH
|
||||
// ValveFlag: byte; //polozenie roznych zaworkow
|
||||
Zamykajacy: boolean; //pamiec zaworka zamykajacego
|
||||
// Przys_wlot: boolean; //wlot do komory przyspieszacza
|
||||
Przys_blok: boolean; //blokada przyspieszacza
|
||||
Miedzypoj: TReservoir; //pojemnosc posrednia (urojona) do napelniania ZP i ZS
|
||||
Przekladniki: array[1..3] of TPrzekladnik;
|
||||
RapidStatus: boolean;
|
||||
RapidStaly: boolean;
|
||||
LoadC: real;
|
||||
TareM, LoadM: real; //masa proznego i pelnego
|
||||
TareBP: real; //cisnienie dla proznego
|
||||
HBG300: real; //zawor ograniczajacy cisnienie
|
||||
Podskok: real; //podskok preznosci poczatkowej
|
||||
// HPBR: real; //zasilanie ZP z wysokiego cisnienia
|
||||
autom: boolean; //odluzniacz samoczynny
|
||||
LBP: real; //cisnienie hamulca pomocniczego
|
||||
public
|
||||
function GetPF(PP, dt, Vel: real): real; override; //przeplyw miedzy komora wstepna i PG
|
||||
procedure EStParams(i_crc: real); //parametry charakterystyczne dla ESt
|
||||
procedure Init(PP, HPP, LPP, BP: real; BDF: byte); override;
|
||||
function GetCRP: real; override;
|
||||
procedure CheckState(BCP: real; var dV1: real); //glowny przyrzad rozrzadczy
|
||||
procedure CheckReleaser(dt: real); //odluzniacz
|
||||
function CVs(bp: real): real; //napelniacz sterujacego
|
||||
function BVs(BCP: real): real; //napelniacz pomocniczego
|
||||
procedure SetSize(size: integer; params: string); //ustawianie dysz (rozmiaru ZR), przekladniki
|
||||
procedure PLC(mass: real); //wspolczynnik cisnienia przystawki wazacej
|
||||
procedure SetLP(TM, LM, TBP: real); //parametry przystawki wazacej
|
||||
procedure ForceEmptiness(); override; //wymuszenie bycia pustym
|
||||
procedure SetLBP(P: real); //cisnienie z hamulca pomocniczego
|
||||
end;
|
||||
|
||||
function d2A(d: real):real;
|
||||
|
||||
implementation
|
||||
|
||||
function d2A(d: real):real;
|
||||
begin
|
||||
d2A:=(d*d)*0.7854/1000;
|
||||
end;
|
||||
|
||||
// ------ RURA ------
|
||||
|
||||
function TRura.P: real;
|
||||
begin
|
||||
P:=Next.P;
|
||||
end;
|
||||
|
||||
procedure TRura.Update(dt: real);
|
||||
begin
|
||||
Next.Flow(dVol);
|
||||
dVol:=0;
|
||||
end;
|
||||
|
||||
// ------ PRZECIWPOSLIG ------
|
||||
|
||||
procedure TPrzeciwposlizg.SetPoslizg(flag: boolean);
|
||||
begin
|
||||
Poslizg:=flag;
|
||||
end;
|
||||
|
||||
procedure TPrzeciwposlizg.Update(dt: real);
|
||||
begin
|
||||
if (Poslizg) then
|
||||
begin
|
||||
BrakeRes.Flow(dVol);
|
||||
Next.Flow(PF(Next.P,0,d2A(10))*dt);
|
||||
end
|
||||
else
|
||||
Next.Flow(dVol);
|
||||
dVol:=0;
|
||||
end;
|
||||
|
||||
|
||||
// ------ PRZEKLADNIK ------
|
||||
|
||||
procedure TPrzekladnik.Update(dt: real);
|
||||
var BCP, BVP, dV: real;
|
||||
begin
|
||||
|
||||
BCP:=Next.P;
|
||||
BVP:=BrakeRes.P;
|
||||
|
||||
if(BCP>P)then
|
||||
dV:=-PFVd(BCP,0,d2A(10),P)*dt
|
||||
else
|
||||
if(BCP<P)then
|
||||
dV:=PFVa(BVP,BCP,d2A(10),P)*dt
|
||||
else dV:=0;
|
||||
|
||||
Next.Flow(dV);
|
||||
if dV>0 then
|
||||
BrakeRes.Flow(-dV);
|
||||
|
||||
end;
|
||||
|
||||
// ------ PRZEKLADNIK RAPID ------
|
||||
|
||||
procedure TRapid.SetRapidParams(mult: real; size: real);
|
||||
begin
|
||||
RapidMult:=mult;
|
||||
RapidStatus:=false;
|
||||
if (size>0.1) then //dopasowywanie srednicy przekladnika
|
||||
begin
|
||||
DN:=D2A(size*0.4);
|
||||
DL:=D2A(size*0.4);
|
||||
end
|
||||
else
|
||||
begin
|
||||
DN:=D2A(5);
|
||||
DL:=D2A(5);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRapid.SetRapidStatus(rs: boolean);
|
||||
begin
|
||||
RapidStatus:=rs;
|
||||
end;
|
||||
|
||||
procedure TRapid.Update(dt: real);
|
||||
var BCP, BVP, dV, ActMult: real;
|
||||
begin
|
||||
BVP:=BrakeRes.P;
|
||||
BCP:=Next.P;
|
||||
|
||||
if(RapidStatus)then
|
||||
begin
|
||||
ActMult:=RapidMult;
|
||||
end
|
||||
else
|
||||
begin
|
||||
ActMult:=1;
|
||||
end;
|
||||
|
||||
if(BCP*RapidMult>P*actMult)then
|
||||
dV:=-PFVd(BCP,0,DL,P*actMult/RapidMult)*dt
|
||||
else
|
||||
if(BCP*RapidMult<P*ActMult)then
|
||||
dV:=PFVa(BVP,BCP,DN,P*actMult/RapidMult)*dt
|
||||
else dV:=0;
|
||||
|
||||
Next.Flow(dV);
|
||||
if dV>0 then
|
||||
BrakeRes.Flow(-dV);
|
||||
|
||||
end;
|
||||
|
||||
// ------ PRZEK£ADNIK CI¥G£Y ------
|
||||
|
||||
procedure TPrzekCiagly.SetMult(m:real);
|
||||
begin
|
||||
Mult:=m;
|
||||
end;
|
||||
|
||||
procedure TPrzekCiagly.Update(dt: real);
|
||||
var BCP, BVP, dV: real;
|
||||
begin
|
||||
BVP:=BrakeRes.P;
|
||||
BCP:=Next.P;
|
||||
|
||||
if(BCP>P*Mult)then
|
||||
dV:=-PFVd(BCP,0,d2A(8),P*Mult)*dt
|
||||
else
|
||||
if(BCP<P*Mult)then
|
||||
dV:=PFVa(BVP,BCP,d2A(8),P*Mult)*dt
|
||||
else dV:=0;
|
||||
|
||||
Next.Flow(dV);
|
||||
if dV>0 then
|
||||
BrakeRes.Flow(-dV);
|
||||
|
||||
end;
|
||||
|
||||
// ------ PRZEK£ADNIK CI¥G£Y ------
|
||||
|
||||
procedure TPrzek_PZZ.SetLBP(P:real);
|
||||
begin
|
||||
LBP:=P;
|
||||
end;
|
||||
|
||||
procedure TPrzek_PZZ.Update(dt: real);
|
||||
var BCP, BVP, dV, Pgr: real;
|
||||
begin
|
||||
BVP:=BrakeRes.P;
|
||||
BCP:=Next.P;
|
||||
|
||||
Pgr:=Max0R(LBP,P);
|
||||
|
||||
if(BCP>Pgr)then
|
||||
dV:=-PFVd(BCP,0,d2A(8),Pgr)*dt
|
||||
else
|
||||
if(BCP<Pgr)then
|
||||
dV:=PFVa(BVP,BCP,d2A(8),Pgr)*dt
|
||||
else dV:=0;
|
||||
|
||||
Next.Flow(dV);
|
||||
if dV>0 then
|
||||
BrakeRes.Flow(-dV);
|
||||
|
||||
end;
|
||||
|
||||
// ------ PRZECIWPOSLIG ------
|
||||
|
||||
procedure TPrzekED.SetP(P: real);
|
||||
begin
|
||||
MaxP:=P;
|
||||
end;
|
||||
|
||||
procedure TPrzekED.Update(dt: real);
|
||||
begin
|
||||
if Next.P>MaxP then
|
||||
begin
|
||||
BrakeRes.Flow(dVol);
|
||||
Next.Flow(PFVd(Next.P,0,d2A(10)*dt,MaxP));
|
||||
end
|
||||
else
|
||||
Next.Flow(dVol);
|
||||
dVol:=0;
|
||||
end;
|
||||
|
||||
|
||||
// ------ OERLIKON EST NA BOGATO ------
|
||||
|
||||
function TNESt3.GetPF(PP, dt, Vel: real): real; //przeplyw miedzy komora wstepna i PG
|
||||
var dv, dv1, temp:real;
|
||||
VVP, BVP, BCP, CVP, MPP, nastG: real;
|
||||
i: byte;
|
||||
begin
|
||||
BVP:=BrakeRes.P;
|
||||
VVP:=ValveRes.P;
|
||||
// BCP:=BrakeCyl.P;
|
||||
BCP:=Przekladniki[1].P;
|
||||
CVP:=CntrlRes.P-0.0;
|
||||
MPP:=Miedzypoj.P;
|
||||
dV1:=0;
|
||||
|
||||
nastG:=(BrakeDelayFlag and bdelay_G);
|
||||
|
||||
//sprawdzanie stanu
|
||||
CheckState(BCP, dV1);
|
||||
CheckReleaser(dt);
|
||||
|
||||
//luzowanie
|
||||
if(BrakeStatus and b_hld)=b_off then
|
||||
dV:=PF(0,BCP,Nozzles[dTO]*nastG+(1-nastG)*Nozzles[dOO])*dt*(0.1+4.9*Min0R(0.2,BCP-((CVP-0.05-VVP)*BVM+0.1)))
|
||||
else dV:=0;
|
||||
// BrakeCyl.Flow(-dV);
|
||||
Przekladniki[1].Flow(-dV);
|
||||
if((BrakeStatus and b_on)=b_on)and(Przekladniki[1].P*HBG300<MaxBP)then
|
||||
dV:=PF(BVP,BCP,Nozzles[dTN]*(nastG+2*Byte(BCP<Podskok))+Nozzles[dON]*(1-nastG))*dt*(0.1+4.9*Min0R(0.2,(CVP-0.05-VVP)*BVM-BCP))
|
||||
else dV:=0;
|
||||
// BrakeCyl.Flow(-dV);
|
||||
Przekladniki[1].Flow(-dV);
|
||||
BrakeRes.Flow(dV);
|
||||
|
||||
for i:=1 to 3 do
|
||||
begin
|
||||
Przekladniki[i].Update(dt);
|
||||
if (Przekladniki[i] is TRapid) then
|
||||
begin
|
||||
RapidStatus:=(((BrakeDelayFlag and bdelay_R)=bdelay_R) and ((Abs(Vel)>70) or ((RapidStatus) and (Abs(Vel)>50)) or (RapidStaly)));
|
||||
(Przekladniki[i] as TRapid).SetRapidStatus(RapidStatus);
|
||||
end
|
||||
else
|
||||
if (Przekladniki[i] is TPrzeciwposlizg) then
|
||||
(Przekladniki[i] as TPrzeciwposlizg).SetPoslizg((BrakeStatus and b_asb)=b_asb)
|
||||
else
|
||||
if (Przekladniki[i] is TPrzekED) then
|
||||
if (Vel<-15) then
|
||||
(Przekladniki[i] as TPrzekED).SetP(0)
|
||||
else (Przekladniki[i] as TPrzekED).SetP(MaxBP*3)
|
||||
else
|
||||
if (Przekladniki[i] is TPrzekCiagly) then
|
||||
(Przekladniki[i] as TPrzekCiagly).SetMult(LoadC)
|
||||
else
|
||||
if (Przekladniki[i] is TPrzek_PZZ) then
|
||||
(Przekladniki[i] as TPrzek_PZZ).SetLBP(LBP);
|
||||
end;
|
||||
|
||||
|
||||
//przeplyw testowy miedzypojemnosci
|
||||
dV:=PF(MPP,VVP,BVs(BCP))+PF(MPP,CVP,CVs(BCP));
|
||||
if(MPP-0.05>BVP)then
|
||||
dV:=dV+PF(MPP-0.05,BVP,Nozzles[dPT]*nastG+(1-nastG)*Nozzles[dPO]);
|
||||
if MPP>VVP then dV:=dV+PF(MPP,VVP,d2A(5));
|
||||
Miedzypoj.Flow(dV*dt*0.15);
|
||||
|
||||
|
||||
//przeplyw ZS <-> PG
|
||||
temp:=CVs(BCP);
|
||||
dV:=PF(CVP,MPP,temp)*dt;
|
||||
CntrlRes.Flow(+dV);
|
||||
ValveRes.Flow(-0.02*dV);
|
||||
dV1:=dV1+0.98*dV;
|
||||
|
||||
//przeplyw ZP <-> MPJ
|
||||
if(MPP-0.05>BVP)then
|
||||
dV:=PF(BVP,MPP-0.05,Nozzles[dPT]*nastG+(1-nastG)*Nozzles[dPO])*dt
|
||||
else dV:=0;
|
||||
BrakeRes.Flow(dV);
|
||||
dV1:=dV1+dV*0.98;
|
||||
ValveRes.Flow(-0.02*dV);
|
||||
//przeplyw PG <-> rozdzielacz
|
||||
dV:=PF(PP,VVP,0.005)*dt; //0.01
|
||||
ValveRes.Flow(-dV);
|
||||
|
||||
|
||||
ValveRes.Act;
|
||||
BrakeCyl.Act;
|
||||
BrakeRes.Act;
|
||||
CntrlRes.Act;
|
||||
Miedzypoj.Act;
|
||||
Przekladniki[1].Act;
|
||||
Przekladniki[2].Act;
|
||||
Przekladniki[3].Act;
|
||||
GetPF:=dV-dV1;
|
||||
end;
|
||||
|
||||
|
||||
procedure TNESt3.EStParams(i_crc: real); //parametry charakterystyczne dla ESt
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure TNESt3.Init(PP, HPP, LPP, BP: real; BDF: byte);
|
||||
begin
|
||||
ValveRes.CreatePress(1*PP);
|
||||
BrakeCyl.CreatePress(1*BP);
|
||||
BrakeRes.CreatePress(1*PP);
|
||||
CntrlRes:=TReservoir.Create;
|
||||
CntrlRes.CreateCap(15);
|
||||
CntrlRes.CreatePress(1*HPP);
|
||||
BrakeStatus:=Byte(BP>1)*1;
|
||||
Miedzypoj:=TReservoir.Create;
|
||||
Miedzypoj.CreateCap(5);
|
||||
Miedzypoj.CreatePress(PP);
|
||||
|
||||
BVM:=1/(HPP-0.05-LPP)*MaxBP;
|
||||
|
||||
BrakeDelayFlag:=BDF;
|
||||
|
||||
Zamykajacy:=false;
|
||||
|
||||
if not ((FM is TDisk1) or (FM is TDisk2)) then //jesli zeliwo to schodz
|
||||
RapidStaly:=false
|
||||
else
|
||||
RapidStaly:=true;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
function TNESt3.GetCRP: real;
|
||||
begin
|
||||
GetCRP:=CntrlRes.P;
|
||||
// GetCRP:=Przekladniki[1].P;
|
||||
// GetCRP:=Miedzypoj.P;
|
||||
end;
|
||||
|
||||
|
||||
procedure TNESt3.CheckState(BCP: real; var dV1: real); //glowny przyrzad rozrzadczy
|
||||
var VVP, BVP, CVP, MPP: real;
|
||||
begin
|
||||
BVP:=BrakeRes.P; //-> tu ma byc komora rozprezna
|
||||
VVP:=ValveRes.P;
|
||||
CVP:=CntrlRes.P;
|
||||
MPP:=Miedzypoj.P;
|
||||
|
||||
if(BCP<0.25)and(VVP+0.08>CVP)then Przys_blok:=false;
|
||||
|
||||
//sprawdzanie stanu
|
||||
// if ((BrakeStatus and 1)=1)and(BCP>0.25)then
|
||||
if(VVP+0.01+BCP/BVM<CVP-0.05)and(Przys_blok)then
|
||||
BrakeStatus:=(BrakeStatus or 3) //hamowanie stopniowe
|
||||
else if(VVP-0.01+(BCP-0.1)/BVM>CVP-0.05) then
|
||||
BrakeStatus:=(BrakeStatus and 252) //luzowanie
|
||||
else if(VVP+BCP/BVM>CVP-0.05) then
|
||||
BrakeStatus:=(BrakeStatus and 253) //zatrzymanie napelaniania
|
||||
else if(VVP+(BCP-0.1)/BVM<CVP-0.05)and(BCP>0.25)then //zatrzymanie luzowania
|
||||
BrakeStatus:=(BrakeStatus or 1);
|
||||
|
||||
if (BrakeStatus and 1)=0 then
|
||||
SoundFlag:=SoundFlag or sf_CylU;
|
||||
|
||||
if(VVP+0.10<CVP)and(BCP<0.25)then //poczatek hamowania
|
||||
if (not Przys_blok) then
|
||||
begin
|
||||
ValveRes.CreatePress(0.1*VVP);
|
||||
SoundFlag:=SoundFlag or sf_Acc;
|
||||
ValveRes.Act;
|
||||
Przys_blok:=true;
|
||||
end;
|
||||
|
||||
|
||||
if(BCP>0.5)then
|
||||
Zamykajacy:=true
|
||||
else if(VVP-0.6<MPP) then
|
||||
Zamykajacy:=false;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure TNESt3.CheckReleaser(dt: real); //odluzniacz
|
||||
var
|
||||
VVP, CVP: real;
|
||||
begin
|
||||
VVP:=ValveRes.P;
|
||||
CVP:=CntrlRes.P;
|
||||
|
||||
//odluzniacz automatyczny
|
||||
if(BrakeStatus and b_rls=b_rls)then
|
||||
begin
|
||||
CntrlRes.Flow(+PF(CVP,0,0.02)*dt);
|
||||
if(CVP<VVP+0.3)or(not autom)then
|
||||
BrakeStatus:=BrakeStatus and 247;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TNESt3.CVs(bp: real): real; //napelniacz sterujacego
|
||||
var CVP, MPP: real;
|
||||
begin
|
||||
CVP:=CntrlRes.P;
|
||||
MPP:=Miedzypoj.P;
|
||||
|
||||
//przeplyw ZS <-> PG
|
||||
if(MPP<CVP-0.17)then
|
||||
CVS:=0
|
||||
else
|
||||
if(MPP>CVP-0.08)then
|
||||
CVs:=Nozzles[dSD]
|
||||
else
|
||||
CVs:=Nozzles[dSm];
|
||||
end;
|
||||
|
||||
|
||||
function TNESt3.BVs(BCP: real): real; //napelniacz pomocniczego
|
||||
var CVP, MPP: real;
|
||||
begin
|
||||
CVP:=CntrlRes.P;
|
||||
MPP:=Miedzypoj.P;
|
||||
|
||||
//przeplyw ZP <-> rozdzielacz
|
||||
if(MPP<CVP-0.3)then
|
||||
BVs:=Nozzles[dP]
|
||||
else
|
||||
if(BCP<0.5) then
|
||||
if(Zamykajacy)then
|
||||
BVs:=Nozzles[dPm] //1.25
|
||||
else
|
||||
BVs:=Nozzles[dPD]
|
||||
else
|
||||
BVs:=0;
|
||||
end;
|
||||
|
||||
procedure TNESt3.PLC(mass: real);
|
||||
begin
|
||||
LoadC:=1+Byte(Mass<LoadM)*((TareBP+(MaxBP-TareBP)*(mass-TareM)/(LoadM-TareM))/MaxBP-1);
|
||||
end;
|
||||
|
||||
procedure TNESt3.ForceEmptiness();
|
||||
begin
|
||||
ValveRes.CreatePress(0);
|
||||
BrakeRes.CreatePress(0);
|
||||
Miedzypoj.CreatePress(0);
|
||||
CntrlRes.CreatePress(0);
|
||||
|
||||
BrakeStatus:=0;
|
||||
|
||||
ValveRes.Act();
|
||||
BrakeRes.Act();
|
||||
Miedzypoj.Act();
|
||||
CntrlRes.Act();
|
||||
end;
|
||||
|
||||
|
||||
procedure TNESt3.SetLP(TM, LM, TBP: real);
|
||||
begin
|
||||
TareM:=TM;
|
||||
LoadM:=LM;
|
||||
TareBP:=TBP;
|
||||
end;
|
||||
|
||||
|
||||
procedure TNESt3.SetLBP(P: real);
|
||||
begin
|
||||
LBP:=P;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TNESt3.SetSize(size: integer; params: string); //ustawianie dysz (rozmiaru ZR)
|
||||
const
|
||||
dNO1l = 1.250;
|
||||
dNT1l = 0.510;
|
||||
dOO1l = 0.907;
|
||||
dOT1l = 0.524;
|
||||
var
|
||||
i:integer;
|
||||
begin
|
||||
|
||||
if Pos('ESt3',params)>0 then
|
||||
begin
|
||||
Podskok:=0.7;
|
||||
Przekladniki[1]:=TRura.Create;
|
||||
Przekladniki[3]:=TRura.Create;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Podskok:=-1;
|
||||
Przekladniki[1]:=TRapid.Create;
|
||||
if Pos('-s216',params)>0 then
|
||||
(Przekladniki[1] as TRapid).SetRapidParams(2,16)
|
||||
else
|
||||
(Przekladniki[1] as TRapid).SetRapidParams(2,0);
|
||||
Przekladniki[3]:=TPrzeciwposlizg.Create;
|
||||
if Pos('-ED',params)>0 then
|
||||
begin
|
||||
Przekladniki[3].Free();
|
||||
(Przekladniki[1] as TRapid).SetRapidParams(2,18);
|
||||
Przekladniki[3]:=TPrzekED.Create;
|
||||
end;
|
||||
end;
|
||||
|
||||
if Pos('AL2',params)>0 then
|
||||
Przekladniki[2]:=TPrzekCiagly.Create
|
||||
else
|
||||
if Pos('PZZ',params)>0 then
|
||||
Przekladniki[2]:=TPrzek_PZZ.Create
|
||||
else
|
||||
Przekladniki[2]:=TRura.Create;
|
||||
|
||||
if (Pos('3d',params)+Pos('4d',params)>0) then autom:=false else autom:=true;
|
||||
if (Pos('HBG300',params)>0) then HBG300:=1 else HBG300:=0;
|
||||
|
||||
case size of
|
||||
16:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=5.0;//5.0;
|
||||
Nozzles[dOO]:=3.4;//3.4;
|
||||
Nozzles[dTN]:=2.0;
|
||||
Nozzles[dTO]:=1.75;
|
||||
Nozzles[dP]:=3.8;
|
||||
Nozzles[dPd]:=2.70;
|
||||
Nozzles[dPm]:=1.25;
|
||||
Nozzles[dPO]:=Nozzles[dON];
|
||||
Nozzles[dPT]:=Nozzles[dTN];
|
||||
end;
|
||||
14:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=4.3;
|
||||
Nozzles[dOO]:=2.85;
|
||||
Nozzles[dTN]:=1.83;
|
||||
Nozzles[dTO]:=1.57;
|
||||
Nozzles[dP]:=3.4;
|
||||
Nozzles[dPd]:=2.20;
|
||||
Nozzles[dPm]:=1.10;
|
||||
Nozzles[dPO]:=Nozzles[dON];
|
||||
Nozzles[dPT]:=Nozzles[dTN];
|
||||
end;
|
||||
12:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=3.7;
|
||||
Nozzles[dOO]:=2.50;
|
||||
Nozzles[dTN]:=1.65;
|
||||
Nozzles[dTO]:=1.39;
|
||||
Nozzles[dP]:=2.65;
|
||||
Nozzles[dPd]:=1.80;
|
||||
Nozzles[dPm]:=0.85;
|
||||
Nozzles[dPO]:=Nozzles[dON];
|
||||
Nozzles[dPT]:=Nozzles[dTN];
|
||||
end;
|
||||
10:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=3.1;
|
||||
Nozzles[dOO]:=2.0;
|
||||
Nozzles[dTN]:=1.35;
|
||||
Nozzles[dTO]:=1.13;
|
||||
Nozzles[dP]:=1.6;
|
||||
Nozzles[dPd]:=1.55;
|
||||
Nozzles[dPm]:=0.7;
|
||||
Nozzles[dPO]:=Nozzles[dON];
|
||||
Nozzles[dPT]:=Nozzles[dTN];
|
||||
end;
|
||||
200:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=dNO1l;
|
||||
Nozzles[dOO]:=dOO1l/1.15;
|
||||
Nozzles[dTN]:=dNT1l;
|
||||
Nozzles[dTO]:=dOT1l;
|
||||
Nozzles[dP]:=7.4;
|
||||
Nozzles[dPd]:=5.3;
|
||||
Nozzles[dPm]:=2.5;
|
||||
Nozzles[dPO]:=7.28;
|
||||
Nozzles[dPT]:=2.96;
|
||||
end;
|
||||
375:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=dNO1l;
|
||||
Nozzles[dOO]:=dOO1l/1.15;
|
||||
Nozzles[dTN]:=dNT1l;
|
||||
Nozzles[dTO]:=dOT1l;
|
||||
Nozzles[dP]:=13.0;
|
||||
Nozzles[dPd]:=9.6;
|
||||
Nozzles[dPm]:=4.4;
|
||||
Nozzles[dPO]:=9.92;
|
||||
Nozzles[dPT]:=3.99;
|
||||
end;
|
||||
150:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=dNO1l;
|
||||
Nozzles[dOO]:=dOO1l;
|
||||
Nozzles[dTN]:=dNT1l;
|
||||
Nozzles[dTO]:=dOT1l;
|
||||
Nozzles[dP]:=5.8;
|
||||
Nozzles[dPd]:=4.1;
|
||||
Nozzles[dPm]:=1.9;
|
||||
Nozzles[dPO]:=6.33;
|
||||
Nozzles[dPT]:=2.58;
|
||||
end;
|
||||
100:
|
||||
begin //dON,dOO,dTN,dTO,dP,dS
|
||||
Nozzles[dON]:=dNO1l;
|
||||
Nozzles[dOO]:=dOO1l;
|
||||
Nozzles[dTN]:=dNT1l;
|
||||
Nozzles[dTO]:=dOT1l;
|
||||
Nozzles[dP]:=4.2;
|
||||
Nozzles[dPd]:=2.9;
|
||||
Nozzles[dPm]:=1.4;
|
||||
Nozzles[dPO]:=5.19;
|
||||
Nozzles[dPT]:=2.14;
|
||||
end;
|
||||
else
|
||||
begin
|
||||
Nozzles[dON]:=0;
|
||||
Nozzles[dOO]:=0;
|
||||
Nozzles[dTN]:=0;
|
||||
Nozzles[dTO]:=0;
|
||||
Nozzles[dP]:=0;
|
||||
Nozzles[dPd]:=0;
|
||||
Nozzles[dPm]:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
Nozzles[dSd]:=1.1;
|
||||
Nozzles[dSm]:=0.9;
|
||||
|
||||
//przeliczanie z mm^2 na l/m
|
||||
for i:=0 to dMAX do
|
||||
begin
|
||||
Nozzles[i]:=d2A(Nozzles[i]); //(/1000^2*pi/4*1000)
|
||||
end;
|
||||
|
||||
for i:=1 to 3 do
|
||||
begin
|
||||
Przekladniki[i].BrakeRes:=@BrakeRes;
|
||||
Przekladniki[i].CreateCap(i);
|
||||
Przekladniki[i].CreatePress(BrakeCyl.P);
|
||||
if i<3 then
|
||||
Przekladniki[i].Next:=@Przekladniki[i+1]
|
||||
else
|
||||
Przekladniki[i].Next:=@BrakeCyl;
|
||||
end
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -1,151 +0,0 @@
|
||||
// Borland C++ Builder
|
||||
// Copyright (c) 1995, 1999 by Borland International
|
||||
// All rights reserved
|
||||
|
||||
// (DO NOT EDIT: machine generated header) 'QueryParserComp.pas' rev: 5.00
|
||||
|
||||
#ifndef QueryParserCompHPP
|
||||
#define QueryParserCompHPP
|
||||
|
||||
#pragma delphiheader begin
|
||||
#pragma option push -w-
|
||||
#pragma option push -Vx
|
||||
#include <SysUtils.hpp> // Pascal unit
|
||||
#include <Classes.hpp> // Pascal unit
|
||||
#include <SysInit.hpp> // Pascal unit
|
||||
#include <System.hpp> // Pascal unit
|
||||
|
||||
//-- user supplied -----------------------------------------------------------
|
||||
|
||||
namespace Queryparsercomp
|
||||
{
|
||||
//-- type declarations -------------------------------------------------------
|
||||
#pragma option push -b-
|
||||
enum TTokenType { ttString, ttSymbol, ttComment, ttDelimiter, ttSpecialChar, ttStatementDelimiter, ttCommentedSymbol,
|
||||
ttCommentDelimiter };
|
||||
#pragma option pop
|
||||
|
||||
typedef Set<char, 0, 255> TSetOfChar;
|
||||
|
||||
typedef AnsiString TComment[2];
|
||||
|
||||
#pragma option push -b-
|
||||
enum TCharacterType { ctSymbol, ctBeginComment, ctEndComment, ctDelimiter, ctString, ctSpecialChar }
|
||||
;
|
||||
#pragma option pop
|
||||
|
||||
#pragma option push -b-
|
||||
enum QueryParserComp__1 { cmt1, cmt2, cmt3 };
|
||||
#pragma option pop
|
||||
|
||||
typedef Set<QueryParserComp__1, cmt1, cmt3> TCommentType;
|
||||
|
||||
typedef AnsiString QueryParserComp__2[3][2];
|
||||
|
||||
typedef void __fastcall (__closure *TEndOfStatement)(System::TObject* Sender, AnsiString SQLStatement
|
||||
);
|
||||
|
||||
class DELPHICLASS TQueryParserComp;
|
||||
class PASCALIMPLEMENTATION TQueryParserComp : public Classes::TComponent
|
||||
{
|
||||
typedef Classes::TComponent inherited;
|
||||
|
||||
private:
|
||||
Classes::TStringStream* FStream;
|
||||
bool FEOF;
|
||||
AnsiString FToken;
|
||||
TTokenType FTokenType;
|
||||
bool FComment;
|
||||
bool FString;
|
||||
bool FWasString;
|
||||
TCommentType FCommentType;
|
||||
AnsiString FStringDelimiters;
|
||||
AnsiString FLastStringDelimiterFound;
|
||||
int FSymbolsCount;
|
||||
AnsiString FSpecialCharacters;
|
||||
bool FRemoveStrDelimiter;
|
||||
AnsiString FStringToParse;
|
||||
int FGoPosition;
|
||||
TEndOfStatement FOnStatementDelimiter;
|
||||
bool FCountFromStatement;
|
||||
Classes::TStringList* FStatementDelimiters;
|
||||
char FStringDelimiter;
|
||||
bool FGenerateOnStmtDelimiter;
|
||||
void __fastcall Init(void);
|
||||
void __fastcall SetStringToParse(AnsiString AStringToParse);
|
||||
bool __fastcall StatementDelimiter(void);
|
||||
bool __fastcall CheckForBeginComment(void);
|
||||
bool __fastcall CheckForEndComment(char Character);
|
||||
TCharacterType __fastcall CharacterType(char Character);
|
||||
bool __fastcall CheckCharcterType(char Character);
|
||||
bool __fastcall StringDelimiter(char Character);
|
||||
bool __fastcall SpecialCharacter(char Character);
|
||||
void __fastcall RemoveStringDelimiter(AnsiString &Source);
|
||||
void __fastcall SetDelimiterType(AnsiString Source);
|
||||
void __fastcall SetToken(void);
|
||||
void __fastcall SetSD(Classes::TStringList* ASD);
|
||||
void __fastcall SetSpecialCharacters(AnsiString ASpecialCharacters);
|
||||
void __fastcall SetStringDelimiters(AnsiString AStringDelimiters);
|
||||
|
||||
protected:
|
||||
DYNAMIC void __fastcall DoStatementDelimiter(void);
|
||||
|
||||
public:
|
||||
__fastcall virtual TQueryParserComp(Classes::TComponent* AOwner);
|
||||
__fastcall virtual ~TQueryParserComp(void);
|
||||
void __fastcall LoadStringToParse(AnsiString FileName);
|
||||
void __fastcall First(void);
|
||||
void __fastcall FirstToken(void);
|
||||
void __fastcall NextToken(void);
|
||||
AnsiString __fastcall GetNextSymbol();
|
||||
__property bool EndOfFile = {read=FEOF, nodefault};
|
||||
__property bool Comment = {read=FComment, nodefault};
|
||||
__property AnsiString Token = {read=FToken};
|
||||
__property TTokenType TokenType = {read=FTokenType, nodefault};
|
||||
__property char CurrentStringDelimiter = {read=FStringDelimiter, nodefault};
|
||||
__property int SymbolsCount = {read=FSymbolsCount, default=0};
|
||||
__property Classes::TStringStream* StringStream = {read=FStream};
|
||||
|
||||
__published:
|
||||
__property bool IsEOFStmtDelimiter = {read=FGenerateOnStmtDelimiter, write=FGenerateOnStmtDelimiter
|
||||
, nodefault};
|
||||
__property AnsiString StringDelimiters = {read=FStringDelimiters, write=SetStringDelimiters};
|
||||
__property AnsiString SpecialCharacters = {read=FSpecialCharacters, write=SetSpecialCharacters};
|
||||
__property bool RemoveStrDelimiter = {read=FRemoveStrDelimiter, write=FRemoveStrDelimiter, nodefault
|
||||
};
|
||||
__property bool CountFromStatement = {read=FCountFromStatement, write=FCountFromStatement, nodefault
|
||||
};
|
||||
__property AnsiString TextToParse = {read=FStringToParse, write=SetStringToParse};
|
||||
__property Classes::TStringList* StatementDelimiters = {read=FStatementDelimiters, write=SetSD};
|
||||
__property TEndOfStatement OnStatementDelimiter = {read=FOnStatementDelimiter, write=FOnStatementDelimiter
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//-- var, const, procedure ---------------------------------------------------
|
||||
extern PACKAGE System::ResourceString _sTextNotSet;
|
||||
#define Queryparsercomp_sTextNotSet System::LoadResourceString(&Queryparsercomp::_sTextNotSet)
|
||||
extern PACKAGE System::ResourceString _sIllegalSpecialChar;
|
||||
#define Queryparsercomp_sIllegalSpecialChar System::LoadResourceString(&Queryparsercomp::_sIllegalSpecialChar)
|
||||
|
||||
extern PACKAGE System::ResourceString _sIllegalStringChar;
|
||||
#define Queryparsercomp_sIllegalStringChar System::LoadResourceString(&Queryparsercomp::_sIllegalStringChar)
|
||||
|
||||
static const char CR = '\xd';
|
||||
static const char LF = '\xa';
|
||||
static const char TAB = '\x9';
|
||||
#define CRLF "\r\n"
|
||||
extern PACKAGE TSetOfChar Delimiters;
|
||||
extern PACKAGE AnsiString Comments[3][2];
|
||||
extern PACKAGE void __fastcall Register(void);
|
||||
|
||||
} /* namespace Queryparsercomp */
|
||||
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
|
||||
using namespace Queryparsercomp;
|
||||
#endif
|
||||
#pragma option pop // -w-
|
||||
#pragma option pop // -Vx
|
||||
|
||||
#pragma delphiheader end.
|
||||
//-- end unit ----------------------------------------------------------------
|
||||
#endif // QueryParserComp
|
||||
@@ -1,733 +0,0 @@
|
||||
unit QueryParserComp;
|
||||
|
||||
(*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Sysutils;
|
||||
|
||||
resourcestring
|
||||
sTextNotSet = 'You must set the TextToParse property first.';
|
||||
sIllegalSpecialChar = 'Illegal special character.';
|
||||
sIllegalStringChar = 'Illegal string delimiter.';
|
||||
|
||||
type
|
||||
TTokenType = (ttString, ttSymbol, ttComment, ttDelimiter, ttSpecialChar,
|
||||
ttStatementDelimiter, ttCommentedSymbol, ttCommentDelimiter);
|
||||
TSetOfChar = set of Char;
|
||||
TComment = array[0..1] of string;
|
||||
TCharacterType = (ctSymbol, ctBeginComment, ctEndComment, ctDelimiter,
|
||||
ctString, ctSpecialChar);
|
||||
TCommentType = set of (cmt1, cmt2, cmt3);
|
||||
|
||||
const
|
||||
CR = #13;
|
||||
LF = #10;
|
||||
TAB = #9;
|
||||
CRLF = CR + LF;
|
||||
Delimiters: TSetOfChar = [' ', ',', ';', CR, LF, TAB];
|
||||
Comments: array[0..2] of TComment = (('/*', '*/'), ('#', LF), ('//', LF));
|
||||
|
||||
type
|
||||
TEndOfStatement = procedure(Sender: TObject; SQLStatement: String) of object;
|
||||
|
||||
TQueryParserComp = class(TComponent)
|
||||
private
|
||||
FStream: TStringStream;
|
||||
FEOF: Boolean;
|
||||
FToken: String;
|
||||
FTokenType: TTokenType;
|
||||
FComment: Boolean;
|
||||
FString: Boolean;
|
||||
FWasString: Boolean;
|
||||
FCommentType: TCommentType;
|
||||
FStringDelimiters: String;
|
||||
FLastStringDelimiterFound: String;
|
||||
FSymbolsCount: Integer;
|
||||
FSpecialCharacters: String;
|
||||
FRemoveStrDelimiter: Boolean;
|
||||
FStringToParse: String;
|
||||
FGoPosition: Integer;
|
||||
FOnStatementDelimiter: TEndOfStatement;
|
||||
FCountFromStatement: Boolean;
|
||||
FStatementDelimiters: TStringList;
|
||||
FStringDelimiter: Char;
|
||||
FGenerateOnStmtDelimiter: Boolean;
|
||||
procedure Init;
|
||||
procedure SetStringToParse(AStringToParse: String);
|
||||
function StatementDelimiter: Boolean;
|
||||
function CheckForBeginComment: Boolean;
|
||||
function CheckForEndComment(Character: Char): Boolean;
|
||||
function CharacterType(Character: Char): TCharacterType;
|
||||
function CheckCharcterType(Character: Char): Boolean;
|
||||
function StringDelimiter(Character: Char): Boolean;
|
||||
function SpecialCharacter(Character: Char): Boolean;
|
||||
procedure RemoveStringDelimiter(var Source: String);
|
||||
procedure SetDelimiterType(Source: String);
|
||||
procedure SetToken;
|
||||
procedure SetSD(ASD: TStringList);
|
||||
procedure SetSpecialCharacters(ASpecialCharacters: String);
|
||||
procedure SetStringDelimiters(AStringDelimiters: String);
|
||||
protected
|
||||
procedure DoStatementDelimiter; dynamic;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure LoadStringToParse(FileName: string);
|
||||
procedure First;
|
||||
procedure FirstToken;
|
||||
procedure NextToken;
|
||||
function GetNextSymbol : string;
|
||||
property EndOfFile: Boolean read FEOF;
|
||||
property Comment: Boolean read FComment;
|
||||
property Token: String read FToken;
|
||||
property TokenType: TTokenType read FTokenType;
|
||||
property CurrentStringDelimiter: Char read FStringDelimiter;
|
||||
property SymbolsCount: Integer read FSymbolsCount default 0;
|
||||
property StringStream: TStringStream read FStream;
|
||||
published
|
||||
property IsEOFStmtDelimiter: Boolean read FGenerateOnStmtDelimiter
|
||||
write FGenerateOnStmtDelimiter;
|
||||
property StringDelimiters: String read FStringDelimiters
|
||||
write SetStringDelimiters;
|
||||
property SpecialCharacters: String read FSpecialCharacters
|
||||
write SetSpecialCharacters;
|
||||
property RemoveStrDelimiter: Boolean read FRemoveStrDelimiter
|
||||
write FRemoveStrDelimiter;
|
||||
property CountFromStatement: Boolean read FCountFromStatement
|
||||
write FCountFromStatement;
|
||||
property TextToParse: String read FStringToParse
|
||||
write SetStringToParse;
|
||||
property StatementDelimiters: TStringList read FStatementDelimiters write SetSD;
|
||||
property OnStatementDelimiter: TEndOfStatement read FOnStatementDelimiter
|
||||
write FOnStatementDelimiter;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
{ TSQLParser }
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Samples', [TQueryParserComp]);
|
||||
end;
|
||||
|
||||
constructor TQueryParserComp.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
FStatementDelimiters := TStringList.Create;
|
||||
FStatementDelimiters.Add('GO');
|
||||
FStatementDelimiters.Add(';');
|
||||
FCountFromStatement := True;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.LoadStringToParse(FileName: string);
|
||||
var
|
||||
fs:TFileStream;
|
||||
size:integer;
|
||||
begin
|
||||
|
||||
fs:= TFileStream.Create(FileName, fmOpenRead);
|
||||
|
||||
size:= fs.Size;
|
||||
|
||||
if Assigned(FStream) then
|
||||
FStream.Free;
|
||||
|
||||
FStream := TStringStream.Create('');
|
||||
FStream.CopyFrom(fs,size);
|
||||
fs.Free;
|
||||
Init;
|
||||
First;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.FirstToken;
|
||||
begin
|
||||
Init;
|
||||
NextToken;
|
||||
end;
|
||||
|
||||
function TQueryParserComp.CheckForBeginComment: Boolean;
|
||||
var
|
||||
Buffer: String;
|
||||
begin
|
||||
Result := False;
|
||||
if not FEOF and not FString then
|
||||
begin
|
||||
Buffer := FStream.ReadString(1);
|
||||
if cmt1 in FCommentType then
|
||||
if Buffer[1] = '*' then
|
||||
begin
|
||||
FCommentType := [cmt1];
|
||||
Result := True;
|
||||
end;
|
||||
if cmt2 in FCommentType then
|
||||
if Buffer[1] = '/' then
|
||||
begin
|
||||
FCommentType := [cmt2];
|
||||
Result := True;
|
||||
end;
|
||||
if cmt3 in FCommentType then
|
||||
if Buffer[1] = '-' then
|
||||
begin
|
||||
FCommentType := [cmt3];
|
||||
Result := True;
|
||||
end;
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.SetDelimiterType(Source: String);
|
||||
begin
|
||||
FToken := Source[1];
|
||||
|
||||
if ((cmt2 in FCommentType) or (cmt3 in FCommentType)) and FComment
|
||||
and ((Source[1] = CR) or (Source[1] = LF)) then
|
||||
begin
|
||||
FComment := False;
|
||||
FTokenType := ttCommentDelimiter;
|
||||
end
|
||||
else
|
||||
FTokenType := ttDelimiter;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.NextToken;
|
||||
var
|
||||
Buffer: String;
|
||||
ETextNotSet: Exception;
|
||||
begin
|
||||
if FEOF then
|
||||
Exit;
|
||||
|
||||
if not Assigned(FStream) then
|
||||
begin
|
||||
ETextNotSet := Exception.Create(sTextNotSet);
|
||||
raise ETextNotSet;
|
||||
end;
|
||||
|
||||
if not FString then
|
||||
FStringDelimiter := ' ';
|
||||
|
||||
FToken := '';
|
||||
if not FEOF then
|
||||
begin
|
||||
Buffer := FStream.ReadString(1);
|
||||
if Length(Buffer) > 0 then
|
||||
begin
|
||||
if (Buffer[1] in Delimiters) and not (FString or FComment)then
|
||||
SetDelimiterType(Buffer)
|
||||
else
|
||||
begin
|
||||
if FStream.Position > 0 then
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
SetToken;
|
||||
end;
|
||||
end
|
||||
else
|
||||
FEOF := True;
|
||||
end;
|
||||
|
||||
case FTokenType of
|
||||
ttSymbol: Inc(FSymbolsCount);
|
||||
ttString:
|
||||
begin
|
||||
FStringDelimiter := FToken[1];
|
||||
if FRemoveStrDelimiter then
|
||||
RemoveStringDelimiter(FToken);
|
||||
end;
|
||||
end;
|
||||
|
||||
if StatementDelimiter then
|
||||
FTokenType := ttStatementDelimiter;
|
||||
|
||||
if FEOF then
|
||||
begin
|
||||
FLastStringDelimiterFound := '';
|
||||
FWasString := False;
|
||||
FString := False;
|
||||
|
||||
if FGenerateOnStmtDelimiter then
|
||||
DoStatementDelimiter;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQueryParserComp.GetNextSymbol : string;
|
||||
begin
|
||||
GetNextSymbol:= '';
|
||||
while ( not EndOfFile) do
|
||||
begin
|
||||
NextToken;
|
||||
if (TokenType=ttSymbol) then
|
||||
begin
|
||||
GetNextSymbol:= Token;
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
end;
|
||||
|
||||
function TQueryParserComp.StatementDelimiter: Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
if not FString then
|
||||
for i := 0 to FStatementDelimiters.Count - 1 do
|
||||
begin
|
||||
Result := (UpperCase(FToken) = UpperCase(FStatementDelimiters.Strings[i]));
|
||||
if Result then
|
||||
begin
|
||||
if FCountFromStatement then
|
||||
FSymbolsCount := 0;
|
||||
DoStatementDelimiter;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQueryParserComp.CharacterType(Character: Char): TCharacterType;
|
||||
begin
|
||||
Result := ctSymbol;
|
||||
case Character of
|
||||
'/':
|
||||
begin
|
||||
if not FComment then
|
||||
begin
|
||||
FCommentType := [cmt1, cmt2];
|
||||
if CheckForBeginComment then
|
||||
Result := ctBeginComment;
|
||||
end;
|
||||
end;
|
||||
'-':
|
||||
begin
|
||||
if not FComment then
|
||||
begin
|
||||
FCommentType := [cmt3];
|
||||
if CheckForBeginComment then
|
||||
Result := ctBeginComment;
|
||||
end;
|
||||
end;
|
||||
'*':
|
||||
begin
|
||||
if CheckForEndComment(Character) then
|
||||
Result := ctEndComment;
|
||||
end;
|
||||
CR, LF, ' ', ',', TAB:
|
||||
begin
|
||||
if CheckForEndComment(Character) then
|
||||
Result := ctEndComment
|
||||
else
|
||||
Result := ctDelimiter;
|
||||
|
||||
if FString and ((Character = CR) or (Character = LF)) then
|
||||
begin
|
||||
FString := False;
|
||||
FWasString := False;
|
||||
Result := ctDelimiter;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if not FString then
|
||||
if SpecialCharacter(Character) then
|
||||
begin
|
||||
if not FComment then
|
||||
Result := ctSpecialChar;
|
||||
end;
|
||||
|
||||
if not FComment then
|
||||
if StringDelimiter(Character) then
|
||||
begin
|
||||
Result := ctSymbol;
|
||||
if FString then
|
||||
begin
|
||||
FLastStringDelimiterFound := '';
|
||||
FWasString := True;
|
||||
FString := False;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FWasString := False;
|
||||
FString := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQueryParserComp.CheckForEndComment(Character: Char): Boolean;
|
||||
var
|
||||
Buffer: String;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if not FComment or FString then
|
||||
Exit;
|
||||
|
||||
if not FEOF then
|
||||
begin
|
||||
if cmt1 in FCommentType then
|
||||
begin
|
||||
Buffer := FStream.ReadString(1);
|
||||
if Buffer[1] = '/' then
|
||||
Result := True;
|
||||
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
end;
|
||||
if (cmt2 in FCommentType) or (cmt3 in FCommentType) then
|
||||
begin
|
||||
if (Character = CR) or (Character = LF) then
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQueryParserComp.CheckCharcterType(Character: Char): Boolean;
|
||||
var
|
||||
Buffer: String;
|
||||
begin
|
||||
Result := False;
|
||||
case CharacterType(Character) of
|
||||
ctBeginComment:
|
||||
begin
|
||||
if not FComment then
|
||||
begin
|
||||
if FToken <> '' then
|
||||
begin
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
FTokenType := ttSymbol;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FComment := True;
|
||||
FToken := FToken + Character;
|
||||
Buffer := FStream.ReadString(1);
|
||||
FToken := FToken + Buffer;
|
||||
FTokenType := ttComment;
|
||||
end;
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
ctEndComment:
|
||||
begin
|
||||
if FComment then
|
||||
begin
|
||||
Result := True;
|
||||
if FToken <> '' then
|
||||
begin
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
FTokenType := ttCommentedSymbol;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FComment := False;
|
||||
FToken := FToken + Character;
|
||||
if FCommentType = [cmt1] then
|
||||
begin
|
||||
Buffer := FStream.ReadString(1);
|
||||
FToken := FToken + Buffer;
|
||||
end;
|
||||
FTokenType := ttComment;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
ctSymbol:
|
||||
begin
|
||||
FToken := FToken + Character;
|
||||
if FComment then
|
||||
FTokenType := ttCommentedSymbol
|
||||
else
|
||||
begin
|
||||
if FString or FWasString then
|
||||
begin
|
||||
if FWasString then
|
||||
begin
|
||||
FTokenType := ttString;
|
||||
FWasString := False;
|
||||
|
||||
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
FTokenType := ttString;
|
||||
end
|
||||
else
|
||||
FTokenType := ttSymbol;
|
||||
end;
|
||||
end;
|
||||
ctSpecialChar:
|
||||
begin
|
||||
if FToken <> '' then
|
||||
begin
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
FTokenType := ttSymbol;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FToken := FToken + Character;
|
||||
FTokenType := ttSpecialChar;
|
||||
end;
|
||||
Result := True;
|
||||
end;
|
||||
ctDelimiter:
|
||||
begin
|
||||
FTokenType := ttDelimiter;
|
||||
Result := True;
|
||||
end;
|
||||
end
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.RemoveStringDelimiter(var Source: String);
|
||||
var
|
||||
EndOfString: Integer;
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 1 to Length(FStringDelimiters) do
|
||||
begin
|
||||
EndOfString := 1;
|
||||
while not (EndOfString = 0) do
|
||||
begin
|
||||
EndOfString := Pos(FStringDelimiters[i], Source);
|
||||
if EndOfString <> 0 then
|
||||
begin
|
||||
FLastStringDelimiterFound := Copy(FStringDelimiters, i, 1);
|
||||
Delete(Source, EndOfString, 1);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQueryParserComp.StringDelimiter(Character: Char): Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
Buffer: String;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
for i := 1 to Length(FStringDelimiters) do
|
||||
if (Character = FStringDelimiters[i]) then
|
||||
begin
|
||||
if (FLastStringDelimiterFound = '') then
|
||||
FLastStringDelimiterFound := FStringDelimiters[i];
|
||||
|
||||
if (FLastStringDelimiterFound = FStringDelimiters[i]) then
|
||||
begin
|
||||
if not FEOF then
|
||||
Buffer := FStream.ReadString(1);
|
||||
|
||||
if Length(Buffer) > 0 then
|
||||
begin
|
||||
if Buffer[1] <> Character then
|
||||
begin
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
FToken := FToken + Buffer;
|
||||
end
|
||||
else
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQueryParserComp.SpecialCharacter(Character: Char): Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
for i := 1 to Length(FSpecialCharacters) do
|
||||
if Character = FSpecialCharacters[i] then
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.SetToken;
|
||||
var
|
||||
EndToken: Boolean;
|
||||
Buffer: String;
|
||||
begin
|
||||
EndToken := False;
|
||||
while not (EndToken or FEOF) do
|
||||
begin
|
||||
FEOF := FStream.Position >= FStream.Size-1;
|
||||
Buffer := FStream.ReadString(1);
|
||||
|
||||
if not (Buffer[1] in Delimiters) then
|
||||
EndToken := CheckCharcterType(Buffer[1])
|
||||
else
|
||||
begin
|
||||
if not (FString or FComment) then
|
||||
begin
|
||||
EndToken := True;
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
end
|
||||
else
|
||||
begin
|
||||
if FString and ((Buffer[1] = CR) or (Buffer[1] = LF)) then
|
||||
begin
|
||||
FString := False;
|
||||
FWasString := False;
|
||||
EndToken := True;
|
||||
end
|
||||
else
|
||||
if FComment and ((cmt2 in FCommentType) or
|
||||
(cmt3 in FCommentType)) and ((Buffer[1] = CR) or
|
||||
(Buffer[1] = LF)) then
|
||||
begin
|
||||
EndToken := True;
|
||||
FStream.Seek(-1, soFromCurrent);
|
||||
FComment := False;
|
||||
FCommentType := [];
|
||||
end
|
||||
else
|
||||
FToken := FToken + Buffer;
|
||||
end;
|
||||
end;
|
||||
end; //while
|
||||
end;
|
||||
|
||||
destructor TQueryParserComp.Destroy;
|
||||
begin
|
||||
if Assigned(FStream) then
|
||||
FStream.Free;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.DoStatementDelimiter;
|
||||
var
|
||||
Buffer: String;
|
||||
CurrentPosition: Integer;
|
||||
begin
|
||||
if Assigned(FOnStatementDelimiter) then
|
||||
begin
|
||||
CurrentPosition := FStream.Position;
|
||||
FStream.Seek(FGoPosition, soFromBeginning);
|
||||
Buffer := FStream.ReadString(CurrentPosition-FGoPosition-Length(FToken));
|
||||
FStream.Seek(Length(FToken), soFromCurrent);
|
||||
if FStream.Position >= FStream.Size then
|
||||
FEOF := True;
|
||||
|
||||
FGoPosition := FStream.Position;
|
||||
|
||||
if FCountFromStatement then
|
||||
FSymbolsCount := 0;
|
||||
|
||||
FOnStatementDelimiter(Self, Trim(Buffer));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.SetStringToParse(AStringToParse: String);
|
||||
begin
|
||||
|
||||
if AStringToParse = '' then
|
||||
Exit;
|
||||
|
||||
if Assigned(FStream) then
|
||||
FStream.Free;
|
||||
|
||||
TrimRight(AStringToParse);
|
||||
FStream := TStringStream.Create(AStringToParse);
|
||||
FStringToParse := AStringToParse;
|
||||
|
||||
Init;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.SetSD(ASD: TStringList);
|
||||
begin
|
||||
FStatementDelimiters.Assign(ASD);
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.First;
|
||||
begin
|
||||
Init;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.Init;
|
||||
var
|
||||
ETextNotSet: Exception;
|
||||
begin
|
||||
if not Assigned(FStream) then
|
||||
begin
|
||||
ETextNotSet := Exception.Create(sTextNotSet);
|
||||
raise ETextNotSet;
|
||||
end;
|
||||
|
||||
FStream.Seek(0, soFromBeginning);
|
||||
FToken := '';
|
||||
FTokenType := ttString;
|
||||
FComment := False;
|
||||
FCommentType := [];
|
||||
FEOF := False;
|
||||
FSymbolsCount := 0;
|
||||
FGoPosition := 0;
|
||||
FLastStringDelimiterFound := '';
|
||||
FWasString := False;
|
||||
FString := False;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.SetSpecialCharacters(ASpecialCharacters: String);
|
||||
var
|
||||
i: Integer;
|
||||
k: Integer;
|
||||
IllegalSpecialChar: Exception;
|
||||
begin
|
||||
for i := 1 to Length(ASpecialCharacters) do
|
||||
begin
|
||||
for k := 0 to FStatementDelimiters.Count - 1 do
|
||||
begin
|
||||
if (Pos(ASpecialCharacters[i], FStatementDelimiters.Strings[k]) <> 0) then
|
||||
begin
|
||||
IllegalSpecialChar := Exception.Create(sIllegalSpecialChar);
|
||||
raise IllegalSpecialChar;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (ASpecialCharacters[i] in Delimiters) or
|
||||
(Pos(ASpecialCharacters[i], FStringDelimiters) <> 0) then
|
||||
begin
|
||||
IllegalSpecialChar := Exception.Create(sIllegalSpecialChar);
|
||||
raise IllegalSpecialChar;
|
||||
end;
|
||||
end;
|
||||
|
||||
FSpecialCharacters := ASpecialCharacters;
|
||||
end;
|
||||
|
||||
procedure TQueryParserComp.SetStringDelimiters(AStringDelimiters: String);
|
||||
var
|
||||
i: Integer;
|
||||
k: Integer;
|
||||
IllegalStringChar: Exception;
|
||||
begin
|
||||
for i := 1 to Length(AStringDelimiters) do
|
||||
begin
|
||||
for k := 0 to FStatementDelimiters.Count - 1 do
|
||||
begin
|
||||
if (Pos(AStringDelimiters[i], FStatementDelimiters.Strings[k]) <> 0) then
|
||||
begin
|
||||
IllegalStringChar := Exception.Create(sIllegalStringChar);
|
||||
raise IllegalStringChar;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (AStringDelimiters[i] in Delimiters) or
|
||||
(Pos(AStringDelimiters[i], FSpecialCharacters) <> 0) then
|
||||
begin
|
||||
IllegalStringChar := Exception.Create(sIllegalStringChar);
|
||||
raise IllegalStringChar;
|
||||
end;
|
||||
end;
|
||||
|
||||
FStringDelimiters := AStringDelimiters;
|
||||
end;
|
||||
|
||||
end.
|
||||
493
old/Unit1.pas
493
old/Unit1.pas
@@ -1,493 +0,0 @@
|
||||
unit Unit1;
|
||||
|
||||
(*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
ai_driver,mtable,mover,mctools,Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, ExtCtrls;
|
||||
|
||||
type
|
||||
TForm1 = class(TForm)
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
Button3: TButton;
|
||||
Button4: TButton;
|
||||
Button5: TButton;
|
||||
Button6: TButton;
|
||||
Label2: TLabel;
|
||||
Label3: TLabel;
|
||||
Timer1: TTimer;
|
||||
Label4: TLabel;
|
||||
Label5: TLabel;
|
||||
Label6: TLabel;
|
||||
Label9: TLabel;
|
||||
Label10: TLabel;
|
||||
Label11: TLabel;
|
||||
Button7: TButton;
|
||||
Button8: TButton;
|
||||
Label12: TLabel;
|
||||
Label13: TLabel;
|
||||
Label14: TLabel;
|
||||
Label15: TLabel;
|
||||
Button9: TButton;
|
||||
Button10: TButton;
|
||||
Label16: TLabel;
|
||||
Label17: TLabel;
|
||||
Label18: TLabel;
|
||||
Label19: TLabel;
|
||||
Button11: TButton;
|
||||
Label20: TLabel;
|
||||
Label21: TLabel;
|
||||
Label22: TLabel;
|
||||
Label23: TLabel;
|
||||
Label24: TLabel;
|
||||
Label25: TLabel;
|
||||
lczas: TLabel;
|
||||
Label28: TLabel;
|
||||
Label29: TLabel;
|
||||
Label30: TLabel;
|
||||
Label31: TLabel;
|
||||
Label32: TLabel;
|
||||
Label33: TLabel;
|
||||
Label34: TLabel;
|
||||
Button12: TButton;
|
||||
BStart: TButton;
|
||||
Label35: TLabel;
|
||||
Label36: TLabel;
|
||||
Label37: TLabel;
|
||||
Label38: TLabel;
|
||||
Button13: TButton;
|
||||
Label39: TLabel;
|
||||
Label40: TLabel;
|
||||
Label41: TLabel;
|
||||
Label42: TLabel;
|
||||
Label43: TLabel;
|
||||
Button14: TButton;
|
||||
Button15: TButton;
|
||||
Label44: TLabel;
|
||||
Label45: TLabel;
|
||||
Label46: TLabel;
|
||||
Label47: TLabel;
|
||||
BMains: TButton;
|
||||
Label48: TLabel;
|
||||
Label49: TLabel;
|
||||
Label50: TLabel;
|
||||
Panel1: TPanel;
|
||||
Label1: TLabel;
|
||||
OpenDialog1: TOpenDialog;
|
||||
Edit1: TEdit;
|
||||
GroupBox1: TGroupBox;
|
||||
CheckBox1: TCheckBox;
|
||||
BSInc: TButton;
|
||||
BSDec: TButton;
|
||||
Label51: TLabel;
|
||||
Label52: TLabel;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure Button5Click(Sender: TObject);
|
||||
procedure Button6Click(Sender: TObject);
|
||||
procedure Button7Click(Sender: TObject);
|
||||
procedure Button8Click(Sender: TObject);
|
||||
procedure Button3Click(Sender: TObject);
|
||||
procedure Button4Click(Sender: TObject);
|
||||
procedure Button9Click(Sender: TObject);
|
||||
procedure Button10Click(Sender: TObject);
|
||||
procedure Button11Click(Sender: TObject);
|
||||
procedure Button12Click(Sender: TObject);
|
||||
procedure BStartClick(Sender: TObject);
|
||||
procedure Button13MouseDown(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
procedure Button14Click(Sender: TObject);
|
||||
procedure Button15Click(Sender: TObject);
|
||||
procedure BMainsClick(Sender: TObject);
|
||||
procedure CheckBox1Click(Sender: TObject);
|
||||
procedure BSIncClick(Sender: TObject);
|
||||
procedure BSDecClick(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
const
|
||||
mtno=30;
|
||||
tno:integer=0;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
loc:TMoverParameters;
|
||||
wagony:array[1..mtno] of TMoverParameters;
|
||||
mechanik: TController;
|
||||
pociag: TTrainParameters;
|
||||
couplerflag:byte;
|
||||
l0,l0p:TLocation;
|
||||
ll:array[1..mtno] of TLocation;
|
||||
r0:TRotation;
|
||||
rr:array[1..mtno] of TRotation;
|
||||
Shape:TTrackShape; Track:TTrackParam;
|
||||
ExternalVoltage:real;
|
||||
ActualTime:real;
|
||||
fout: text;
|
||||
OK:boolean;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.DFM}
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
var typename,path:string;slashpos:byte;
|
||||
begin
|
||||
|
||||
couplerflag:=strtoint(Edit1.Text);
|
||||
if tno>0 then
|
||||
wagony[tno]:=TMoverParameters.Create;
|
||||
|
||||
OpenDialog1.Execute;
|
||||
path:='';
|
||||
typename:=OpenDialog1.Filename;
|
||||
repeat
|
||||
slashpos:=pos('\',typename);
|
||||
if slashpos>0 then
|
||||
typename:=copy(typename,slashpos+1,length(typename));
|
||||
until slashpos=0;
|
||||
path:=copy(opendialog1.filename,1,length(opendialog1.filename)-length(typename));
|
||||
typename:=Copy(typename,1,Pos('.chk',typename)-1);
|
||||
|
||||
if tno=0 then
|
||||
begin
|
||||
loc.Init(l0,r0,0,typename,'lokomotywa',0,'',1);
|
||||
OK:=loc.loadchkfile(path) and loc.CheckLocomotiveParameters(Go);
|
||||
if OK then
|
||||
begin
|
||||
Label1.Caption:=loc.TypeName;
|
||||
case loc.AutoRelayType of
|
||||
2: CheckBox1.Enabled:=True;
|
||||
1: CheckBox1.Checked:=True;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
wagony[tno].Init(ll[tno],rr[tno],0,typename,IntToStr(tno),0,'',0);
|
||||
OK:=OK and (wagony[tno].loadchkfile(path) and wagony[tno].CheckLocomotiveParameters(Go));
|
||||
if OK then
|
||||
begin
|
||||
Label1.Caption:=Label1.Caption+' '+wagony[tno].TypeName;
|
||||
if tno=1 then
|
||||
ll[tno].x:=loc.Loc.x-loc.Dim.L/2-wagony[tno].Dim.L/2
|
||||
else
|
||||
ll[tno].x:=wagony[tno-1].Loc.x-wagony[tno-1].Dim.L/2-wagony[tno].Dim.L/2;
|
||||
wagony[tno].loc:=ll[tno];
|
||||
if tno=1 then
|
||||
begin
|
||||
OK:=OK and loc.attach(2,@wagony[1],couplerflag);
|
||||
OK:=OK and wagony[1].attach(1,@loc,couplerflag);
|
||||
end
|
||||
else
|
||||
begin
|
||||
OK:=OK and wagony[tno-1].attach(2,@wagony[tno],couplerflag);
|
||||
OK:=OK and wagony[tno].attach(1,@wagony[tno-1],couplerflag);
|
||||
end
|
||||
end;
|
||||
end;
|
||||
|
||||
if OK then
|
||||
begin
|
||||
BStart.Enabled:=True;
|
||||
if tno=mtno then button1.enabled:=false
|
||||
else inc(tno);
|
||||
Label49.Caption:='ilosc pojazdow '+inttostr(tno);
|
||||
end
|
||||
else
|
||||
begin
|
||||
Label1.Caption:=inttostr(conversionerror)+' '+inttostr(linecount);
|
||||
Button1.Enabled:=False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button2Click(Sender: TObject);
|
||||
var iw:integer;
|
||||
begin
|
||||
if Timer1.Enabled then
|
||||
begin
|
||||
Timer1.Enabled:=False;
|
||||
CloseFile(fout);
|
||||
end;
|
||||
mechanik.CloseLog;
|
||||
mechanik.free;
|
||||
loc.Free;
|
||||
for iw:=1 to tno do
|
||||
wagony[iw].Free;
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.Timer1Timer(Sender: TObject);
|
||||
var dl,dt:real; iw:integer;
|
||||
begin
|
||||
dt:=Timer1.Interval/1000;
|
||||
ActualTime:=ActualTime+dt;
|
||||
if l0.x>200 then Shape.R:=1000;
|
||||
if l0.x>1000 then Shape.R:=-500;
|
||||
if l0.x>1500 then Shape.R:=0;
|
||||
if l0.x>2000 then Shape.R:=1500;
|
||||
if l0.x>2200 then Shape.R:=3000;
|
||||
if l0.x>2400 then Shape.R:=0;
|
||||
loc.ComputeTotalForce(dt);
|
||||
for iw:=1 to tno do
|
||||
wagony[iw].ComputeTotalForce(dt);
|
||||
dl:=loc.ComputeMovement(dt,Shape,Track,ExternalVoltage,l0,r0);
|
||||
l0.x:=l0.x+dl;
|
||||
for iw:=1 to tno do
|
||||
begin
|
||||
dl:=wagony[iw].ComputeMovement(dt,Shape,Track,ExternalVoltage,ll[iw],rr[iw]);
|
||||
ll[iw].x:=ll[iw].x+dl;
|
||||
end;
|
||||
|
||||
mechanik.UpdateSituation(dt);
|
||||
|
||||
|
||||
l0p.x:=500; l0p.y:=2; l0.z:=0;
|
||||
if (l0.x>-1) and (l0.x<5) then
|
||||
loc.PutCommand('SetVelocity',60,-1,l0p);
|
||||
if (l0.x>499) and (l0.x<505) then
|
||||
loc.PutCommand('SetVelocity',-1,-1,l0);
|
||||
l0p.x:=3600;
|
||||
if (l0.x>2985) and (l0.x<3005) then
|
||||
loc.PutCommand('SetVelocity',-1,0,l0p);
|
||||
if (l0.x>3600) and (l0.x<3615) then
|
||||
loc.PutCommand('SetVelocity',0,0,l0);
|
||||
if (l0.x>3430) and (loc.Vel<0.01) and (mechanik.GetCurrentOrder=Obey_train) then
|
||||
loc.PutCommand('SetVelocity',0,0,l0);
|
||||
|
||||
if (loc.power>0) then
|
||||
begin
|
||||
Label2.Caption:='I0='+r2s(Loc.Im,0)+' A';
|
||||
Label3.Caption:=r2s(Loc.Ft/1000,0)+' kN';
|
||||
Label13.Caption:=IntToStr(Loc.MainCtrlPos);
|
||||
Label18.Caption:=IntToStr(Loc.ScndCtrlPos);
|
||||
Label20.Caption:=IntToStr(Loc.MainCtrlActualPos);
|
||||
Label21.Caption:=IntToStr(Loc.ScndCtrlActualPos);
|
||||
end
|
||||
else
|
||||
for iw:=1 to tno do
|
||||
if wagony[iw].power>0 then
|
||||
begin
|
||||
Label2.Caption:='I'+IntToStr(iw)+'='+r2s(wagony[iw].Im,0)+' A';
|
||||
Label3.Caption:=r2s(wagony[iw].Ft/1000,0)+' kN';
|
||||
Label13.Caption:=IntToStr(wagony[iw].MainCtrlPos);
|
||||
Label18.Caption:=IntToStr(wagony[iw].ScndCtrlPos);
|
||||
Label20.Caption:=IntToStr(wagony[iw].MainCtrlActualPos);
|
||||
Label21.Caption:=IntToStr(wagony[iw].ScndCtrlActualPos);
|
||||
end;
|
||||
Label4.Caption:=r2s(l0.x,0)+' m';
|
||||
Label5.Caption:=r2s(Sign(Loc.V)*Loc.Vel,0)+' km/h';
|
||||
Label6.Caption:=r2s(Loc.AccS,0)+' m/ss';
|
||||
Label9.Caption:=r2s(Loc.Fb/1000,0)+' kN';
|
||||
Label10.Caption:=r2s(Loc.Compressor,0)+' MPa';
|
||||
Label11.Caption:=r2s(Loc.PipePress,0)+' MPa';
|
||||
Label12.Caption:=r2s(Loc.BrakePress,0)+' MPa';
|
||||
|
||||
|
||||
Label14.Caption:=IntToStr(Loc.BrakeCtrlPos);
|
||||
Label15.Caption:=IntToStr(Loc.LocalBrakePos);
|
||||
|
||||
Label16.Caption:=IntToStr(Loc.showcurrent(1));
|
||||
Label17.Caption:=IntToStr(Loc.showcurrent(2));
|
||||
|
||||
if loc.SlippingWheels then
|
||||
Label19.Caption:='Poslizg!'
|
||||
else Label19.Caption:=' ';
|
||||
|
||||
|
||||
Label22.Caption:=r2s(ll[1].x,0)+' m';
|
||||
if tno>=1 then
|
||||
begin
|
||||
Label23.Caption:=r2s(Sign(wagony[1].V)*wagony[1].Vel,0)+' km/h';
|
||||
Label24.Caption:=r2s(Distance(loc.loc,wagony[1].loc,loc.dim,wagony[1].dim),0)+' m';
|
||||
end;
|
||||
Label25.Caption:=r2s(loc.nrot,0)+' 1/s';
|
||||
|
||||
Label28.Caption:=r2s(ll[2].x,0)+' m';
|
||||
|
||||
if tno>=2 then
|
||||
Label29.Caption:=r2s(sign(wagony[2].V)*wagony[2].Vel,0)+' km/h';
|
||||
|
||||
Label30.Caption:=r2s(loc.dpLocalValve/dt,0)+' MPa/s';
|
||||
Label31.Caption:=r2s(loc.dpBrake/dt,0)+' MPa/s';
|
||||
Label32.Caption:=r2s(loc.dpMainValve/dt,0)+' MPa/s';
|
||||
Label33.Caption:=r2s(loc.dpPipe/dt,0)+' MPa/s';
|
||||
|
||||
if tno>0 then Label34.Caption:=r2s(wagony[tno].PipePress,0)+' MPa';
|
||||
|
||||
Label35.Caption:=r2s(ll[3].x,0)+' m';
|
||||
if tno>0 then Label36.Caption:=r2s(sign(wagony[tno].V)*wagony[tno].Vel,0)+' km/h';
|
||||
if tno>0 then Label37.Caption:=r2s(wagony[tno].couplers[1].cforce/1000,0)+' kN';
|
||||
if tno>0 then Label38.Caption:=r2s(wagony[tno].brakepress,0)+' MPa';
|
||||
|
||||
Label39.Caption:=r2s(loc.enginePower/1000,0)+' kW';
|
||||
Label40.Caption:=i2s(trunc(loc.Rventrot*60))+' /min';
|
||||
Label41.Visible:=loc.SandDose;
|
||||
Label42.Caption:=r2s(mechanik.accdesired,0)+' m/ss';
|
||||
Label43.Caption:=r2s(mechanik.veldesired,0)+' km/h';
|
||||
if tno>0 then Label44.Caption:=r2s(ll[tno].x,0)+' m';
|
||||
Label45.Caption:=inttostr(loc.activedir);
|
||||
Label46.Caption:=inttostr(ord(mechanik.orderlist[mechanik.orderpos]));
|
||||
Label47.Caption:=inttostr(mechanik.orderpos);
|
||||
Label48.Caption:=inttostr(ord(loc.mains));
|
||||
{ if tno>0 then Label51.Caption:=wagony[1].CommandIn.Command;
|
||||
if tno>0 then Label52.Caption:=r2s(wagony[1].CommandIn.Value1,0);
|
||||
}
|
||||
Label51.Caption:=loc.CommandIn.Command;
|
||||
Label52.Caption:=r2s(loc.CommandIn.Value1,0);
|
||||
Lczas.Caption:=r2s(actualtime,0)+' s';
|
||||
writeln(fout,Actualtime,' ',{loc.v-wag.v,}loc.UnitBrakeForce,' ',loc.dpMainValve,{' ',loc.dpLocalValve,}' ',loc.accs,' ',loc.couplers[2].cforce,' ',{,l1.x}' '{,Distance(loc.loc,wagony[1].loc,loc.dim,wagony[1].dim)});
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
var iw:integer;
|
||||
begin
|
||||
Timer1.Enabled:=False;
|
||||
tno:=0;
|
||||
assignfile(fout,'log.dat');
|
||||
rewrite(fout);
|
||||
ActualTime:=0;
|
||||
loc:=TMoverParameters.Create;
|
||||
Shape.R:=0; Shape.Len:=10000; Shape.dHtrack:=0; Shape.dHrail:=0;
|
||||
Track.Width:=1435; Track.friction:=0.15; Track.CategoryFlag:=1;
|
||||
Track.QualityFlag:=25; Track.DamageFlag:=0;
|
||||
Track.VelMax:=120;
|
||||
ExternalVoltage:=3000;
|
||||
l0.x:=0; l0.y:=0; l0.z:=0;
|
||||
r0.rx:=0; r0.ry:=0; r0.rz:=0;
|
||||
for iw:=1 to mtno do
|
||||
begin
|
||||
rr[iw].rx:=0; rr[iw].ry:=0; rr[iw].rz:=0;
|
||||
ll[iw].x:=0; ll[iw].y:=0; ll[iw].z:=0;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TForm1.Button5Click(Sender: TObject);
|
||||
begin
|
||||
loc.incbrakelevel;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button6Click(Sender: TObject);
|
||||
begin
|
||||
loc.decbrakelevel;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button7Click(Sender: TObject);
|
||||
begin
|
||||
loc.inclocalbrakelevel(1);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button8Click(Sender: TObject);
|
||||
begin
|
||||
loc.declocalbrakelevel(1);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button3Click(Sender: TObject);
|
||||
begin
|
||||
loc.incmainctrl(1);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button4Click(Sender: TObject);
|
||||
begin
|
||||
loc.decmainctrl(1);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button9Click(Sender: TObject);
|
||||
begin
|
||||
loc.DirectionForward;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button10Click(Sender: TObject);
|
||||
begin
|
||||
loc.DirectionBackward;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button11Click(Sender: TObject);
|
||||
begin
|
||||
loc.FuseOn;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button12Click(Sender: TObject);
|
||||
begin
|
||||
Loc.AntiSlippingBrake;
|
||||
end;
|
||||
|
||||
procedure TForm1.BStartClick(Sender: TObject);
|
||||
begin
|
||||
tno:=tno-1;
|
||||
Button1.Enabled:=False;
|
||||
Edit1.Enabled:=False;
|
||||
Timer1.Enabled:=True;
|
||||
mechanik:=TController.Create;
|
||||
pociag:=TTrainParameters.Create;
|
||||
pociag.init('Testowy Express',100);
|
||||
mechanik.init(l0,r0,HumanDriver,@loc,@pociag,Aggressive);
|
||||
|
||||
BStart.Enabled:=False;
|
||||
Button14.enabled:=True;
|
||||
Button15.enabled:=True;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button13MouseDown(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
loc.SandDoseOn;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button14Click(Sender: TObject);
|
||||
begin
|
||||
mechanik.SetVelocity(30,120);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button15Click(Sender: TObject);
|
||||
begin
|
||||
mechanik.AIControllFlag:=not mechanik.AIControllFlag;
|
||||
if not loc.mains then
|
||||
begin
|
||||
mechanik.ChangeOrder(Prepare_Engine);
|
||||
mechanik.JumpToNextOrder;
|
||||
mechanik.ChangeOrder(Obey_train);
|
||||
mechanik.JumpToNextOrder;
|
||||
mechanik.ChangeOrder(Release_engine);
|
||||
mechanik.JumpToFirstOrder;
|
||||
mechanik.SetVelocity(60,120);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.BMainsClick(Sender: TObject);
|
||||
begin
|
||||
loc.MainSwitch;
|
||||
end;
|
||||
|
||||
procedure TForm1.CheckBox1Click(Sender: TObject);
|
||||
begin
|
||||
loc.autorelayswitch;
|
||||
end;
|
||||
|
||||
procedure TForm1.BSIncClick(Sender: TObject);
|
||||
begin
|
||||
loc.incscndctrl(1);
|
||||
end;
|
||||
|
||||
procedure TForm1.BSDecClick(Sender: TObject);
|
||||
begin
|
||||
loc.decscndctrl(1);
|
||||
end;
|
||||
|
||||
end.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user