2 Copyright (C) 2004-2011 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 if ((think > 0) || (!active))
42 if ((think > 0) || (!active))
61 bool Train::isMoving()
69 bool Train::waitsForPlayer()
71 if ((active) || (pause != 0))
77 void Train::setName(const char *name)
79 strlcpy(this->name, name, sizeof this->name);
82 void Train::set(int startX, int startY, int endX, int endY, int pause, bool fromStart)
84 this->startX = startX;
85 this->startY = startY;
92 Math::calculateSlope(startX, startY, endX, endY, &dx, &dy);
94 if ((dx != 0) && (dy != 0))
95 debug(("WARNING: TRAIN '%s' is not straight! - %d %d %d %d\n", name, startX, startY, endX, endY));
99 this->x = this->startX;
100 this->y = this->startY;
105 this->x = this->endX;
106 this->y = this->endY;
107 if (type == TR_TRAIN)
116 bool Train::openClose()
118 Math::limitInt(&(--think), 0, 9999);
122 if ((x > startX) || (y > startY))
127 if ((x == startX) && (y == startY))
135 if ((x < endX) || (y < endY))
140 if ((x == endX) && (y == endY))
162 if (((x >= endX) && (y >= endY)) || ((x <= startX) && (y <= startY)))
172 if ((x <= startX) && (y <= startY) && (waitAtStart))
178 if ((x >= endX) && (y >= endY) && (!waitAtStart))
187 int Train::getPause()