mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-16 07:39:52 +00:00
Compare commits
1 Commits
release/0.4
..
0.3.5
| Author | SHA1 | Date | |
|---|---|---|---|
| f788b1aa28 |
@@ -1,233 +0,0 @@
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = openttd
|
||||
OUTPUT_DIRECTORY = docs/source/
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH = ./
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 2
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ./
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cpp \
|
||||
*.c++ \
|
||||
*.h \
|
||||
table/*.h
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = YES
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = YES
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = YES
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE = openttd.tag
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// ttd.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
+429
-412
File diff suppressed because it is too large
Load Diff
+55
-46
@@ -1,10 +1,7 @@
|
||||
/* $Id$ */
|
||||
#ifndef AI_H
|
||||
#define AI_H
|
||||
|
||||
#ifndef AI_TROLLY_H
|
||||
#define AI_TROLLY_H
|
||||
|
||||
#include "../../aystar.h"
|
||||
#include "../../player.h"
|
||||
#include "aystar.h"
|
||||
|
||||
/*
|
||||
* These defines can be altered to change the behavoir of the AI
|
||||
@@ -40,8 +37,6 @@
|
||||
#define AI_PATHFINDER_PENALTY 150
|
||||
// The penalty given to a tile that is going up
|
||||
#define AI_PATHFINDER_TILE_GOES_UP_PENALTY 450
|
||||
// The penalty given to a tile which would have to use fundation
|
||||
#define AI_PATHFINDER_FOUNDATION_PENALTY 100
|
||||
// Changing direction is a penalty, to prevent curved ways (with that: slow ways)
|
||||
#define AI_PATHFINDER_DIRECTION_CHANGE_PENALTY 200
|
||||
// Same penalty, only for when road already exists
|
||||
@@ -76,7 +71,7 @@
|
||||
#define AI_LOCATE_ROUTE_MAX_COUNTER 200
|
||||
|
||||
// How many days must there be between building the first station and the second station
|
||||
// within one city. This number is in days and should be more than 4 months.
|
||||
// within one city. This number is in days and should be more then 4 months.
|
||||
#define AI_CHECKCITY_DATE_BETWEEN 180
|
||||
|
||||
// How many cargo is needed for one station in a city?
|
||||
@@ -135,7 +130,7 @@
|
||||
// reuse the station instead of building a new one!
|
||||
#define AI_STATION_REUSE_MULTIPLER 2
|
||||
|
||||
// No more than this amount of vehicles per station..
|
||||
// No more then this amount of vehicles per station..
|
||||
#define AI_CHECK_MAX_VEHICLE_PER_STATION 10
|
||||
|
||||
// How many thick between building 2 vehicles
|
||||
@@ -154,7 +149,7 @@
|
||||
// while old vehicles stay longer, because we do get less in return.
|
||||
#define AI_MINIMUM_ROUTE_PROFIT 1000
|
||||
|
||||
// A vehicle is considered lost when he his cargo is more than 180 days old
|
||||
// A vehicle is considered lost when he his cargo is more then 180 days old
|
||||
#define AI_VEHICLE_LOST_DAYS 180
|
||||
|
||||
// How many times may the AI try to find a route before it gives up
|
||||
@@ -166,34 +161,40 @@
|
||||
|
||||
// This stops 90degrees curves
|
||||
static const byte _illegal_curves[6] = {
|
||||
255, 255, // Horz and vert, don't have the effect
|
||||
5, // upleft and upright are not valid
|
||||
4, // downright and downleft are not valid
|
||||
2, // downleft and upleft are not valid
|
||||
3, // upright and downright are not valid
|
||||
255, 255, // Horz and vert, don't have the effect
|
||||
5, // upleft and upright are not valid
|
||||
4, // downright and downleft are not valid
|
||||
2, // downleft and upleft are not valid
|
||||
3, // upright and downright are not valid
|
||||
};
|
||||
|
||||
static const TileIndexDiff _tiles_around[4] = {
|
||||
TILE_XY(-1,0),
|
||||
TILE_XY(0,1),
|
||||
TILE_XY(1,0),
|
||||
TILE_XY(0,-1),
|
||||
};
|
||||
|
||||
enum {
|
||||
AI_STATE_STARTUP = 0,
|
||||
AI_STATE_FIRST_TIME,
|
||||
AI_STATE_NOTHING,
|
||||
AI_STATE_WAKE_UP,
|
||||
AI_STATE_LOCATE_ROUTE,
|
||||
AI_STATE_FIND_STATION,
|
||||
AI_STATE_FIND_PATH,
|
||||
AI_STATE_FIND_DEPOT,
|
||||
AI_STATE_VERIFY_ROUTE,
|
||||
AI_STATE_BUILD_STATION,
|
||||
AI_STATE_BUILD_PATH,
|
||||
AI_STATE_BUILD_DEPOT,
|
||||
AI_STATE_BUILD_VEHICLE,
|
||||
AI_STATE_WAIT_FOR_BUILD,
|
||||
AI_STATE_GIVE_ORDERS,
|
||||
AI_STATE_START_VEHICLE,
|
||||
AI_STATE_REPAY_MONEY,
|
||||
AI_STATE_STARTUP = 0,
|
||||
AI_STATE_FIRST_TIME,
|
||||
AI_STATE_NOTHING,
|
||||
AI_STATE_WAKE_UP,
|
||||
AI_STATE_LOCATE_ROUTE,
|
||||
AI_STATE_FIND_STATION,
|
||||
AI_STATE_FIND_PATH,
|
||||
AI_STATE_FIND_DEPOT,
|
||||
AI_STATE_VERIFY_ROUTE,
|
||||
AI_STATE_BUILD_STATION,
|
||||
AI_STATE_BUILD_PATH,
|
||||
AI_STATE_BUILD_DEPOT,
|
||||
AI_STATE_BUILD_VEHICLE,
|
||||
AI_STATE_GIVE_ORDERS,
|
||||
AI_STATE_START_VEHICLE,
|
||||
AI_STATE_REPAY_MONEY,
|
||||
AI_STATE_CHECK_ALL_VEHICLES,
|
||||
AI_STATE_ACTION_DONE,
|
||||
AI_STATE_STOP, // Temporary function to stop the AI
|
||||
AI_STATE_ACTION_DONE,
|
||||
AI_STATE_STOP, // Temporary function to stop the AI
|
||||
};
|
||||
|
||||
// Used for tbt (train/bus/truck)
|
||||
@@ -213,7 +214,7 @@ enum {
|
||||
|
||||
// Used for from_type/to_type
|
||||
enum {
|
||||
AI_NO_TYPE = 0,
|
||||
AI_NO_TYPE = 0,
|
||||
AI_CITY,
|
||||
AI_INDUSTRY,
|
||||
};
|
||||
@@ -226,7 +227,7 @@ enum {
|
||||
|
||||
#define AI_NO_CARGO 0xFF // Means that there is no cargo defined yet (used for industry)
|
||||
#define AI_NEED_CARGO 0xFE // Used when the AI needs to find out a cargo for the route
|
||||
#define AI_STATION_RANGE TileXY(MapMaxX(), MapMaxY())
|
||||
#define AI_STATION_RANGE TILE_XY(TILE_X_MAX, TILE_Y_MAX)
|
||||
|
||||
#define AI_PATHFINDER_NO_DIRECTION (byte)-1
|
||||
|
||||
@@ -234,6 +235,13 @@ enum {
|
||||
#define AI_PATHFINDER_FLAG_BRIDGE 1
|
||||
#define AI_PATHFINDER_FLAG_TUNNEL 2
|
||||
|
||||
// A macro for mp_street, where 0x20 is depot
|
||||
// mp_tunnelbridge, where 0xf0 is a bridge, and 0x4/0x2 means: roadtunnel/bridge
|
||||
#define AI_PATHFINDER_IS_ROAD(tile) ((IS_TILETYPE(tile, MP_STREET) && !(_map5[tile] & 0x20)) || \
|
||||
(IS_TILETYPE(tile, MP_TUNNELBRIDGE) && \
|
||||
(((_map5[tile] & 0x80) == 0 && (_map5[tile] & 0x4) == 0x4) || \
|
||||
((_map5[tile] & 0x80) != 0 && (_map5[tile] & 0x2) == 0x2))))
|
||||
|
||||
typedef void AiNew_StateFunction(Player *p);
|
||||
|
||||
// ai_new.c
|
||||
@@ -244,19 +252,20 @@ AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFin
|
||||
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo);
|
||||
|
||||
// ai_shared.c
|
||||
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
|
||||
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
|
||||
int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b);
|
||||
int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c);
|
||||
int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c);
|
||||
int AiNew_GetDirection(uint tile_a, uint tile_b);
|
||||
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
|
||||
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
|
||||
|
||||
// ai_build.c
|
||||
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile);
|
||||
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
|
||||
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
|
||||
bool AiNew_Build_CompanyHQ(Player *p, uint tile);
|
||||
int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag);
|
||||
int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag);
|
||||
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
|
||||
int AiNew_PickVehicle(Player *p);
|
||||
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
|
||||
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag);
|
||||
int AiNew_Build_Vehicle(Player *p, uint tile, byte flag);
|
||||
int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag);
|
||||
|
||||
#endif /* AI_TROLLY_H */
|
||||
|
||||
#endif
|
||||
@@ -1,271 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../openttd.h"
|
||||
#include "../variables.h"
|
||||
#include "../command.h"
|
||||
#include "../network.h"
|
||||
#include "ai.h"
|
||||
#include "default/default.h"
|
||||
|
||||
/**
|
||||
* Dequeues commands put in the queue via AI_PutCommandInQueue.
|
||||
*/
|
||||
static void AI_DequeueCommands(byte player)
|
||||
{
|
||||
AICommand *com, *entry_com;
|
||||
|
||||
entry_com = _ai_player[player].queue;
|
||||
|
||||
/* It happens that DoCommandP issues a new DoCommandAI which adds a new command
|
||||
* to this very same queue (don't argue about this, if it currently doesn't
|
||||
* happen I can tell you it will happen with AIScript -- TrueLight). If we
|
||||
* do not make the queue NULL, that commands will be dequeued immediatly.
|
||||
* Therefor we safe the entry-point to entry_com, and make the queue NULL, so
|
||||
* the new queue can be safely built up. */
|
||||
_ai_player[player].queue = NULL;
|
||||
_ai_player[player].queue_tail = NULL;
|
||||
|
||||
/* Dequeue all commands */
|
||||
while ((com = entry_com) != NULL) {
|
||||
_current_player = player;
|
||||
|
||||
/* Copy the DP back in place */
|
||||
_cmd_text = com->text;
|
||||
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
|
||||
|
||||
/* Free item */
|
||||
entry_com = com->next;
|
||||
if (com->text != NULL)
|
||||
free(com->text);
|
||||
free(com);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Needed for SP; we need to delay DoCommand with 1 tick, because else events
|
||||
* will make infinite loops (AIScript).
|
||||
*/
|
||||
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCallback* callback)
|
||||
{
|
||||
AICommand *com;
|
||||
|
||||
if (_ai_player[player].queue_tail == NULL) {
|
||||
/* There is no item in the queue yet, create the queue */
|
||||
_ai_player[player].queue = malloc(sizeof(AICommand));
|
||||
_ai_player[player].queue_tail = _ai_player[player].queue;
|
||||
} else {
|
||||
/* Add an item at the end */
|
||||
_ai_player[player].queue_tail->next = malloc(sizeof(AICommand));
|
||||
_ai_player[player].queue_tail = _ai_player[player].queue_tail->next;
|
||||
}
|
||||
|
||||
/* This is our new item */
|
||||
com = _ai_player[player].queue_tail;
|
||||
|
||||
/* Assign the info */
|
||||
com->tile = tile;
|
||||
com->p1 = p1;
|
||||
com->p2 = p2;
|
||||
com->procc = procc;
|
||||
com->callback = callback;
|
||||
com->next = NULL;
|
||||
com->text = NULL;
|
||||
|
||||
/* Copy the cmd_text, if needed */
|
||||
if (_cmd_text != NULL) {
|
||||
com->text = strdup(_cmd_text);
|
||||
_cmd_text = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a raw DoCommand for the AI.
|
||||
*/
|
||||
int32 AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback)
|
||||
{
|
||||
PlayerID old_lp;
|
||||
int32 res = 0;
|
||||
char *tmp_cmdtext = NULL;
|
||||
|
||||
/* If you enable DC_EXEC with DC_QUERY_COST you are a really strange
|
||||
* person.. should we check for those funny jokes?
|
||||
*/
|
||||
|
||||
/* The test already free _cmd_text in most cases, so let's backup the string, else we have a problem ;) */
|
||||
if (_cmd_text != NULL)
|
||||
tmp_cmdtext = strdup(_cmd_text);
|
||||
|
||||
/* First, do a test-run to see if we can do this */
|
||||
res = DoCommandByTile(tile, p1, p2, flags & ~DC_EXEC, procc);
|
||||
/* The command failed, or you didn't want to execute, or you are quering, return */
|
||||
if ((CmdFailed(res)) || !(flags & DC_EXEC) || (flags & DC_QUERY_COST)) {
|
||||
if (tmp_cmdtext != NULL)
|
||||
free(tmp_cmdtext);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Recover _cmd_text */
|
||||
if (tmp_cmdtext != NULL)
|
||||
_cmd_text = tmp_cmdtext;
|
||||
|
||||
/* If we did a DC_EXEC, and the command did not return an error, execute it
|
||||
over the network */
|
||||
if (flags & DC_AUTO) procc |= CMD_AUTO;
|
||||
if (flags & DC_NO_WATER) procc |= CMD_NO_WATER;
|
||||
|
||||
/* NetworkSend_Command needs _local_player to be set correctly, so
|
||||
adjust it, and put it back right after the function */
|
||||
old_lp = _local_player;
|
||||
_local_player = _current_player;
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
/* Send the command */
|
||||
if (_networking)
|
||||
/* Network is easy, send it to his handler */
|
||||
NetworkSend_Command(tile, p1, p2, procc, callback);
|
||||
else
|
||||
#endif
|
||||
/* If we execute BuildCommands directly in SP, we have a big problem with events
|
||||
* so we need to delay is for 1 tick */
|
||||
AI_PutCommandInQueue(_current_player, tile, p1, p2, procc, callback);
|
||||
|
||||
/* Set _local_player back */
|
||||
_local_player = old_lp;
|
||||
|
||||
/* Free the temp _cmd_text var */
|
||||
if (tmp_cmdtext != NULL)
|
||||
free(tmp_cmdtext);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int32 AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
|
||||
{
|
||||
return AI_DoCommandCc(tile, p1, p2, flags, procc, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run 1 tick of the AI. Don't overdo it, keep it realistic.
|
||||
*/
|
||||
static void AI_RunTick(PlayerID player)
|
||||
{
|
||||
extern void AiNewDoGameLoop(Player *p);
|
||||
|
||||
Player *p = GetPlayer(player);
|
||||
_current_player = player;
|
||||
|
||||
if (_patches.ainew_active) {
|
||||
AiNewDoGameLoop(p);
|
||||
} else {
|
||||
/* Enable all kind of cheats the old AI needs in order to operate correctly... */
|
||||
_is_old_ai_player = true;
|
||||
AiDoGameLoop(p);
|
||||
_is_old_ai_player = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The gameloop for AIs.
|
||||
* Handles one tick for all the AIs.
|
||||
*/
|
||||
void AI_RunGameLoop(void)
|
||||
{
|
||||
/* Don't do anything if ai is disabled */
|
||||
if (!_ai.enabled) return;
|
||||
|
||||
/* Don't do anything if we are a network-client
|
||||
* (too bad when a client joins, he thinks the AIs are real, so it wants to control
|
||||
* them.. this avoids that, while loading a network game in singleplayer, does make
|
||||
* the AIs to continue ;))
|
||||
*/
|
||||
if (_networking && !_network_server && !_ai.network_client)
|
||||
return;
|
||||
|
||||
/* New tick */
|
||||
_ai.tick++;
|
||||
|
||||
/* Make sure the AI follows the difficulty rule.. */
|
||||
assert(_opt.diff.competitor_speed <= 4);
|
||||
if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0)
|
||||
return;
|
||||
|
||||
/* Check for AI-client (so joining a network with an AI) */
|
||||
if (_ai.network_client && _ai_player[_ai.network_playas].active) {
|
||||
/* Run the script */
|
||||
AI_DequeueCommands(_ai.network_playas);
|
||||
AI_RunTick(_ai.network_playas);
|
||||
} else if (!_networking || _network_server) {
|
||||
/* Check if we want to run AIs (server or SP only) */
|
||||
Player *p;
|
||||
|
||||
FOR_ALL_PLAYERS(p) {
|
||||
if (p->is_active && p->is_ai) {
|
||||
/* This should always be true, else something went wrong... */
|
||||
assert(_ai_player[p->index].active);
|
||||
|
||||
/* Run the script */
|
||||
AI_DequeueCommands(p->index);
|
||||
AI_RunTick(p->index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_current_player = OWNER_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* A new AI sees the day of light. You can do here what ever you think is needed.
|
||||
*/
|
||||
void AI_StartNewAI(PlayerID player)
|
||||
{
|
||||
assert(player < MAX_PLAYERS);
|
||||
|
||||
/* Called if a new AI is booted */
|
||||
_ai_player[player].active = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This AI player died. Give it some chance to make a final puf.
|
||||
*/
|
||||
void AI_PlayerDied(PlayerID player)
|
||||
{
|
||||
if (_ai.network_client && _ai.network_playas == player)
|
||||
_ai.network_playas = OWNER_SPECTATOR;
|
||||
|
||||
/* Called if this AI died */
|
||||
_ai_player[player].active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize some AI-related stuff.
|
||||
*/
|
||||
void AI_Initialize(void)
|
||||
{
|
||||
bool ai_network_client = _ai.network_client;
|
||||
|
||||
/* First, make sure all AIs are DEAD! */
|
||||
AI_Uninitialize();
|
||||
|
||||
memset(&_ai, 0, sizeof(_ai));
|
||||
memset(&_ai_player, 0, sizeof(_ai_player));
|
||||
|
||||
_ai.network_client = ai_network_client;
|
||||
_ai.network_playas = OWNER_SPECTATOR;
|
||||
_ai.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deinitializer for AI-related stuff.
|
||||
*/
|
||||
void AI_Uninitialize(void)
|
||||
{
|
||||
Player* p;
|
||||
|
||||
FOR_ALL_PLAYERS(p) {
|
||||
if (p->is_active && p->is_ai) AI_PlayerDied(p->index);
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
#ifndef AI_H
|
||||
#define AI_H
|
||||
|
||||
#include "../functions.h"
|
||||
#include "../network.h"
|
||||
#include "../player.h"
|
||||
|
||||
/* How DoCommands look like for an AI */
|
||||
typedef struct AICommand {
|
||||
uint32 tile;
|
||||
uint32 p1;
|
||||
uint32 p2;
|
||||
uint32 procc;
|
||||
CommandCallback* callback;
|
||||
|
||||
char *text;
|
||||
uint uid;
|
||||
|
||||
struct AICommand *next;
|
||||
} AICommand;
|
||||
|
||||
/* The struct for an AIScript Player */
|
||||
typedef struct AIPlayer {
|
||||
bool active; //! Is this AI active?
|
||||
AICommand *queue; //! The commands that he has in his queue
|
||||
AICommand *queue_tail; //! The tail of this queue
|
||||
} AIPlayer;
|
||||
|
||||
/* The struct to keep some data about the AI in general */
|
||||
typedef struct AIStruct {
|
||||
/* General */
|
||||
bool enabled; //! Is AI enabled?
|
||||
uint tick; //! The current tick (something like _frame_counter, only for AIs)
|
||||
|
||||
/* For network-clients (a OpenTTD client who acts as an AI connected to a server) */
|
||||
bool network_client; //! Are we a network_client?
|
||||
uint8 network_playas; //! The current network player we are connected as
|
||||
} AIStruct;
|
||||
|
||||
VARDEF AIStruct _ai;
|
||||
VARDEF AIPlayer _ai_player[MAX_PLAYERS];
|
||||
|
||||
// ai.c
|
||||
void AI_StartNewAI(PlayerID player);
|
||||
void AI_PlayerDied(PlayerID player);
|
||||
void AI_RunGameLoop(void);
|
||||
void AI_Initialize(void);
|
||||
void AI_Uninitialize(void);
|
||||
int32 AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
|
||||
int32 AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback);
|
||||
|
||||
/** Is it allowed to start a new AI.
|
||||
* This function checks some boundries to see if we should launch a new AI.
|
||||
* @return True if we can start a new AI.
|
||||
*/
|
||||
static inline bool AI_AllowNewAI(void)
|
||||
{
|
||||
/* If disabled, no AI */
|
||||
if (!_ai.enabled)
|
||||
return false;
|
||||
|
||||
/* If in network, but no server, no AI */
|
||||
if (_networking && !_network_server)
|
||||
return false;
|
||||
|
||||
/* If in network, and server, possible AI */
|
||||
if (_networking && _network_server) {
|
||||
/* Do we want AIs in multiplayer? */
|
||||
if (!_patches.ai_in_multiplayer)
|
||||
return false;
|
||||
|
||||
/* Only the NewAI is allowed... sadly enough the old AI just doesn't support this
|
||||
* system, because all commands are delayed by at least 1 tick, which causes
|
||||
* a big problem, because it uses variables that are only set AFTER the command
|
||||
* is really executed... */
|
||||
if (!_patches.ainew_active)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define AI_CHANCE16(a,b) ((uint16) AI_Random() <= (uint16)((65536 * a) / b))
|
||||
#define AI_CHANCE16R(a,b,r) ((uint16)(r = AI_Random()) <= (uint16)((65536 * a) / b))
|
||||
|
||||
/**
|
||||
* The random-function that should be used by ALL AIs.
|
||||
*/
|
||||
static inline uint AI_RandomRange(uint max)
|
||||
{
|
||||
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
|
||||
* but we pick InteractiveRandomRange if we are a network_server or network-client.
|
||||
*/
|
||||
if (_networking)
|
||||
return InteractiveRandomRange(max);
|
||||
else
|
||||
return RandomRange(max);
|
||||
}
|
||||
|
||||
/**
|
||||
* The random-function that should be used by ALL AIs.
|
||||
*/
|
||||
static inline uint32 AI_Random(void)
|
||||
{
|
||||
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
|
||||
* but we pick InteractiveRandomRange if we are a network_server or network-client.
|
||||
*/
|
||||
if (_networking)
|
||||
return InteractiveRandom();
|
||||
else
|
||||
return Random();
|
||||
}
|
||||
|
||||
#endif /* AI_H */
|
||||
@@ -1,8 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef DEFAULT_H
|
||||
#define DEFAULT_H
|
||||
|
||||
void AiDoGameLoop(Player*);
|
||||
|
||||
#endif
|
||||
@@ -1,292 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "../../openttd.h"
|
||||
#include "../../debug.h"
|
||||
#include "../../functions.h"
|
||||
#include "../../map.h"
|
||||
#include "../../tile.h"
|
||||
#include "../../vehicle.h"
|
||||
#include "../../command.h"
|
||||
#include "trolly.h"
|
||||
#include "../../engine.h"
|
||||
#include "../../station.h"
|
||||
#include "../../variables.h"
|
||||
#include "../ai.h"
|
||||
|
||||
// Build HQ
|
||||
// Params:
|
||||
// tile : tile where HQ is going to be build
|
||||
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
|
||||
{
|
||||
if (CmdFailed(AI_DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ)))
|
||||
return false;
|
||||
AI_DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Build station
|
||||
// Params:
|
||||
// type : AI_TRAIN/AI_BUS/AI_TRUCK : indicates the type of station
|
||||
// tile : tile where station is going to be build
|
||||
// length : in case of AI_TRAIN: length of station
|
||||
// numtracks : in case of AI_TRAIN: tracks of station
|
||||
// direction : the direction of the station
|
||||
// flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
|
||||
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
|
||||
{
|
||||
if (type == AI_TRAIN)
|
||||
return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
|
||||
|
||||
if (type == AI_BUS)
|
||||
return AI_DoCommand(tile, direction, RS_BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
|
||||
|
||||
return AI_DoCommand(tile, direction, RS_TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
|
||||
}
|
||||
|
||||
|
||||
// Builds a brdige. The second best out of the ones available for this player
|
||||
// Params:
|
||||
// tile_a : starting point
|
||||
// tile_b : end point
|
||||
// flag : flag passed to DoCommand
|
||||
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
|
||||
{
|
||||
int bridge_type, bridge_len, type, type2;
|
||||
|
||||
// Find a good bridgetype (the best money can buy)
|
||||
bridge_len = GetBridgeLength(tile_a, tile_b);
|
||||
type = type2 = 0;
|
||||
for (bridge_type = MAX_BRIDGES-1; bridge_type >= 0; bridge_type--) {
|
||||
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
|
||||
type2 = type;
|
||||
type = bridge_type;
|
||||
// We found two bridges, exit
|
||||
if (type2 != 0) break;
|
||||
}
|
||||
}
|
||||
// There is only one bridge that can be build..
|
||||
if (type2 == 0 && type != 0) type2 = type;
|
||||
|
||||
// Now, simply, build the bridge!
|
||||
if (p->ainew.tbt == AI_TRAIN)
|
||||
return AI_DoCommand(tile_a, tile_b, (0<<8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
|
||||
return AI_DoCommand(tile_a, tile_b, (0x80 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
}
|
||||
|
||||
|
||||
// Build the route part by part
|
||||
// Basicly what this function do, is build that amount of parts of the route
|
||||
// that go in the same direction. It sets 'part' to the last part of the route builded.
|
||||
// The return value is the cost for the builded parts
|
||||
//
|
||||
// Params:
|
||||
// PathFinderInfo : Pointer to the PathFinderInfo used for AiPathFinder
|
||||
// part : Which part we need to build
|
||||
//
|
||||
// TODO: skip already builded road-pieces (e.g.: cityroad)
|
||||
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag)
|
||||
{
|
||||
int part = PathFinderInfo->position;
|
||||
byte *route_extra = PathFinderInfo->route_extra;
|
||||
TileIndex *route = PathFinderInfo->route;
|
||||
int dir;
|
||||
int old_dir = -1;
|
||||
int cost = 0;
|
||||
int res;
|
||||
// We need to calculate the direction with the parent of the parent.. so we skip
|
||||
// the first pieces and the last piece
|
||||
if (part < 1) part = 1;
|
||||
// When we are done, stop it
|
||||
if (part >= PathFinderInfo->route_length - 1) { PathFinderInfo->position = -2; return 0; }
|
||||
|
||||
|
||||
if (PathFinderInfo->rail_or_road) {
|
||||
// Tunnel code
|
||||
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
|
||||
cost += AI_DoCommand(route[part], 0, 0, flag, CMD_BUILD_TUNNEL);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (CmdFailed(cost)) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
// Bridge code
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
|
||||
cost += AiNew_Build_Bridge(p, route[part], route[part-1], flag);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (CmdFailed(cost)) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
// Build normal rail
|
||||
// Keep it doing till we go an other way
|
||||
if (route_extra[part-1] == 0 && route_extra[part] == 0) {
|
||||
while (route_extra[part] == 0) {
|
||||
// Get the current direction
|
||||
dir = AiNew_GetRailDirection(route[part-1], route[part], route[part+1]);
|
||||
// Is it the same as the last one?
|
||||
if (old_dir != -1 && old_dir != dir) break;
|
||||
old_dir = dir;
|
||||
// Build the tile
|
||||
res = AI_DoCommand(route[part], 0, dir, flag, CMD_BUILD_SINGLE_RAIL);
|
||||
if (CmdFailed(res)) {
|
||||
// Problem.. let's just abort it all!
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
return 0;
|
||||
}
|
||||
cost += res;
|
||||
// Go to the next tile
|
||||
part++;
|
||||
// Check if it is still in range..
|
||||
if (part >= PathFinderInfo->route_length - 1) break;
|
||||
}
|
||||
part--;
|
||||
}
|
||||
// We want to return the last position, so we go back one
|
||||
PathFinderInfo->position = part;
|
||||
} else {
|
||||
// Tunnel code
|
||||
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
|
||||
cost += AI_DoCommand(route[part], 0x200, 0, flag, CMD_BUILD_TUNNEL);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (CmdFailed(cost)) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
// Bridge code
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
|
||||
cost += AiNew_Build_Bridge(p, route[part], route[part+1], flag);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (CmdFailed(cost)) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
// Build normal road
|
||||
// Keep it doing till we go an other way
|
||||
// EnsureNoVehicle makes sure we don't build on a tile where a vehicle is. This way
|
||||
// it will wait till the vehicle is gone..
|
||||
if (route_extra[part-1] == 0 && route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) {
|
||||
while (route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) {
|
||||
// Get the current direction
|
||||
dir = AiNew_GetRoadDirection(route[part-1], route[part], route[part+1]);
|
||||
// Is it the same as the last one?
|
||||
if (old_dir != -1 && old_dir != dir) break;
|
||||
old_dir = dir;
|
||||
// There is already some road, and it is a bridge.. don't build!!!
|
||||
if (!IsTileType(route[part], MP_TUNNELBRIDGE)) {
|
||||
// Build the tile
|
||||
res = AI_DoCommand(route[part], dir, 0, flag | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
// Currently, we ignore CMD_ERRORs!
|
||||
if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) {
|
||||
// Problem.. let's just abort it all!
|
||||
DEBUG(ai,0)("Darn, the route could not be builded.. aborting!");
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!CmdFailed(res)) cost += res;
|
||||
}
|
||||
// Go to the next tile
|
||||
part++;
|
||||
// Check if it is still in range..
|
||||
if (part >= PathFinderInfo->route_length - 1) break;
|
||||
}
|
||||
part--;
|
||||
// We want to return the last position, so we go back one
|
||||
}
|
||||
if (!EnsureNoVehicle(route[part]) && flag == DC_EXEC) part--;
|
||||
PathFinderInfo->position = part;
|
||||
}
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
||||
// This functions tries to find the best vehicle for this type of cargo
|
||||
// It returns vehicle_id or -1 if not found
|
||||
int AiNew_PickVehicle(Player *p)
|
||||
{
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
// Not supported yet
|
||||
return -1;
|
||||
} else {
|
||||
int start, count, i, ret = CMD_ERROR;
|
||||
start = _cargoc.ai_roadveh_start[p->ainew.cargo];
|
||||
count = _cargoc.ai_roadveh_count[p->ainew.cargo];
|
||||
|
||||
// Let's check it backwards.. we simply want to best engine available..
|
||||
for (i = start + count - 1; i >= start; i--) {
|
||||
// Is it availiable?
|
||||
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
|
||||
if (!HASBIT(GetEngine(i)->player_avail, _current_player) || GetEngine(i)->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
|
||||
// Can we build it?
|
||||
ret = AI_DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_ROAD_VEH);
|
||||
if (!CmdFailed(ret)) break;
|
||||
}
|
||||
// We did not find a vehicle :(
|
||||
if (CmdFailed(ret)) return -1;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
Player* p = GetPlayer(_current_player);
|
||||
|
||||
if (success) {
|
||||
p->ainew.state = AI_STATE_GIVE_ORDERS;
|
||||
p->ainew.veh_id = _new_vehicle_id;
|
||||
} else {
|
||||
/* XXX this should be handled more gracefully */
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Builds the best vehicle possible
|
||||
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
|
||||
{
|
||||
int i = AiNew_PickVehicle(p);
|
||||
if (i == -1) return CMD_ERROR;
|
||||
|
||||
if (p->ainew.tbt == AI_TRAIN) return CMD_ERROR;
|
||||
|
||||
if (flag & DC_EXEC) {
|
||||
return AI_DoCommandCc(tile, i, 0, flag, CMD_BUILD_ROAD_VEH, CcAI);
|
||||
} else {
|
||||
return AI_DoCommand(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
|
||||
}
|
||||
}
|
||||
|
||||
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
|
||||
{
|
||||
static const byte _roadbits_by_dir[4] = {2,1,8,4};
|
||||
int ret, ret2;
|
||||
if (p->ainew.tbt == AI_TRAIN)
|
||||
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
|
||||
|
||||
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
||||
if (CmdFailed(ret)) return ret;
|
||||
// Try to build the road from the depot
|
||||
ret2 = AI_DoCommand(tile + TileOffsByDir(direction), _roadbits_by_dir[direction], 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
// If it fails, ignore it..
|
||||
if (CmdFailed(ret2)) return ret;
|
||||
return ret + ret2;
|
||||
}
|
||||
@@ -1,509 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "../../openttd.h"
|
||||
#include "../../debug.h"
|
||||
#include "../../functions.h"
|
||||
#include "../../map.h"
|
||||
#include "../../tile.h"
|
||||
#include "../../command.h"
|
||||
#include "trolly.h"
|
||||
#include "../../depot.h"
|
||||
#include "../../variables.h"
|
||||
#include "../ai.h"
|
||||
|
||||
#define TEST_STATION_NO_DIR 0xFF
|
||||
|
||||
// Tests if a station can be build on the given spot
|
||||
// TODO: make it train compatible
|
||||
static bool TestCanBuildStationHere(TileIndex tile, byte dir)
|
||||
{
|
||||
Player *p = GetPlayer(_current_player);
|
||||
|
||||
if (dir == TEST_STATION_NO_DIR) {
|
||||
int32 ret;
|
||||
// TODO: currently we only allow spots that can be access from al 4 directions...
|
||||
// should be fixed!!!
|
||||
for (dir = 0; dir < 4; dir++) {
|
||||
ret = AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST);
|
||||
if (!CmdFailed(ret)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// return true if command succeeded, so the inverse of CmdFailed()
|
||||
return !CmdFailed(AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST));
|
||||
}
|
||||
|
||||
|
||||
static bool IsRoad(TileIndex tile)
|
||||
{
|
||||
return
|
||||
// MP_STREET, but not a road depot?
|
||||
(IsTileType(tile, MP_STREET) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
|
||||
(IsTileType(tile, MP_TUNNELBRIDGE) && (
|
||||
// road tunnel?
|
||||
((_m[tile].m5 & 0x80) == 0 && (_m[tile].m5 & 0x4) == 0x4) ||
|
||||
// road bridge?
|
||||
((_m[tile].m5 & 0x80) != 0 && (_m[tile].m5 & 0x2) == 0x2)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
// Checks if a tile 'a' is between the tiles 'b' and 'c'
|
||||
#define TILES_BETWEEN(a, b, c) (TileX(a) >= TileX(b) && TileX(a) <= TileX(c) && TileY(a) >= TileY(b) && TileY(a) <= TileY(c))
|
||||
|
||||
|
||||
// Check if the current tile is in our end-area
|
||||
static int32 AyStar_AiPathFinder_EndNodeCheck(AyStar *aystar, OpenListNode *current)
|
||||
{
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
// It is not allowed to have a station on the end of a bridge or tunnel ;)
|
||||
if (current->path.node.user_data[0] != 0) return AYSTAR_DONE;
|
||||
if (TILES_BETWEEN(current->path.node.tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br))
|
||||
if (IsTileType(current->path.node.tile, MP_CLEAR) || IsTileType(current->path.node.tile, MP_TREES))
|
||||
if (current->path.parent == NULL || TestCanBuildStationHere(current->path.node.tile, AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile)))
|
||||
return AYSTAR_FOUND_END_NODE;
|
||||
|
||||
return AYSTAR_DONE;
|
||||
}
|
||||
|
||||
|
||||
// Calculates the hash
|
||||
// Currently it is a 10 bit hash, so the hash array has a max depth of 6 bits (so 64)
|
||||
static uint AiPathFinder_Hash(uint key1, uint key2)
|
||||
{
|
||||
return (TileX(key1) & 0x1F) + ((TileY(key1) & 0x1F) << 5);
|
||||
}
|
||||
|
||||
|
||||
// Clear the memory of all the things
|
||||
static void AyStar_AiPathFinder_Free(AyStar *aystar)
|
||||
{
|
||||
AyStarMain_Free(aystar);
|
||||
free(aystar);
|
||||
}
|
||||
|
||||
|
||||
static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
||||
static int32 AyStar_AiPathFinder_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
||||
static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current);
|
||||
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current);
|
||||
|
||||
|
||||
// This creates the AiPathFinder
|
||||
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo)
|
||||
{
|
||||
PathNode start_node;
|
||||
uint x;
|
||||
uint y;
|
||||
// Create AyStar
|
||||
AyStar *result = malloc(sizeof(AyStar));
|
||||
init_AyStar(result, AiPathFinder_Hash, 1 << 10);
|
||||
// Set the function pointers
|
||||
result->CalculateG = AyStar_AiPathFinder_CalculateG;
|
||||
result->CalculateH = AyStar_AiPathFinder_CalculateH;
|
||||
result->EndNodeCheck = AyStar_AiPathFinder_EndNodeCheck;
|
||||
result->FoundEndNode = AyStar_AiPathFinder_FoundEndNode;
|
||||
result->GetNeighbours = AyStar_AiPathFinder_GetNeighbours;
|
||||
|
||||
result->free = AyStar_AiPathFinder_Free;
|
||||
|
||||
// Set some information
|
||||
result->loops_per_tick = AI_PATHFINDER_LOOPS_PER_TICK;
|
||||
result->max_path_cost = 0;
|
||||
result->max_search_nodes = AI_PATHFINDER_MAX_SEARCH_NODES;
|
||||
|
||||
// Set the user_data to the PathFinderInfo
|
||||
result->user_target = PathFinderInfo;
|
||||
|
||||
// Set the start node
|
||||
start_node.parent = NULL;
|
||||
start_node.node.direction = 0;
|
||||
start_node.node.user_data[0] = 0;
|
||||
|
||||
// Now we add all the starting tiles
|
||||
for (x = TileX(PathFinderInfo->start_tile_tl); x <= TileX(PathFinderInfo->start_tile_br); x++) {
|
||||
for (y = TileY(PathFinderInfo->start_tile_tl); y <= TileY(PathFinderInfo->start_tile_br); y++) {
|
||||
start_node.node.tile = TileXY(x, y);
|
||||
result->addstart(result, &start_node.node, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// To reuse AyStar we sometimes have to clean all the memory
|
||||
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo)
|
||||
{
|
||||
PathNode start_node;
|
||||
uint x;
|
||||
uint y;
|
||||
|
||||
aystar->clear(aystar);
|
||||
|
||||
// Set the user_data to the PathFinderInfo
|
||||
aystar->user_target = PathFinderInfo;
|
||||
|
||||
// Set the start node
|
||||
start_node.parent = NULL;
|
||||
start_node.node.direction = 0;
|
||||
start_node.node.user_data[0] = 0;
|
||||
start_node.node.tile = PathFinderInfo->start_tile_tl;
|
||||
|
||||
// Now we add all the starting tiles
|
||||
for (x = TileX(PathFinderInfo->start_tile_tl); x <= TileX(PathFinderInfo->start_tile_br); x++) {
|
||||
for (y = TileY(PathFinderInfo->start_tile_tl); y <= TileY(PathFinderInfo->start_tile_br); y++) {
|
||||
if (!(IsTileType(TileXY(x, y), MP_CLEAR) || IsTileType(TileXY(x, y), MP_TREES))) continue;
|
||||
if (!TestCanBuildStationHere(TileXY(x, y), TEST_STATION_NO_DIR)) continue;
|
||||
start_node.node.tile = TileXY(x, y);
|
||||
aystar->addstart(aystar, &start_node.node, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The h-value, simple calculation
|
||||
static int32 AyStar_AiPathFinder_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent)
|
||||
{
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
int r, r2;
|
||||
if (PathFinderInfo->end_direction != AI_PATHFINDER_NO_DIRECTION) {
|
||||
// The station is pointing to a direction, add a tile towards that direction, so the H-value is more accurate
|
||||
r = DistanceManhattan(current->tile, PathFinderInfo->end_tile_tl + TileOffsByDir(PathFinderInfo->end_direction));
|
||||
r2 = DistanceManhattan(current->tile, PathFinderInfo->end_tile_br + TileOffsByDir(PathFinderInfo->end_direction));
|
||||
} else {
|
||||
// No direction, so just get the fastest route to the station
|
||||
r = DistanceManhattan(current->tile, PathFinderInfo->end_tile_tl);
|
||||
r2 = DistanceManhattan(current->tile, PathFinderInfo->end_tile_br);
|
||||
}
|
||||
// See if the bottomright is faster than the topleft..
|
||||
if (r2 < r) r = r2;
|
||||
return r * AI_PATHFINDER_H_MULTIPLER;
|
||||
}
|
||||
|
||||
|
||||
// We found the end.. let's get the route back and put it in an array
|
||||
static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current)
|
||||
{
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
uint i = 0;
|
||||
PathNode *parent = ¤t->path;
|
||||
|
||||
do {
|
||||
PathFinderInfo->route_extra[i] = parent->node.user_data[0];
|
||||
PathFinderInfo->route[i++] = parent->node.tile;
|
||||
if (i > lengthof(PathFinderInfo->route)) {
|
||||
// We ran out of space for the PathFinder
|
||||
DEBUG(ai, 0)("[AiPathFinder] Ran out of space in the route[] array!!!");
|
||||
PathFinderInfo->route_length = -1; // -1 indicates out of space
|
||||
return;
|
||||
}
|
||||
parent = parent->parent;
|
||||
} while (parent != NULL);
|
||||
PathFinderInfo->route_length = i;
|
||||
DEBUG(ai, 1)("[Ai-PathFinding] Found route of %d nodes long in %d nodes of searching", i, Hash_Size(&aystar->ClosedListHash));
|
||||
}
|
||||
|
||||
|
||||
// What tiles are around us.
|
||||
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current)
|
||||
{
|
||||
uint i;
|
||||
int ret;
|
||||
int dir;
|
||||
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
|
||||
aystar->num_neighbours = 0;
|
||||
|
||||
// Go through all surrounding tiles and check if they are within the limits
|
||||
for (i = 0; i < 4; i++) {
|
||||
TileIndex ctile = current->path.node.tile; // Current tile
|
||||
TileIndex atile = ctile + TileOffsByDir(i); // Adjacent tile
|
||||
|
||||
if (TileX(atile) > 1 && TileX(atile) < MapMaxX() - 1 &&
|
||||
TileY(atile) > 1 && TileY(atile) < MapMaxY() - 1) {
|
||||
// We also directly test if the current tile can connect to this tile..
|
||||
// We do this simply by just building the tile!
|
||||
|
||||
// If the next step is a bridge, we have to enter it the right way
|
||||
if (!PathFinderInfo->rail_or_road && IsRoad(atile)) {
|
||||
if (IsTileType(atile, MP_TUNNELBRIDGE)) {
|
||||
// An existing bridge... let's test the direction ;)
|
||||
if ((_m[atile].m5 & 1U) != (i & 1)) continue;
|
||||
// This problem only is valid for tunnels:
|
||||
// When the last tile was not yet a tunnel, check if we enter from the right side..
|
||||
if ((_m[atile].m5 & 0x80) == 0) {
|
||||
if (i != (_m[atile].m5 & 3U)) continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// But also if we are on a bridge, we can only move a certain direction
|
||||
if (!PathFinderInfo->rail_or_road && IsRoad(ctile)) {
|
||||
if (IsTileType(ctile, MP_TUNNELBRIDGE)) {
|
||||
// An existing bridge/tunnel... let's test the direction ;)
|
||||
if ((_m[ctile].m5 & 1U) != (i & 1)) continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||
|
||||
(AI_PATHFINDER_FLAG_TUNNEL & current->path.node.user_data[0]) != 0) {
|
||||
// We are a bridge/tunnel, how cool!!
|
||||
// This means we can only point forward.. get the direction from the user_data
|
||||
if (i != (current->path.node.user_data[0] >> 8)) continue;
|
||||
}
|
||||
dir = 0;
|
||||
|
||||
// First, check if we have a parent
|
||||
if (current->path.parent == NULL && current->path.node.user_data[0] == 0) {
|
||||
// If not, this means we are at the starting station
|
||||
if (PathFinderInfo->start_direction != AI_PATHFINDER_NO_DIRECTION) {
|
||||
// We do need a direction?
|
||||
if (AiNew_GetDirection(ctile, atile) != PathFinderInfo->start_direction) {
|
||||
// We are not pointing the right way, invalid tile
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if (current->path.node.user_data[0] == 0) {
|
||||
if (PathFinderInfo->rail_or_road) {
|
||||
// Rail check
|
||||
dir = AiNew_GetRailDirection(current->path.parent->node.tile, ctile, atile);
|
||||
ret = AI_DoCommand(ctile, 0, dir, DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
|
||||
if (CmdFailed(ret)) continue;
|
||||
#ifdef AI_PATHFINDER_NO_90DEGREES_TURN
|
||||
if (current->path.parent->parent != NULL) {
|
||||
// Check if we don't make a 90degree curve
|
||||
int dir1 = AiNew_GetRailDirection(current->path.parent->parent->node.tile, current->path.parent->node.tile, ctile);
|
||||
if (_illegal_curves[dir1] == dir || _illegal_curves[dir] == dir1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// Road check
|
||||
dir = AiNew_GetRoadDirection(current->path.parent->node.tile, ctile, atile);
|
||||
if (IsRoad(ctile)) {
|
||||
if (IsTileType(ctile, MP_TUNNELBRIDGE)) {
|
||||
// We have a bridge, how nicely! We should mark it...
|
||||
dir = 0;
|
||||
} else {
|
||||
// It already has road.. check if we miss any bits!
|
||||
if ((_m[ctile].m5 & dir) != dir) {
|
||||
// We do miss some pieces :(
|
||||
dir &= ~_m[ctile].m5;
|
||||
} else {
|
||||
dir = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only destruct things if it is MP_CLEAR of MP_TREES
|
||||
if (dir != 0) {
|
||||
ret = AI_DoCommand(ctile, dir, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
if (CmdFailed(ret)) continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The tile can be connected
|
||||
aystar->neighbours[aystar->num_neighbours].tile = atile;
|
||||
aystar->neighbours[aystar->num_neighbours].user_data[0] = 0;
|
||||
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Next step, check for bridges and tunnels
|
||||
if (current->path.parent != NULL && current->path.node.user_data[0] == 0) {
|
||||
TileInfo ti;
|
||||
// First we get the dir from this tile and his parent
|
||||
int dir = AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile);
|
||||
// It means we can only walk with the track, so the bridge has to be in the same direction
|
||||
TileIndex tile = current->path.node.tile;
|
||||
TileIndex new_tile = tile;
|
||||
|
||||
FindLandscapeHeightByTile(&ti, tile);
|
||||
|
||||
// Bridges can only be build on land that is not flat
|
||||
// And if there is a road or rail blocking
|
||||
if (ti.tileh != 0 ||
|
||||
(PathFinderInfo->rail_or_road && IsTileType(tile + TileOffsByDir(dir), MP_STREET)) ||
|
||||
(!PathFinderInfo->rail_or_road && IsTileType(tile + TileOffsByDir(dir), MP_RAILWAY))) {
|
||||
for (;;) {
|
||||
new_tile += TileOffsByDir(dir);
|
||||
|
||||
// Precheck, is the length allowed?
|
||||
if (!CheckBridge_Stuff(0, GetBridgeLength(tile, new_tile))) break;
|
||||
|
||||
// Check if we hit the station-tile.. we don't like that!
|
||||
if (TILES_BETWEEN(new_tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br)) break;
|
||||
|
||||
// Try building the bridge..
|
||||
ret = AI_DoCommand(tile, new_tile, (0 << 8) + (MAX_BRIDGES / 2), DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
if (CmdFailed(ret)) continue;
|
||||
// We can build a bridge here.. add him to the neighbours
|
||||
aystar->neighbours[aystar->num_neighbours].tile = new_tile;
|
||||
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_BRIDGE + (dir << 8);
|
||||
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
||||
// We can only have 12 neighbours, and we need 1 left for tunnels
|
||||
if (aystar->num_neighbours == 11) break;
|
||||
}
|
||||
}
|
||||
|
||||
// Next, check for tunnels!
|
||||
// Tunnels can only be build with tileh of 3, 6, 9 or 12, depending on the direction
|
||||
// For now, we check both sides for this tile.. terraforming gives fuzzy result
|
||||
if ((dir == 0 && ti.tileh == 12) ||
|
||||
(dir == 1 && ti.tileh == 6) ||
|
||||
(dir == 2 && ti.tileh == 3) ||
|
||||
(dir == 3 && ti.tileh == 9)) {
|
||||
// Now simply check if a tunnel can be build
|
||||
ret = AI_DoCommand(tile, (PathFinderInfo->rail_or_road?0:0x200), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
||||
FindLandscapeHeightByTile(&ti, _build_tunnel_endtile);
|
||||
if (!CmdFailed(ret) && (ti.tileh == 3 || ti.tileh == 6 || ti.tileh == 9 || ti.tileh == 12)) {
|
||||
aystar->neighbours[aystar->num_neighbours].tile = _build_tunnel_endtile;
|
||||
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_TUNNEL + (dir << 8);
|
||||
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern uint GetRailFoundation(uint tileh, uint bits);
|
||||
extern uint GetRoadFoundation(uint tileh, uint bits);
|
||||
extern uint GetBridgeFoundation(uint tileh, byte direction);
|
||||
enum {
|
||||
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
|
||||
};
|
||||
|
||||
// The most important function: it calculates the g-value
|
||||
static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent)
|
||||
{
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
int r, res = 0;
|
||||
TileInfo ti, parent_ti;
|
||||
|
||||
// Gather some information about the tile..
|
||||
FindLandscapeHeightByTile(&ti, current->tile);
|
||||
FindLandscapeHeightByTile(&parent_ti, parent->path.node.tile);
|
||||
|
||||
// Check if we hit the end-tile
|
||||
if (TILES_BETWEEN(current->tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br)) {
|
||||
// We are at the end-tile, check if we had a direction or something...
|
||||
if (PathFinderInfo->end_direction != AI_PATHFINDER_NO_DIRECTION && AiNew_GetDirection(current->tile, parent->path.node.tile) != PathFinderInfo->end_direction) {
|
||||
// We are not pointing the right way, invalid tile
|
||||
return AYSTAR_INVALID_NODE;
|
||||
}
|
||||
// If it was valid, drop out.. we don't build on the endtile
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Give everything a small penalty
|
||||
res += AI_PATHFINDER_PENALTY;
|
||||
|
||||
if (!PathFinderInfo->rail_or_road) {
|
||||
// Road has the lovely advantage it can use other road... check if
|
||||
// the current tile is road, and if so, give a good bonus
|
||||
if (IsRoad(current->tile)) {
|
||||
res -= AI_PATHFINDER_ROAD_ALREADY_EXISTS_BONUS;
|
||||
}
|
||||
}
|
||||
|
||||
// We should give a penalty when the tile is going up or down.. this is one way to do so!
|
||||
// Too bad we have to count it from the parent.. but that is not so bad.
|
||||
// We also dislike long routes on slopes, since they do not look too realistic
|
||||
// when there is a flat land all around, they are more expensive to build, and
|
||||
// especially they essentially block the ability to connect or cross the road
|
||||
// from one side.
|
||||
if (parent_ti.tileh != 0 && parent->path.parent != NULL) {
|
||||
// Skip if the tile was from a bridge or tunnel
|
||||
if (parent->path.node.user_data[0] == 0 && current->user_data[0] == 0) {
|
||||
if (PathFinderInfo->rail_or_road) {
|
||||
r = GetRailFoundation(parent_ti.tileh, 1 << AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
|
||||
// Maybe is BRIDGE_NO_FOUNDATION a bit strange here, but it contains just the right information..
|
||||
if (r >= 15 || (r == 0 && (BRIDGE_NO_FOUNDATION & (1 << ti.tileh)))) {
|
||||
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||
} else {
|
||||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||
}
|
||||
} else {
|
||||
if (!(IsRoad(parent->path.node.tile) && IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE))) {
|
||||
r = GetRoadFoundation(parent_ti.tileh, AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
|
||||
if (r >= 15 || r == 0)
|
||||
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||
else
|
||||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Are we part of a tunnel?
|
||||
if ((AI_PATHFINDER_FLAG_TUNNEL & current->user_data[0]) != 0) {
|
||||
// Tunnels are very expensive when build on long routes..
|
||||
// Ironicly, we are using BridgeCode here ;)
|
||||
r = AI_PATHFINDER_TUNNEL_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
|
||||
res += r + (r >> 8);
|
||||
}
|
||||
|
||||
// Are we part of a bridge?
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & current->user_data[0]) != 0) {
|
||||
// That means for every length a penalty
|
||||
res += AI_PATHFINDER_BRIDGE_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
|
||||
// Check if we are going up or down, first for the starting point
|
||||
// In user_data[0] is at the 8th bit the direction
|
||||
if (!(BRIDGE_NO_FOUNDATION & (1 << parent_ti.tileh))) {
|
||||
if (GetBridgeFoundation(parent_ti.tileh, (current->user_data[0] >> 8) & 1) < 15)
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
// Second for the end point
|
||||
if (!(BRIDGE_NO_FOUNDATION & (1 << ti.tileh))) {
|
||||
if (GetBridgeFoundation(ti.tileh, (current->user_data[0] >> 8) & 1) < 15)
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
if (parent_ti.tileh == 0) res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
if (ti.tileh == 0) res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
|
||||
// To prevent the AI from taking the fastest way in tiles, but not the fastest way
|
||||
// in speed, we have to give a good penalty to direction changing
|
||||
// This way, we get almost the fastest way in tiles, and a very good speed on the track
|
||||
if (!PathFinderInfo->rail_or_road) {
|
||||
if (parent->path.parent != NULL &&
|
||||
AiNew_GetDirection(current->tile, parent->path.node.tile) != AiNew_GetDirection(parent->path.node.tile, parent->path.parent->node.tile)) {
|
||||
// When road exists, we don't like turning, but its free, so don't be to piggy about it
|
||||
if (IsRoad(parent->path.node.tile))
|
||||
res += AI_PATHFINDER_DIRECTION_CHANGE_ON_EXISTING_ROAD_PENALTY;
|
||||
else
|
||||
res += AI_PATHFINDER_DIRECTION_CHANGE_PENALTY;
|
||||
}
|
||||
} else {
|
||||
// For rail we have 1 exeption: diagonal rail..
|
||||
// So we fetch 2 raildirection. That of the current one, and of the one before that
|
||||
if (parent->path.parent != NULL && parent->path.parent->parent != NULL) {
|
||||
int dir1 = AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile);
|
||||
int dir2 = AiNew_GetRailDirection(parent->path.parent->parent->node.tile, parent->path.parent->node.tile, parent->path.node.tile);
|
||||
// First, see if we are on diagonal path, that is better than straight path
|
||||
if (dir1 > 1) { res -= AI_PATHFINDER_DIAGONAL_BONUS; }
|
||||
|
||||
// First see if they are different
|
||||
if (dir1 != dir2) {
|
||||
// dir 2 and 3 are 1 diagonal track, and 4 and 5.
|
||||
if (!(((dir1 == 2 || dir1 == 3) && (dir2 == 2 || dir2 == 3)) || ((dir1 == 4 || dir1 == 5) && (dir2 == 4 || dir2 == 5)))) {
|
||||
// It is not, so we changed of direction
|
||||
res += AI_PATHFINDER_DIRECTION_CHANGE_PENALTY;
|
||||
}
|
||||
if (parent->path.parent->parent->parent != NULL) {
|
||||
int dir3 = AiNew_GetRailDirection(parent->path.parent->parent->parent->node.tile, parent->path.parent->parent->node.tile, parent->path.parent->node.tile);
|
||||
// Check if we changed 3 tiles of direction in 3 tiles.. bad!!!
|
||||
if ((dir1 == 0 || dir1 == 1) && dir2 > 1 && (dir3 == 0 || dir3 == 1)) {
|
||||
res += AI_PATHFINDER_CURVE_PENALTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (res < 0) ? 0 : res;
|
||||
}
|
||||
-1353
File diff suppressed because it is too large
Load Diff
+258
@@ -0,0 +1,258 @@
|
||||
#include "stdafx.h"
|
||||
#include "ttd.h"
|
||||
#include "map.h"
|
||||
#include "command.h"
|
||||
#include "ai.h"
|
||||
#include "engine.h"
|
||||
|
||||
// Build HQ
|
||||
// Params:
|
||||
// tile : tile where HQ is going to be build
|
||||
bool AiNew_Build_CompanyHQ(Player *p, uint tile) {
|
||||
if (DoCommandByTile(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ) == CMD_ERROR)
|
||||
return false;
|
||||
DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Build station
|
||||
// Params:
|
||||
// type : AI_TRAIN/AI_BUS/AI_TRUCK : indicates the type of station
|
||||
// tile : tile where station is going to be build
|
||||
// length : in case of AI_TRAIN: length of station
|
||||
// numtracks : in case of AI_TRAIN: tracks of station
|
||||
// direction : the direction of the station
|
||||
// flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
|
||||
int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag) {
|
||||
if (type == AI_TRAIN)
|
||||
return DoCommandByTile(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
|
||||
else if (type == AI_BUS)
|
||||
return DoCommandByTile(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_BUS_STATION);
|
||||
else
|
||||
return DoCommandByTile(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRUCK_STATION);
|
||||
}
|
||||
|
||||
// Builds a brdige. The second best out of the ones available for this player
|
||||
// Params:
|
||||
// tile_a : starting point
|
||||
// tile_b : end point
|
||||
// flag : flag passed to DoCommand
|
||||
int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag) {
|
||||
int bridge_type, bridge_len, type, type2;
|
||||
|
||||
// Find a good bridgetype (the best money can buy)
|
||||
bridge_len = GetBridgeLength(tile_a, tile_b);
|
||||
type = type2 = 0;
|
||||
for (bridge_type = MAX_BRIDGES-1; bridge_type >= 0; bridge_type--) {
|
||||
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
|
||||
type2 = type;
|
||||
type = bridge_type;
|
||||
// We found two bridges, exit
|
||||
if (type2 != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// There is only one bridge that can be build..
|
||||
if (type2 == 0 && type != 0) type2 = type;
|
||||
|
||||
// Now, simply, build the bridge!
|
||||
if (p->ainew.tbt == AI_TRAIN)
|
||||
return DoCommandByTile(tile_a, tile_b, (0<<8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
else
|
||||
return DoCommandByTile(tile_a, tile_b, (0x80 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
}
|
||||
|
||||
|
||||
// Build the route part by part
|
||||
// Basicly what this function do, is build that amount of parts of the route
|
||||
// that go in the same direction. It sets 'part' to the last part of the route builded.
|
||||
// The return value is the cost for the builded parts
|
||||
//
|
||||
// Params:
|
||||
// PathFinderInfo : Pointer to the PathFinderInfo used for AiPathFinder
|
||||
// part : Which part we need to build
|
||||
//
|
||||
// TODO: skip already builded road-pieces (e.g.: cityroad)
|
||||
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag) {
|
||||
int part = PathFinderInfo->position;
|
||||
byte *route_extra = PathFinderInfo->route_extra;
|
||||
TileIndex *route = PathFinderInfo->route;
|
||||
int dir;
|
||||
int old_dir = -1;
|
||||
int cost = 0;
|
||||
int res;
|
||||
// We need to calculate the direction with the parent of the parent.. so we skip
|
||||
// the first pieces and the last piece
|
||||
if (part < 1) part = 1;
|
||||
// When we are done, stop it
|
||||
if (part >= PathFinderInfo->route_length - 1) { PathFinderInfo->position = -2; return 0; }
|
||||
|
||||
|
||||
if (PathFinderInfo->rail_or_road) {
|
||||
// Tunnel code
|
||||
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
|
||||
cost += DoCommandByTile(route[part], 0, 0, flag, CMD_BUILD_TUNNEL);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (cost == CMD_ERROR) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
// Bridge code
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
|
||||
cost += AiNew_Build_Bridge(p, route[part], route[part-1], flag);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (cost == CMD_ERROR) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
// Build normal rail
|
||||
// Keep it doing till we go an other way
|
||||
if (route_extra[part-1] == 0 && route_extra[part] == 0) {
|
||||
while (route_extra[part] == 0) {
|
||||
// Get the current direction
|
||||
dir = AiNew_GetRailDirection(route[part-1], route[part], route[part+1]);
|
||||
// Is it the same as the last one?
|
||||
if (old_dir != -1 && old_dir != dir) break;
|
||||
old_dir = dir;
|
||||
// Build the tile
|
||||
res = DoCommandByTile(route[part], 0, dir, flag, CMD_BUILD_SINGLE_RAIL);
|
||||
if (res == CMD_ERROR) {
|
||||
// Problem.. let's just abort it all!
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
return 0;
|
||||
}
|
||||
cost += res;
|
||||
// Go to the next tile
|
||||
part++;
|
||||
// Check if it is still in range..
|
||||
if (part >= PathFinderInfo->route_length - 1) break;
|
||||
}
|
||||
part--;
|
||||
}
|
||||
// We want to return the last position, so we go back one
|
||||
PathFinderInfo->position = part;
|
||||
} else {
|
||||
// Tunnel code
|
||||
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
|
||||
cost += DoCommandByTile(route[part], 0x200, 0, flag, CMD_BUILD_TUNNEL);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (cost == CMD_ERROR) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
// Bridge code
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
|
||||
cost += AiNew_Build_Bridge(p, route[part], route[part+1], flag);
|
||||
PathFinderInfo->position++;
|
||||
// TODO: problems!
|
||||
if (cost == CMD_ERROR) {
|
||||
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be build!");
|
||||
return 0;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
// Build normal road
|
||||
// Keep it doing till we go an other way
|
||||
// EnsureNoVehicle makes sure we don't build on a tile where a vehicle is. This way
|
||||
// it will wait till the vehicle is gone..
|
||||
if (route_extra[part-1] == 0 && route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) {
|
||||
while (route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) {
|
||||
// Get the current direction
|
||||
dir = AiNew_GetRoadDirection(route[part-1], route[part], route[part+1]);
|
||||
// Is it the same as the last one?
|
||||
if (old_dir != -1 && old_dir != dir) break;
|
||||
old_dir = dir;
|
||||
// There is already some road, and it is a bridge.. don't build!!!
|
||||
if (!IS_TILETYPE(route[part], MP_TUNNELBRIDGE)) {
|
||||
// Build the tile
|
||||
res = DoCommandByTile(route[part], dir, 0, flag | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
// Currently, we ignore CMD_ERRORs!
|
||||
if (res == CMD_ERROR && flag == DC_EXEC && !IS_TILETYPE(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) {
|
||||
// Problem.. let's just abort it all!
|
||||
DEBUG(ai,0)("Darn, the route could not be builded.. aborting!");
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
return 0;
|
||||
} else {
|
||||
if (res != CMD_ERROR)
|
||||
cost += res;
|
||||
}
|
||||
}
|
||||
// Go to the next tile
|
||||
part++;
|
||||
// Check if it is still in range..
|
||||
if (part >= PathFinderInfo->route_length - 1) break;
|
||||
}
|
||||
part--;
|
||||
// We want to return the last position, so we go back one
|
||||
}
|
||||
if (!EnsureNoVehicle(route[part]) && flag == DC_EXEC) part--;
|
||||
PathFinderInfo->position = part;
|
||||
}
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
// This functions tries to find the best vehicle for this type of cargo
|
||||
// It returns vehicle_id or -1 if not found
|
||||
int AiNew_PickVehicle(Player *p) {
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
// Not supported yet
|
||||
return -1;
|
||||
} else {
|
||||
int start, count, i, r = CMD_ERROR;
|
||||
start = _cargoc.ai_roadveh_start[p->ainew.cargo];
|
||||
count = _cargoc.ai_roadveh_count[p->ainew.cargo];
|
||||
|
||||
// Let's check it backwards.. we simply want to best engine available..
|
||||
for (i=start+count-1;i>=start;i--) {
|
||||
// Is it availiable?
|
||||
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
|
||||
if (!HASBIT(_engines[i].player_avail, _current_player) || _engines[i].reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
|
||||
// Can we build it?
|
||||
r = DoCommandByTile(0, i, 0, DC_QUERY_COST, CMD_BUILD_ROAD_VEH);
|
||||
if (r != CMD_ERROR) break;
|
||||
}
|
||||
// We did not find a vehicle :(
|
||||
if (r == CMD_ERROR) { return -1; }
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// Builds the best vehicle possible
|
||||
int AiNew_Build_Vehicle(Player *p, uint tile, byte flag) {
|
||||
int i = AiNew_PickVehicle(p);
|
||||
if (i == -1) return CMD_ERROR;
|
||||
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
return CMD_ERROR;
|
||||
} else {
|
||||
return DoCommandByTile(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
|
||||
}
|
||||
}
|
||||
|
||||
int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag) {
|
||||
static const byte _roadbits_by_dir[4] = {2,1,8,4};
|
||||
int r, r2;
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
return DoCommandByTile(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
|
||||
} else {
|
||||
r = DoCommandByTile(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
||||
if (r == CMD_ERROR) return r;
|
||||
// Try to build the road from the depot
|
||||
r2 = DoCommandByTile(tile + _tileoffs_by_dir[direction], _roadbits_by_dir[direction], 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
// If it fails, ignore it..
|
||||
if (r2 == CMD_ERROR) return r;
|
||||
return r + r2;
|
||||
}
|
||||
}
|
||||
+458
@@ -0,0 +1,458 @@
|
||||
#include "stdafx.h"
|
||||
#include "ttd.h"
|
||||
#include "map.h"
|
||||
#include "command.h"
|
||||
#include "ai.h"
|
||||
|
||||
#define TEST_STATION_NO_DIR 0xFF
|
||||
|
||||
// Tests if a station can be build on the given spot
|
||||
// TODO: make it train compatible
|
||||
bool TestCanBuildStationHere(uint tile, byte dir) {
|
||||
Player *p = DEREF_PLAYER(_current_player);
|
||||
if (dir == TEST_STATION_NO_DIR) {
|
||||
// TODO: currently we only allow spots that can be access from al 4 directions...
|
||||
// should be fixed!!!
|
||||
for (dir=0;dir<4;dir++) {
|
||||
int res = AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST);
|
||||
if (res != CMD_ERROR)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
int res = AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST);
|
||||
if (res == CMD_ERROR)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Checks if a tile 'a' is between the tiles 'b' and 'c'
|
||||
#define TILES_BETWEEN(a,b,c) (GET_TILE_X(a) >= GET_TILE_X(b) && GET_TILE_X(a) <= GET_TILE_X(c) && GET_TILE_Y(a) >= GET_TILE_Y(b) && GET_TILE_Y(a) <= GET_TILE_Y(c))
|
||||
|
||||
// Check if the current tile is in our end-area
|
||||
int32 AyStar_AiPathFinder_EndNodeCheck(AyStar *aystar, OpenListNode *current) {
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
// It is not allowed to have a station on the end of a bridge or tunnel ;)
|
||||
if (current->path.node.user_data[0] != 0) return AYSTAR_DONE;
|
||||
if (TILES_BETWEEN(current->path.node.tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br))
|
||||
if (IS_TILETYPE(current->path.node.tile, MP_CLEAR) || IS_TILETYPE(current->path.node.tile, MP_TREES))
|
||||
if (current->path.parent == NULL || TestCanBuildStationHere(current->path.node.tile,AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile)))
|
||||
return AYSTAR_FOUND_END_NODE;
|
||||
|
||||
return AYSTAR_DONE;
|
||||
}
|
||||
|
||||
// Calculates the hash
|
||||
// Currently it is a 10 bit hash, so the hash array has a max depth of 6 bits (so 64)
|
||||
uint AiPathFinder_Hash(uint key1, uint key2) {
|
||||
return (GET_TILE_X(key1) & 0x1F) + ((GET_TILE_Y(key1) & 0x1F) << 5);
|
||||
}
|
||||
|
||||
// Clear the memory of all the things
|
||||
void AyStar_AiPathFinder_Free(AyStar *aystar) {
|
||||
AyStarMain_Free(aystar);
|
||||
free(aystar);
|
||||
}
|
||||
|
||||
static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
||||
static int32 AyStar_AiPathFinder_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
||||
static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current);
|
||||
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current);
|
||||
|
||||
// This creates the AiPathFinder
|
||||
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo) {
|
||||
PathNode start_node;
|
||||
uint x,y;
|
||||
// Create AyStar
|
||||
AyStar *result = malloc(sizeof(AyStar));
|
||||
init_AyStar(result, AiPathFinder_Hash, 1 << 10);
|
||||
// Set the function pointers
|
||||
result->CalculateG = AyStar_AiPathFinder_CalculateG;
|
||||
result->CalculateH = AyStar_AiPathFinder_CalculateH;
|
||||
result->EndNodeCheck = AyStar_AiPathFinder_EndNodeCheck;
|
||||
result->FoundEndNode = AyStar_AiPathFinder_FoundEndNode;
|
||||
result->GetNeighbours = AyStar_AiPathFinder_GetNeighbours;
|
||||
|
||||
result->free = AyStar_AiPathFinder_Free;
|
||||
|
||||
// Set some information
|
||||
result->loops_per_tick = AI_PATHFINDER_LOOPS_PER_TICK;
|
||||
result->max_path_cost = 0;
|
||||
result->max_search_nodes = AI_PATHFINDER_MAX_SEARCH_NODES;
|
||||
|
||||
// Set the user_data to the PathFinderInfo
|
||||
result->user_target = PathFinderInfo;
|
||||
|
||||
// Set the start node
|
||||
start_node.parent = NULL;
|
||||
start_node.node.direction = 0;
|
||||
start_node.node.user_data[0] = 0;
|
||||
|
||||
// Now we add all the starting tiles
|
||||
for (x=GET_TILE_X(PathFinderInfo->start_tile_tl);x<=GET_TILE_X(PathFinderInfo->start_tile_br);x++) {
|
||||
for (y=GET_TILE_Y(PathFinderInfo->start_tile_tl);y<=GET_TILE_Y(PathFinderInfo->start_tile_br);y++) {
|
||||
start_node.node.tile = TILE_XY(x,y);
|
||||
result->addstart(result, &start_node.node);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// To reuse AyStar we sometimes have to clean all the memory
|
||||
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo) {
|
||||
PathNode start_node;
|
||||
uint x,y;
|
||||
|
||||
aystar->clear(aystar);
|
||||
|
||||
// Set the user_data to the PathFinderInfo
|
||||
aystar->user_target = PathFinderInfo;
|
||||
|
||||
// Set the start node
|
||||
start_node.parent = NULL;
|
||||
start_node.node.direction = 0;
|
||||
start_node.node.user_data[0] = 0;
|
||||
start_node.node.tile = PathFinderInfo->start_tile_tl;
|
||||
|
||||
// Now we add all the starting tiles
|
||||
for (x=GET_TILE_X(PathFinderInfo->start_tile_tl);x<=GET_TILE_X(PathFinderInfo->start_tile_br);x++) {
|
||||
for (y=GET_TILE_Y(PathFinderInfo->start_tile_tl);y<=GET_TILE_Y(PathFinderInfo->start_tile_br);y++) {
|
||||
if (!(IS_TILETYPE(TILE_XY(x,y), MP_CLEAR) || IS_TILETYPE(TILE_XY(x,y), MP_TREES))) continue;
|
||||
if (!TestCanBuildStationHere(TILE_XY(x,y),TEST_STATION_NO_DIR)) continue;
|
||||
start_node.node.tile = TILE_XY(x,y);
|
||||
aystar->addstart(aystar, &start_node.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The h-value, simple calculation
|
||||
static int32 AyStar_AiPathFinder_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent) {
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
int r, r2;
|
||||
if (PathFinderInfo->end_direction != AI_PATHFINDER_NO_DIRECTION) {
|
||||
// The station is pointing to a direction, add a tile towards that direction, so the H-value is more accurate
|
||||
r = GetTileDist(current->tile, PathFinderInfo->end_tile_tl + _tiles_around[PathFinderInfo->end_direction]);
|
||||
r2 = GetTileDist(current->tile, PathFinderInfo->end_tile_br + _tiles_around[PathFinderInfo->end_direction]);
|
||||
} else {
|
||||
// No direction, so just get the fastest route to the station
|
||||
r = GetTileDist(current->tile, PathFinderInfo->end_tile_tl);
|
||||
r2 = GetTileDist(current->tile, PathFinderInfo->end_tile_br);
|
||||
}
|
||||
// See if the bottomright is faster then the topleft..
|
||||
if (r2 < r) r = r2;
|
||||
return r * AI_PATHFINDER_H_MULTIPLER;
|
||||
}
|
||||
|
||||
// We found the end.. let's get the route back and put it in an array
|
||||
static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current) {
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
int i = 0;
|
||||
PathNode *parent = ¤t->path;
|
||||
|
||||
do {
|
||||
PathFinderInfo->route_extra[i] = parent->node.user_data[0];
|
||||
PathFinderInfo->route[i++] = parent->node.tile;
|
||||
if (i > lengthof(PathFinderInfo->route)) {
|
||||
// We ran out of space for the PathFinder
|
||||
DEBUG(ai,0)("[AiPathFinder] Ran out of spacein the route[] array!!!");
|
||||
PathFinderInfo->route_length = -1; // -1 indicates out of space
|
||||
return;
|
||||
}
|
||||
parent = parent->parent;
|
||||
} while (parent != NULL);
|
||||
PathFinderInfo->route_length = i;
|
||||
DEBUG(ai,1)("[Ai-PathFinding] Found route of %d nodes long in %d nodes of searching",i,Hash_Size(&aystar->ClosedListHash));
|
||||
}
|
||||
|
||||
// What tiles are around us.
|
||||
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current) {
|
||||
int i, r, dir;
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
|
||||
aystar->num_neighbours = 0;
|
||||
|
||||
// Go through all surrounding tiles and check if they are within the limits
|
||||
for (i=0;i<4;i++) {
|
||||
if (GET_TILE_X(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_X(_tiles_around[i] + current->path.node.tile) < TILE_X_MAX - 1 &&
|
||||
GET_TILE_Y(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_Y(_tiles_around[i] + current->path.node.tile) < TILE_Y_MAX - 1) {
|
||||
// We also directly test if the current tile can connect to this tile..
|
||||
// We do this simply by just building the tile!
|
||||
|
||||
// If the next step is a bridge, we have to enter it the right way
|
||||
if (!PathFinderInfo->rail_or_road && AI_PATHFINDER_IS_ROAD(current->path.node.tile + _tiles_around[i])) {
|
||||
if (IS_TILETYPE(current->path.node.tile + _tiles_around[i], MP_TUNNELBRIDGE)) {
|
||||
// An existing bridge... let's test the direction ;)
|
||||
if ((_map5[current->path.node.tile + _tiles_around[i]] & 1) != (i & 1)) continue;
|
||||
// This problem only is valid for tunnels:
|
||||
// When the last tile was not yet a tunnel, check if we enter from the right side..
|
||||
if (!IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE) && (_map5[current->path.node.tile + _tiles_around[i]] & 0x80) == 0) {
|
||||
if (i != (_map5[current->path.node.tile + _tiles_around[i]] & 3)) continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// But also if we are on a bridge, we can only move a certain direction
|
||||
if (!PathFinderInfo->rail_or_road && AI_PATHFINDER_IS_ROAD(current->path.node.tile)) {
|
||||
if (IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE)) {
|
||||
// An existing bridge/tunnel... let's test the direction ;)
|
||||
if ((_map5[current->path.node.tile] & 1) != (i & 1)) continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||
|
||||
(AI_PATHFINDER_FLAG_TUNNEL & current->path.node.user_data[0]) != 0) {
|
||||
// We are a bridge/tunnel, how cool!!
|
||||
// This means we can only point forward.. get the direction from the user_data
|
||||
if (i != (current->path.node.user_data[0] >> 8)) continue;
|
||||
}
|
||||
dir = 0;
|
||||
|
||||
// First, check if we have a parent
|
||||
if (current->path.parent == NULL && current->path.node.user_data[0] == 0) {
|
||||
// If not, this means we are at the starting station
|
||||
if (PathFinderInfo->start_direction != AI_PATHFINDER_NO_DIRECTION) {
|
||||
// We do need a direction?
|
||||
if (AiNew_GetDirection(current->path.node.tile, current->path.node.tile + _tiles_around[i]) != PathFinderInfo->start_direction)
|
||||
// We are not pointing the right way, invalid tile
|
||||
continue;
|
||||
}
|
||||
} else if (current->path.node.user_data[0] == 0) {
|
||||
if (PathFinderInfo->rail_or_road) {
|
||||
// Rail check
|
||||
dir = AiNew_GetRailDirection(current->path.parent->node.tile, current->path.node.tile, current->path.node.tile + _tiles_around[i]);
|
||||
r = DoCommandByTile(current->path.node.tile, 0, dir, DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
|
||||
if (r == CMD_ERROR) continue;
|
||||
#ifdef AI_PATHFINDER_NO_90DEGREES_TURN
|
||||
if (current->path.parent->parent != NULL) {
|
||||
// Check if we don't make a 90degree curve
|
||||
int dir1 = AiNew_GetRailDirection(current->path.parent->parent->node.tile, current->path.parent->node.tile, current->path.node.tile);
|
||||
if (_illegal_curves[dir1] == dir || _illegal_curves[dir] == dir1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// Road check
|
||||
dir = AiNew_GetRoadDirection(current->path.parent->node.tile, current->path.node.tile, current->path.node.tile + _tiles_around[i]);
|
||||
if (AI_PATHFINDER_IS_ROAD(current->path.node.tile)) {
|
||||
if (IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE)) {
|
||||
// We have a bridge, how nicely! We should mark it...
|
||||
dir = 0;
|
||||
} else {
|
||||
// It already has road.. check if we miss any bits!
|
||||
if ((_map5[current->path.node.tile] & dir) != dir) {
|
||||
// We do miss some pieces :(
|
||||
dir &= ~_map5[current->path.node.tile];
|
||||
} else {
|
||||
dir = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only destruct things if it is MP_CLEAR of MP_TREES
|
||||
if (dir != 0) {
|
||||
r = DoCommandByTile(current->path.node.tile, dir, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
if (r == CMD_ERROR) continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// The tile can be connected
|
||||
aystar->neighbours[aystar->num_neighbours].tile = _tiles_around[i] + current->path.node.tile;
|
||||
aystar->neighbours[aystar->num_neighbours].user_data[0] = 0;
|
||||
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Next step, check for bridges and tunnels
|
||||
if (current->path.parent != NULL && current->path.node.user_data[0] == 0) {
|
||||
|
||||
TileInfo ti;
|
||||
// First we get the dir from this tile and his parent
|
||||
int dir = AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile);
|
||||
// It means we can only walk with the track, so the bridge has to be in the same direction
|
||||
TileIndex tile = current->path.node.tile;
|
||||
TileIndex new_tile = tile;
|
||||
|
||||
FindLandscapeHeightByTile(&ti, tile);
|
||||
|
||||
// Bridges can only be build on land that is not flat
|
||||
// And if there is a road or rail blocking
|
||||
if (ti.tileh != 0 ||
|
||||
(PathFinderInfo->rail_or_road && IS_TILETYPE(tile + _tiles_around[dir], MP_STREET)) ||
|
||||
(!PathFinderInfo->rail_or_road && IS_TILETYPE(tile + _tiles_around[dir], MP_RAILWAY))) {
|
||||
|
||||
for (;;) {
|
||||
new_tile += _tiles_around[dir];
|
||||
|
||||
// Precheck, is the length allowed?
|
||||
if (!CheckBridge_Stuff(0,GetBridgeLength(tile, new_tile))) break;
|
||||
|
||||
// Check if we hit the station-tile.. we don't like that!
|
||||
if (TILES_BETWEEN(new_tile,PathFinderInfo->end_tile_tl,PathFinderInfo->end_tile_br)) break;
|
||||
|
||||
// Try building the bridge..
|
||||
r = DoCommandByTile(tile, new_tile, (0<<8) + (MAX_BRIDGES / 2), DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
if (r == CMD_ERROR) continue;
|
||||
// We can build a bridge here.. add him to the neighbours
|
||||
aystar->neighbours[aystar->num_neighbours].tile = new_tile;
|
||||
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_BRIDGE + (dir << 8);
|
||||
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
||||
// We can only have 12 neighbours, and we need 1 left for tunnels
|
||||
if (aystar->num_neighbours == 11) break;
|
||||
}
|
||||
}
|
||||
|
||||
// Next, check for tunnels!
|
||||
// Tunnels can only be build with tileh of 3, 6, 9 or 12, depending on the direction
|
||||
// For now, we check both sides for this tile.. terraforming gives fuzzy result
|
||||
if ((dir == 0 && ti.tileh == 12) ||
|
||||
(dir == 1 && ti.tileh == 6) ||
|
||||
(dir == 2 && ti.tileh == 3) ||
|
||||
(dir == 3 && ti.tileh == 9)) {
|
||||
// Now simply check if a tunnel can be build
|
||||
r = DoCommandByTile(tile, (PathFinderInfo->rail_or_road?0:0x200), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
||||
FindLandscapeHeightByTile(&ti, _build_tunnel_endtile);
|
||||
if (r != CMD_ERROR && (ti.tileh == 3 || ti.tileh == 6 || ti.tileh == 9 || ti.tileh == 12)) {
|
||||
aystar->neighbours[aystar->num_neighbours].tile = _build_tunnel_endtile;
|
||||
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_TUNNEL + (dir << 8);
|
||||
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern uint GetRailFoundation(uint tileh, uint bits);
|
||||
extern uint GetRoadFoundation(uint tileh, uint bits);
|
||||
extern uint GetBridgeFoundation(uint tileh, byte direction);
|
||||
enum {
|
||||
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
|
||||
};
|
||||
|
||||
// The most important function: it calculates the g-value
|
||||
static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent) {
|
||||
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
|
||||
int r, res = 0;
|
||||
TileInfo ti, parent_ti;
|
||||
|
||||
// Gather some information about the tile..
|
||||
FindLandscapeHeightByTile(&ti, current->tile);
|
||||
FindLandscapeHeightByTile(&parent_ti, parent->path.node.tile);
|
||||
|
||||
// Check if we hit the end-tile
|
||||
if (TILES_BETWEEN(current->tile,PathFinderInfo->end_tile_tl,PathFinderInfo->end_tile_br)) {
|
||||
// We are at the end-tile, check if we had a direction or something...
|
||||
if (PathFinderInfo->end_direction != AI_PATHFINDER_NO_DIRECTION && AiNew_GetDirection(current->tile, parent->path.node.tile) != PathFinderInfo->end_direction)
|
||||
// We are not pointing the right way, invalid tile
|
||||
return AYSTAR_INVALID_NODE;
|
||||
// If it was valid, drop out.. we don't build on the endtile
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Give everything a small penalty
|
||||
res += AI_PATHFINDER_PENALTY;
|
||||
|
||||
if (!PathFinderInfo->rail_or_road) {
|
||||
// Road has the lovely advantage it can use other road... check if
|
||||
// the current tile is road, and if so, give a good bonus
|
||||
if (AI_PATHFINDER_IS_ROAD(current->tile)) {
|
||||
res -= AI_PATHFINDER_ROAD_ALREADY_EXISTS_BONUS;
|
||||
}
|
||||
}
|
||||
|
||||
// We should give a penalty when the tile is going up or down.. this is one way to do so!
|
||||
// Too bad we have to count it from the parent.. but that is not so bad
|
||||
if (parent_ti.tileh != 0 && parent->path.parent != NULL) {
|
||||
// Skip if the tile was from a bridge or tunnel
|
||||
if (parent->path.node.user_data[0] == 0 && current->user_data[0] == 0) {
|
||||
if (PathFinderInfo->rail_or_road) {
|
||||
r = GetRailFoundation(parent_ti.tileh, 1 << AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
|
||||
// Maybe is BRIDGE_NO_FOUNDATION a bit strange here, but it contains just the right information..
|
||||
if (r >= 15 || (r == 0 && (BRIDGE_NO_FOUNDATION & (1 << ti.tileh)))) {
|
||||
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||
}
|
||||
} else {
|
||||
if (!(AI_PATHFINDER_IS_ROAD(parent->path.node.tile) && IS_TILETYPE(parent->path.node.tile, MP_TUNNELBRIDGE))) {
|
||||
r = GetRoadFoundation(parent_ti.tileh, AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
|
||||
if (r >= 15 || r == 0)
|
||||
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Are we part of a tunnel?
|
||||
if ((AI_PATHFINDER_FLAG_TUNNEL & current->user_data[0]) != 0) {
|
||||
// Tunnels are very expensive when build on long routes..
|
||||
// Ironicly, we are using BridgeCode here ;)
|
||||
r = AI_PATHFINDER_TUNNEL_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
|
||||
res += r + (r >> 8);
|
||||
}
|
||||
|
||||
// Are we part of a bridge?
|
||||
if ((AI_PATHFINDER_FLAG_BRIDGE & current->user_data[0]) != 0) {
|
||||
// That means for every length a penalty
|
||||
res += AI_PATHFINDER_BRIDGE_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
|
||||
// Check if we are going up or down, first for the starting point
|
||||
// In user_data[0] is at the 8th bit the direction
|
||||
if (!(BRIDGE_NO_FOUNDATION & (1 << parent_ti.tileh))) {
|
||||
if (GetBridgeFoundation(parent_ti.tileh, (current->user_data[0] >> 8) & 1) < 15)
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
// Second for the end point
|
||||
if (!(BRIDGE_NO_FOUNDATION & (1 << ti.tileh))) {
|
||||
if (GetBridgeFoundation(ti.tileh, (current->user_data[0] >> 8) & 1) < 15)
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
if (parent_ti.tileh == 0)
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
if (ti.tileh == 0)
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
|
||||
// To prevent the AI from taking the fastest way in tiles, but not the fastest way
|
||||
// in speed, we have to give a good penalty to direction changing
|
||||
// This way, we get almost the fastest way in tiles, and a very good speed on the track
|
||||
if (!PathFinderInfo->rail_or_road) {
|
||||
if (parent->path.parent != NULL &&
|
||||
AiNew_GetDirection(current->tile, parent->path.node.tile) != AiNew_GetDirection(parent->path.node.tile, parent->path.parent->node.tile)) {
|
||||
// When road exists, we don't like turning, but its free, so don't be to piggy about it
|
||||
if (AI_PATHFINDER_IS_ROAD(parent->path.node.tile))
|
||||
res += AI_PATHFINDER_DIRECTION_CHANGE_ON_EXISTING_ROAD_PENALTY;
|
||||
else
|
||||
res += AI_PATHFINDER_DIRECTION_CHANGE_PENALTY;
|
||||
}
|
||||
} else {
|
||||
// For rail we have 1 exeption: diagonal rail..
|
||||
// So we fetch 2 raildirection. That of the current one, and of the one before that
|
||||
if (parent->path.parent != NULL && parent->path.parent->parent != NULL) {
|
||||
int dir1 = AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile);
|
||||
int dir2 = AiNew_GetRailDirection(parent->path.parent->parent->node.tile, parent->path.parent->node.tile, parent->path.node.tile);
|
||||
// First, see if we are on diagonal path, that is better then straight path
|
||||
if (dir1 > 1) { res -= AI_PATHFINDER_DIAGONAL_BONUS; }
|
||||
|
||||
// First see if they are different
|
||||
if (dir1 != dir2) {
|
||||
// dir 2 and 3 are 1 diagonal track, and 4 and 5.
|
||||
if (!(((dir1 == 2 || dir1 == 3) && (dir2 == 2 || dir2 == 3)) || ((dir1 == 4 || dir1 == 5) && (dir2 == 4 || dir2 == 5)))) {
|
||||
// It is not, so we changed of direction
|
||||
res += AI_PATHFINDER_DIRECTION_CHANGE_PENALTY;
|
||||
}
|
||||
if (parent->path.parent->parent->parent != NULL) {
|
||||
int dir3 = AiNew_GetRailDirection(parent->path.parent->parent->parent->node.tile, parent->path.parent->parent->node.tile, parent->path.parent->node.tile);
|
||||
// Check if we changed 3 tiles of direction in 3 tiles.. bad!!!
|
||||
if ((dir1 == 0 || dir1 == 1) && dir2 > 1 && (dir3 == 0 || dir3 == 1)) {
|
||||
res += AI_PATHFINDER_CURVE_PENALTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Res should never be below zero.. if so, make it zero!
|
||||
if (res < 0) { res = 0; }
|
||||
|
||||
// Return our value
|
||||
return res;
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
/* $Id$ */
|
||||
#include "stdafx.h"
|
||||
#include "ttd.h"
|
||||
#include "map.h"
|
||||
#include "ai.h"
|
||||
#include "vehicle.h"
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "../../openttd.h"
|
||||
#include "../../debug.h"
|
||||
#include "../../map.h"
|
||||
#include "trolly.h"
|
||||
#include "../../vehicle.h"
|
||||
|
||||
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
||||
{
|
||||
int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c) {
|
||||
// 0 = vert
|
||||
// 1 = horz
|
||||
// 2 = dig up-left
|
||||
@@ -19,13 +15,13 @@ int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
||||
int x1, x2, x3;
|
||||
int y1, y2, y3;
|
||||
|
||||
x1 = TileX(tile_a);
|
||||
x2 = TileX(tile_b);
|
||||
x3 = TileX(tile_c);
|
||||
x1 = GET_TILE_X(tile_a);
|
||||
x2 = GET_TILE_X(tile_b);
|
||||
x3 = GET_TILE_X(tile_c);
|
||||
|
||||
y1 = TileY(tile_a);
|
||||
y2 = TileY(tile_b);
|
||||
y3 = TileY(tile_c);
|
||||
y1 = GET_TILE_Y(tile_a);
|
||||
y2 = GET_TILE_Y(tile_b);
|
||||
y3 = GET_TILE_Y(tile_c);
|
||||
|
||||
if (y1 == y2 && y2 == y3) return 0;
|
||||
if (x1 == x2 && x2 == x3) return 1;
|
||||
@@ -49,19 +45,18 @@ int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
||||
{
|
||||
int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c) {
|
||||
int x1, x2, x3;
|
||||
int y1, y2, y3;
|
||||
int r;
|
||||
|
||||
x1 = TileX(tile_a);
|
||||
x2 = TileX(tile_b);
|
||||
x3 = TileX(tile_c);
|
||||
x1 = GET_TILE_X(tile_a);
|
||||
x2 = GET_TILE_X(tile_b);
|
||||
x3 = GET_TILE_X(tile_c);
|
||||
|
||||
y1 = TileY(tile_a);
|
||||
y2 = TileY(tile_b);
|
||||
y3 = TileY(tile_c);
|
||||
y1 = GET_TILE_Y(tile_a);
|
||||
y2 = GET_TILE_Y(tile_b);
|
||||
y3 = GET_TILE_Y(tile_c);
|
||||
|
||||
r = 0;
|
||||
|
||||
@@ -79,11 +74,10 @@ int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
||||
}
|
||||
|
||||
// Get's the direction between 2 tiles seen from tile_a
|
||||
int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
|
||||
{
|
||||
if (TileY(tile_a) < TileY(tile_b)) return 1;
|
||||
if (TileY(tile_a) > TileY(tile_b)) return 3;
|
||||
if (TileX(tile_a) < TileX(tile_b)) return 2;
|
||||
int AiNew_GetDirection(uint tile_a, uint tile_b) {
|
||||
if (GET_TILE_Y(tile_a) < GET_TILE_Y(tile_b)) return 1;
|
||||
if (GET_TILE_Y(tile_a) > GET_TILE_Y(tile_b)) return 3;
|
||||
if (GET_TILE_X(tile_a) < GET_TILE_X(tile_b)) return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "station_map.h"
|
||||
#include "vehicle.h"
|
||||
|
||||
|
||||
static inline bool IsAircraftInHangar(const Vehicle* v)
|
||||
{
|
||||
assert(v->type == VEH_Aircraft);
|
||||
return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile);
|
||||
}
|
||||
|
||||
static inline bool IsAircraftInHangarStopped(const Vehicle* v)
|
||||
{
|
||||
return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED;
|
||||
}
|
||||
+447
-591
File diff suppressed because it is too large
Load Diff
+360
-437
File diff suppressed because it is too large
Load Diff
@@ -1,25 +1,20 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "ttd.h"
|
||||
#include "map.h"
|
||||
#include "airport.h"
|
||||
#include "macros.h"
|
||||
#include "variables.h"
|
||||
|
||||
static AirportFTAClass* CountryAirport;
|
||||
static AirportFTAClass* CityAirport;
|
||||
static AirportFTAClass* Oilrig;
|
||||
static AirportFTAClass* Heliport;
|
||||
static AirportFTAClass* MetropolitanAirport;
|
||||
static AirportFTAClass* InternationalAirport;
|
||||
AirportFTAClass *CountryAirport;
|
||||
AirportFTAClass *CityAirport;
|
||||
AirportFTAClass *Heliport, *Oilrig;
|
||||
AirportFTAClass *MetropolitanAirport;
|
||||
AirportFTAClass *InternationalAirport;
|
||||
|
||||
static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||
const byte *terminals, const byte *helipads,
|
||||
const byte nofterminals, const byte nofterminalgroups,
|
||||
const byte nofhelipads, const byte nofhelipadgroups,
|
||||
const byte entry_point, const byte acc_planes,
|
||||
const AirportFTAbuildup *FA,
|
||||
const TileIndexDiffC *depots, const byte nof_depots);
|
||||
const TileIndex *depots, const byte nof_depots);
|
||||
static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
|
||||
|
||||
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
|
||||
@@ -28,82 +23,31 @@ static byte AirportTestFTA(const AirportFTAClass *Airport);
|
||||
/*static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
|
||||
static byte AirportBlockToString(uint32 block);*/
|
||||
|
||||
void InitializeAirports(void)
|
||||
void InitializeAirports()
|
||||
{
|
||||
// country airport
|
||||
CountryAirport = malloc(sizeof(AirportFTAClass));
|
||||
|
||||
AirportFTAClass_Constructor(
|
||||
CountryAirport,
|
||||
_airport_terminal_country,
|
||||
NULL,
|
||||
16,
|
||||
ALL,
|
||||
_airport_fta_country,
|
||||
_airport_depots_country,
|
||||
lengthof(_airport_depots_country)
|
||||
);
|
||||
CountryAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
|
||||
AirportFTAClass_Constructor(CountryAirport, 2, 1, 0, 0, 16, ALL, _airport_fta_country, _airport_depots_country, lengthof(_airport_depots_country));
|
||||
|
||||
// city airport
|
||||
CityAirport = malloc(sizeof(AirportFTAClass));
|
||||
|
||||
AirportFTAClass_Constructor(
|
||||
CityAirport,
|
||||
_airport_terminal_city,
|
||||
NULL,
|
||||
19,
|
||||
ALL,
|
||||
_airport_fta_city,
|
||||
_airport_depots_city,
|
||||
lengthof(_airport_depots_city)
|
||||
);
|
||||
CityAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
|
||||
AirportFTAClass_Constructor(CityAirport, 3, 1, 0, 0, 19, ALL, _airport_fta_city, _airport_depots_city, lengthof(_airport_depots_city));
|
||||
|
||||
// metropolitan airport
|
||||
MetropolitanAirport = malloc(sizeof(AirportFTAClass));
|
||||
|
||||
AirportFTAClass_Constructor(
|
||||
MetropolitanAirport,
|
||||
_airport_terminal_metropolitan,
|
||||
NULL,
|
||||
20,
|
||||
ALL,
|
||||
_airport_fta_metropolitan,
|
||||
_airport_depots_metropolitan,
|
||||
lengthof(_airport_depots_metropolitan)
|
||||
);
|
||||
MetropolitanAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
|
||||
AirportFTAClass_Constructor(MetropolitanAirport, 3, 1, 0, 0, 20, ALL, _airport_fta_metropolitan, _airport_depots_metropolitan, lengthof(_airport_depots_metropolitan));
|
||||
|
||||
// international airport
|
||||
InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
|
||||
|
||||
AirportFTAClass_Constructor(
|
||||
InternationalAirport,
|
||||
_airport_terminal_international,
|
||||
_airport_helipad_international,
|
||||
37,
|
||||
ALL,
|
||||
_airport_fta_international,
|
||||
_airport_depots_international,
|
||||
lengthof(_airport_depots_international)
|
||||
);
|
||||
AirportFTAClass_Constructor(InternationalAirport, 6, 2, 2, 1, 37, ALL, _airport_fta_international, _airport_depots_international, lengthof(_airport_depots_international));
|
||||
|
||||
// heliport, oilrig
|
||||
Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
|
||||
|
||||
AirportFTAClass_Constructor(
|
||||
Heliport,
|
||||
NULL,
|
||||
_airport_helipad_heliport_oilrig,
|
||||
7,
|
||||
HELICOPTERS_ONLY,
|
||||
_airport_fta_heliport_oilrig,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
|
||||
AirportFTAClass_Constructor(Heliport, 0, 0, 1, 1, 7, HELICOPTERS_ONLY, _airport_fta_heliport_oilrig, NULL, 0);
|
||||
Oilrig = Heliport; // exactly the same structure for heliport/oilrig, so share state machine
|
||||
}
|
||||
|
||||
void UnInitializeAirports(void)
|
||||
void UnInitializeAirports()
|
||||
{
|
||||
AirportFTAClass_Destructor(CountryAirport);
|
||||
AirportFTAClass_Destructor(CityAirport);
|
||||
@@ -113,46 +57,12 @@ void UnInitializeAirports(void)
|
||||
}
|
||||
|
||||
static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||
const byte *terminals, const byte *helipads,
|
||||
const byte nofterminals, const byte nofterminalgroups,
|
||||
const byte nofhelipads, const byte nofhelipadgroups,
|
||||
const byte entry_point, const byte acc_planes,
|
||||
const AirportFTAbuildup *FA,
|
||||
const TileIndexDiffC *depots, const byte nof_depots)
|
||||
const TileIndex *depots, const byte nof_depots)
|
||||
{
|
||||
byte nofterminals, nofhelipads;
|
||||
byte nofterminalgroups = 0;
|
||||
byte nofhelipadgroups = 0;
|
||||
const byte * curr;
|
||||
int i;
|
||||
nofterminals = nofhelipads = 0;
|
||||
|
||||
//now we read the number of terminals we have
|
||||
if (terminals != NULL) {
|
||||
i = terminals[0];
|
||||
nofterminalgroups = i;
|
||||
curr = terminals;
|
||||
while (i-- > 0) {
|
||||
curr++;
|
||||
assert(*curr != 0); //we don't want to have an empty group
|
||||
nofterminals += *curr;
|
||||
}
|
||||
|
||||
}
|
||||
Airport->terminals = terminals;
|
||||
|
||||
//read helipads
|
||||
if (helipads != NULL) {
|
||||
i = helipads[0];
|
||||
nofhelipadgroups = i;
|
||||
curr = helipads;
|
||||
while (i-- > 0) {
|
||||
curr++;
|
||||
assert(*curr != 0); //no empty groups please
|
||||
nofhelipads += *curr;
|
||||
}
|
||||
|
||||
}
|
||||
Airport->helipads = helipads;
|
||||
|
||||
// if there are more terminals than 6, internal variables have to be changed, so don't allow that
|
||||
// same goes for helipads
|
||||
if (nofterminals > MAX_TERMINALS) { printf("Currently only maximum of %2d terminals are supported (you wanted %2d)\n", MAX_TERMINALS, nofterminals);}
|
||||
@@ -160,15 +70,23 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||
// terminals/helipads are divided into groups. Groups are computed by dividing the number
|
||||
// of terminals by the number of groups. Half in half. If #terminals is uneven, first group
|
||||
// will get the less # of terminals
|
||||
if (nofterminalgroups > nofterminals) { printf("# of terminalgroups (%2d) must be less or equal to terminals (%2d)", nofterminals, nofterminalgroups);}
|
||||
if (nofhelipadgroups > nofhelipads) { printf("# of helipadgroups (%2d) must be less or equal to helipads (%2d)", nofhelipads, nofhelipadgroups);}
|
||||
|
||||
assert(nofterminals <= MAX_TERMINALS);
|
||||
assert(nofhelipads <= MAX_HELIPADS);
|
||||
assert(nofterminalgroups <= nofterminals);
|
||||
assert(nofhelipadgroups <= nofhelipads);
|
||||
|
||||
Airport->nofelements = AirportGetNofElements(FA);
|
||||
// check
|
||||
if (entry_point >= Airport->nofelements) {printf("Entry point (%2d) must be within the airport positions (which is max %2d)\n", entry_point, Airport->nofelements);}
|
||||
assert(entry_point < Airport->nofelements);
|
||||
|
||||
Airport->nofterminals = nofterminals;
|
||||
Airport->nofterminalgroups = nofterminalgroups;
|
||||
Airport->nofhelipads = nofhelipads;
|
||||
Airport->nofhelipadgroups = nofhelipadgroups;
|
||||
Airport->acc_planes = acc_planes;
|
||||
Airport->entry_point = entry_point;
|
||||
Airport->airport_depots = depots;
|
||||
@@ -177,15 +95,14 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||
|
||||
// build the state machine
|
||||
AirportBuildAutomata(Airport, FA);
|
||||
DEBUG(misc, 1) ("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s); Entry Point %d",
|
||||
Airport->nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, Airport->entry_point
|
||||
);
|
||||
DEBUG(misc, 1) ("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s)", Airport->nofelements,
|
||||
Airport->nofterminals, Airport->nofterminalgroups, Airport->nofhelipads, Airport->nofhelipadgroups);
|
||||
|
||||
|
||||
{
|
||||
byte ret = AirportTestFTA(Airport);
|
||||
if (ret != MAX_ELEMENTS) printf("ERROR with element: %d\n", ret - 1);
|
||||
assert(ret == MAX_ELEMENTS);
|
||||
byte _retval = AirportTestFTA(Airport);
|
||||
if (_retval != MAX_ELEMENTS) {printf("ERROR with element: %d\n", _retval-1);}
|
||||
assert(_retval == MAX_ELEMENTS);
|
||||
}
|
||||
// print out full information
|
||||
// true -- full info including heading, block, etc
|
||||
@@ -215,13 +132,12 @@ static uint16 AirportGetNofElements(const AirportFTAbuildup *FA)
|
||||
int i;
|
||||
uint16 nofelements = 0;
|
||||
int temp = FA[0].position;
|
||||
|
||||
for (i = 0; i < MAX_ELEMENTS; i++) {
|
||||
if (temp != FA[i].position) {
|
||||
nofelements++;
|
||||
temp = FA[i].position;
|
||||
}
|
||||
if (FA[i].position == MAX_ELEMENTS) break;
|
||||
if (FA[i].position == MAX_ELEMENTS) {break;}
|
||||
}
|
||||
return nofelements;
|
||||
}
|
||||
@@ -231,7 +147,7 @@ static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuild
|
||||
AirportFTA *FAutomata;
|
||||
AirportFTA *current;
|
||||
uint16 internalcounter, i;
|
||||
FAutomata = malloc(sizeof(AirportFTA) * Airport->nofelements);
|
||||
FAutomata = (AirportFTA *)malloc(sizeof(AirportFTA) * Airport->nofelements);
|
||||
Airport->layout = FAutomata;
|
||||
internalcounter = 0;
|
||||
|
||||
@@ -243,13 +159,12 @@ static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuild
|
||||
current->next_position = FA[internalcounter].next_in_chain;
|
||||
|
||||
// outgoing nodes from the same position, create linked list
|
||||
while (current->position == FA[internalcounter + 1].position) {
|
||||
AirportFTA* newNode = malloc(sizeof(AirportFTA));
|
||||
|
||||
newNode->position = FA[internalcounter + 1].position;
|
||||
newNode->heading = FA[internalcounter + 1].heading;
|
||||
newNode->block = FA[internalcounter + 1].block;
|
||||
newNode->next_position = FA[internalcounter + 1].next_in_chain;
|
||||
while (current->position == FA[internalcounter+1].position) {
|
||||
AirportFTA *newNode = (AirportFTA *)malloc(sizeof(AirportFTA));
|
||||
newNode->position = FA[internalcounter+1].position;
|
||||
newNode->heading = FA[internalcounter+1].heading;
|
||||
newNode->block = FA[internalcounter+1].block;
|
||||
newNode->next_position = FA[internalcounter+1].next_in_chain;
|
||||
// create link
|
||||
current->next_in_chain = newNode;
|
||||
current = current->next_in_chain;
|
||||
@@ -268,14 +183,14 @@ static byte AirportTestFTA(const AirportFTAClass *Airport)
|
||||
|
||||
for (i = 0; i < Airport->nofelements; i++) {
|
||||
position = Airport->layout[i].position;
|
||||
if (position != next_element) return i;
|
||||
if (position != next_element) {return i;}
|
||||
temp = &Airport->layout[i];
|
||||
|
||||
do {
|
||||
if (temp->heading > MAX_HEADINGS && temp->heading != 255) return i;
|
||||
if (temp->heading == 0 && temp->next_in_chain != 0) return i;
|
||||
if (position != temp->position) return i;
|
||||
if (temp->next_position >= Airport->nofelements) return i;
|
||||
if (temp->heading > MAX_HEADINGS && temp->heading != 255) {return i;}
|
||||
if (temp->heading == 0 && temp->next_in_chain != 0) {return i;}
|
||||
if (position != temp->position) {return i;}
|
||||
if (temp->next_position >= Airport->nofelements) {return i;}
|
||||
temp = temp->next_in_chain;
|
||||
} while (temp != NULL);
|
||||
next_element++;
|
||||
@@ -283,8 +198,7 @@ static byte AirportTestFTA(const AirportFTAClass *Airport)
|
||||
return MAX_ELEMENTS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const char* const _airport_heading_strings[] = {
|
||||
static const char* const _airport_heading_strings[MAX_HEADINGS+2] = {
|
||||
"TO_ALL",
|
||||
"HANGAR",
|
||||
"TERM1",
|
||||
@@ -307,6 +221,7 @@ static const char* const _airport_heading_strings[] = {
|
||||
"DUMMY" // extra heading for 255
|
||||
};
|
||||
|
||||
/*
|
||||
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report)
|
||||
{
|
||||
AirportFTA *temp;
|
||||
@@ -320,18 +235,16 @@ static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_repo
|
||||
heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
|
||||
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
|
||||
_airport_heading_strings[heading], AirportBlockToString(temp->block));
|
||||
} else {
|
||||
printf("P:%2d NP:%2d", temp->position, temp->next_position);
|
||||
}
|
||||
else { printf("P:%2d NP:%2d", temp->position, temp->next_position);}
|
||||
while (temp->next_in_chain != NULL) {
|
||||
temp = temp->next_in_chain;
|
||||
if (full_report) {
|
||||
heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
|
||||
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
|
||||
_airport_heading_strings[heading], AirportBlockToString(temp->block));
|
||||
} else {
|
||||
printf("P:%2d NP:%2d", temp->position, temp->next_position);
|
||||
}
|
||||
else { printf("P:%2d NP:%2d", temp->position, temp->next_position);}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@@ -347,8 +260,7 @@ static byte AirportBlockToString(uint32 block)
|
||||
if (block & 0x0000000c) { block >>= 2; i += 2; }
|
||||
if (block & 0x00000002) { i += 1; }
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
}*/
|
||||
|
||||
const AirportFTAClass* GetAirport(const byte airport_type)
|
||||
{
|
||||
@@ -370,14 +282,3 @@ const AirportFTAClass* GetAirport(const byte airport_type)
|
||||
}
|
||||
return Airport;
|
||||
}
|
||||
|
||||
uint32 GetValidAirports(void)
|
||||
{
|
||||
uint32 bytemask = _avail_aircraft; /// sets the first 3 bytes, 0 - 2, @see AdjustAvailAircraft()
|
||||
|
||||
// 1980-1-1 is --> 21915
|
||||
// 1990-1-1 is --> 25568
|
||||
if (_date >= 21915) SETBIT(bytemask, 3); // metropilitan airport 1980
|
||||
if (_date >= 25568) SETBIT(bytemask, 4); // international airport 1990
|
||||
return bytemask;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef AIRPORT_H
|
||||
#define AIRPORT_H
|
||||
|
||||
@@ -15,7 +13,7 @@ enum {
|
||||
AT_HELIPORT = 2,
|
||||
AT_METROPOLITAN = 3,
|
||||
AT_INTERNATIONAL = 4,
|
||||
AT_OILRIG = 15
|
||||
AT_OILRIG = 5
|
||||
};
|
||||
|
||||
// do not change unless you change v->subtype too. This aligns perfectly with its current setting
|
||||
@@ -28,11 +26,13 @@ enum {
|
||||
// Finite sTate mAchine --> FTA
|
||||
typedef struct AirportFTAClass {
|
||||
byte nofelements; // number of positions the airport consists of
|
||||
const byte *terminals;
|
||||
const byte *helipads;
|
||||
byte nofterminals; // number of terminals this airport has
|
||||
byte nofterminalgroups; // terminals belong to so many groups (MAX is the nofterminals)
|
||||
byte nofhelipads; // number of helipads this airport has
|
||||
byte nofhelipadgroups; // helipads belong to so many groups (MAX is the nofhelipads)
|
||||
byte entry_point; // when an airplane arrives at this airport, enter it at position entry_point
|
||||
byte acc_planes; // accept airplanes or helicopters or both
|
||||
const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
|
||||
const TileIndex *airport_depots; // gives the position of the depots on the airports
|
||||
byte nof_depots; // number of depots this airport has
|
||||
struct AirportFTA *layout; // state machine for airport
|
||||
} AirportFTAClass;
|
||||
@@ -46,15 +46,8 @@ typedef struct AirportFTA {
|
||||
struct AirportFTA *next_in_chain; // possible extra movement choices from this position
|
||||
} AirportFTA;
|
||||
|
||||
void InitializeAirports(void);
|
||||
void UnInitializeAirports(void);
|
||||
void InitializeAirports();
|
||||
void UnInitializeAirports();
|
||||
const AirportFTAClass* GetAirport(const byte airport_type);
|
||||
|
||||
/** Get buildable airport bitmask.
|
||||
* @return get all buildable airports at this given time, bitmasked.
|
||||
* Bit 0 means the small airport is buildable, etc.
|
||||
* @todo set availability of airports by year, instead of airplane
|
||||
*/
|
||||
uint32 GetValidAirports(void);
|
||||
|
||||
#endif /* AIRPORT_H */
|
||||
|
||||
+54
-76
@@ -1,10 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "table/sprites.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
@@ -15,14 +11,13 @@
|
||||
#include "vehicle.h"
|
||||
#include "station.h"
|
||||
#include "airport.h"
|
||||
#include "depot.h"
|
||||
|
||||
static byte _selected_airport_type;
|
||||
|
||||
static void ShowBuildAirportPicker(void);
|
||||
static void ShowBuildAirportPicker();
|
||||
|
||||
|
||||
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
void CcBuildAirport(bool success, uint tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (success) {
|
||||
SndPlayTileFx(SND_1F_SPLAT, tile);
|
||||
@@ -30,12 +25,12 @@ void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
}
|
||||
}
|
||||
|
||||
static void PlaceAirport(TileIndex tile)
|
||||
static void PlaceAirport(uint tile)
|
||||
{
|
||||
DoCommandP(tile, _selected_airport_type, 0, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE));
|
||||
}
|
||||
|
||||
static void PlaceAir_DemolishArea(TileIndex tile)
|
||||
static void PlaceAir_DemolishArea(uint tile)
|
||||
{
|
||||
VpStartPlaceSizing(tile, 4);
|
||||
}
|
||||
@@ -43,7 +38,7 @@ static void PlaceAir_DemolishArea(TileIndex tile)
|
||||
|
||||
static void BuildAirClick_Airport(Window *w)
|
||||
{
|
||||
if (HandlePlacePushButton(w, 3, SPR_CURSOR_AIRPORT, 1, PlaceAirport)) ShowBuildAirportPicker();
|
||||
if (HandlePlacePushButton(w, 3, 0xAA4, 1, PlaceAirport)) ShowBuildAirportPicker();
|
||||
}
|
||||
|
||||
static void BuildAirClick_Demolish(Window *w)
|
||||
@@ -65,7 +60,7 @@ static OnButtonClick * const _build_air_button_proc[] = {
|
||||
|
||||
static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
DrawWindowWidgets(w);
|
||||
break;
|
||||
@@ -75,15 +70,6 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
|
||||
_build_air_button_proc[e->click.widget - 3](w);
|
||||
break;
|
||||
|
||||
case WE_KEYPRESS: {
|
||||
switch (e->keypress.keycode) {
|
||||
case '1': BuildAirClick_Airport(w); break;
|
||||
case '2': BuildAirClick_Demolish(w); break;
|
||||
case 'l': BuildAirClick_Landscaping(w); break;
|
||||
default: return;
|
||||
}
|
||||
} break;
|
||||
|
||||
case WE_PLACE_OBJ:
|
||||
_place_proc(e->place.tile);
|
||||
break;
|
||||
@@ -106,20 +92,16 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
|
||||
if (w != 0)
|
||||
WP(w,def_d).close = true;
|
||||
break;
|
||||
|
||||
case WE_DESTROY:
|
||||
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const Widget _air_toolbar_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 73, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, RESIZE_NONE, 7, 74, 85, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 41, 14, 35, 0x2E8, STR_A01E_BUILD_AIRPORT},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 42, 63, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 64, 85, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 73, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, 7, 74, 85, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_PANEL, 7, 0, 41, 14, 35, 0x2E8, STR_A01E_BUILD_AIRPORT},
|
||||
{ WWT_PANEL, 7, 42, 63, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
||||
{ WWT_PANEL, 7, 64, 85, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -132,52 +114,49 @@ static const WindowDesc _air_toolbar_desc = {
|
||||
BuildAirToolbWndProc
|
||||
};
|
||||
|
||||
void ShowBuildAirToolbar(void)
|
||||
void ShowBuildAirToolbar()
|
||||
{
|
||||
if (_current_player == OWNER_SPECTATOR) return;
|
||||
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
|
||||
AllocateWindowDescFront(&_air_toolbar_desc, 0);
|
||||
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();
|
||||
}
|
||||
|
||||
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
int sel;
|
||||
int rad = 4; // default catchment radious
|
||||
uint32 avail_airports;
|
||||
|
||||
if (WP(w,def_d).close) return;
|
||||
if (WP(w,def_d).close)
|
||||
return;
|
||||
w->disabled_state = 0;
|
||||
|
||||
sel = _selected_airport_type;
|
||||
avail_airports = GetValidAirports();
|
||||
|
||||
if (!HASBIT(avail_airports, 0) && sel == AT_SMALL) sel = AT_LARGE;
|
||||
if (!HASBIT(avail_airports, 1) && sel == AT_LARGE) sel = AT_SMALL;
|
||||
|
||||
/* 'Country Airport' starts at widget 3, and if its bit is set, it is
|
||||
* available, so take its opposite value to set the disabled_state. There
|
||||
* are only 5 available airports, so XOR with 0x1F (1 1111) */
|
||||
w->disabled_state = (avail_airports ^ 0x1F) << 3;
|
||||
|
||||
// FIXME -- BuildAirportPickerWndProc - set availability of airports by year, instead of airplane
|
||||
if (!(_avail_aircraft & 1)) { w->disabled_state |= (1<<3); if (sel == AT_SMALL) sel = AT_LARGE; }
|
||||
if (!(_avail_aircraft & 2)) { w->disabled_state |= (1<<4); if (sel == AT_LARGE) sel = AT_SMALL; }
|
||||
if (!(_avail_aircraft & 4)) { w->disabled_state |= (1<<5); } // heliport
|
||||
// 1980-1-1 is --> 21915
|
||||
// 1990-1-1 is --> 25568
|
||||
if (_date < 21915) {w->disabled_state |= (1<<6);} // metropilitan airport 1980
|
||||
if (_date < 25568) {w->disabled_state |= (1<<7);} // international airport 1990
|
||||
_selected_airport_type = sel;
|
||||
// select default the coverage area to 'Off' (8)
|
||||
w->click_state = ((1<<3) << sel) | ((1<<8) << _station_show_coverage);
|
||||
SetTileSelectSize(_airport_size_x[sel],_airport_size_y[sel]);
|
||||
|
||||
if (_patches.modified_catchment) {
|
||||
switch (sel) {
|
||||
case AT_OILRIG: rad = CA_AIR_OILPAD; break;
|
||||
case AT_HELIPORT: rad = CA_AIR_HELIPORT; break;
|
||||
case AT_SMALL: rad = CA_AIR_SMALL; break;
|
||||
case AT_LARGE: rad = CA_AIR_LARGE; break;
|
||||
case AT_METROPOLITAN: rad = CA_AIR_METRO; break;
|
||||
case AT_INTERNATIONAL: rad = CA_AIR_INTER; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
if (_patches.modified_catchment) {
|
||||
switch (sel) {
|
||||
case AT_OILRIG: rad = CA_AIR_OILPAD; break;
|
||||
case AT_HELIPORT: rad = CA_AIR_HELIPORT; break;
|
||||
case AT_SMALL: rad = CA_AIR_SMALL; break;
|
||||
case AT_LARGE: rad = CA_AIR_LARGE; break;
|
||||
case AT_METROPOLITAN: rad = CA_AIR_METRO; break;
|
||||
case AT_INTERNATIONAL: rad = CA_AIR_INTER; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
// strings such as 'Size' and 'Coverage Area'
|
||||
@@ -188,7 +167,10 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
|
||||
case WE_CLICK: {
|
||||
switch (e->click.widget) {
|
||||
switch(e->click.widget) {
|
||||
case 0:
|
||||
ResetObjectToPlace();
|
||||
break;
|
||||
case 3: case 4: case 5: case 6: case 7:
|
||||
_selected_airport_type = e->click.widget - 3;
|
||||
SndPlayFx(SND_15_BEEP);
|
||||
@@ -210,24 +192,20 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
CheckRedrawStationCoverage(w);
|
||||
} break;
|
||||
|
||||
case WE_DESTROY:
|
||||
if (!WP(w,def_d).close) ResetObjectToPlace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const Widget _build_airport_picker_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 130, 0x0, STR_NULL},
|
||||
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 73, 27, 38, STR_3059_SMALL, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 74, 145, 27, 38, STR_305A_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 145, 63, 74, STR_306B_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 145, 39, 50, STR_305AA_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 145, 51, 62, STR_305AB_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 88, 98, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 88, 98, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 147, 14, 130, 0x0, STR_NULL},
|
||||
{WWT_NODISTXTBTN, 14, 2, 73, 27, 38, STR_3059_SMALL, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, 14, 74, 145, 27, 38, STR_305A_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, 14, 2, 145, 63, 74, STR_306B_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, 14, 2, 145, 39, 50, STR_305AA_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{WWT_NODISTXTBTN, 14, 2, 145, 51, 62, STR_305AB_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
|
||||
{ WWT_CLOSEBOX, 14, 14, 73, 88, 98, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
||||
{ WWT_CLOSEBOX, 14, 74, 133, 88, 98, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -239,12 +217,12 @@ static const WindowDesc _build_airport_desc = {
|
||||
BuildAirportPickerWndProc
|
||||
};
|
||||
|
||||
static void ShowBuildAirportPicker(void)
|
||||
static void ShowBuildAirportPicker()
|
||||
{
|
||||
AllocateWindowDesc(&_build_airport_desc);
|
||||
}
|
||||
|
||||
void InitializeAirportGui(void)
|
||||
void InitializeAirportGui()
|
||||
{
|
||||
_selected_airport_type = AT_SMALL;
|
||||
_last_built_aircraft_depot_tile = 0;
|
||||
|
||||
+6
-23
@@ -1,9 +1,8 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef AIRPORT_MOVEMENT_H
|
||||
#define AIRPORT_MOVEMENT_H
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "macros.h"
|
||||
|
||||
typedef struct AirportMovingData {
|
||||
int x,y;
|
||||
@@ -264,8 +263,7 @@ static const AirportMovingData _airport_moving_data_oilrig[9] = {
|
||||
/////**********Movement Machine on Airports*********************///////
|
||||
// first element of depots array tells us how many depots there are (to know size of array)
|
||||
// this may be changed later when airports are moved to external file
|
||||
static const TileIndexDiffC _airport_depots_country[] = {{3, 0}};
|
||||
static const byte _airport_terminal_country[] = {1, 2};
|
||||
static const TileIndex _airport_depots_country[] = {TILE_XY(3,0)};
|
||||
static const AirportFTAbuildup _airport_fta_country[] = {
|
||||
{ 0,HANGAR,NOTHING_block,1},
|
||||
{ 1,255,AIRPORT_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM1,TERM1_block,2}, {1,TERM2,0,4}, {1,HELITAKEOFF,0,19}, {1,0,0,6},
|
||||
@@ -295,8 +293,7 @@ static const AirportFTAbuildup _airport_fta_country[] = {
|
||||
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
static const TileIndexDiffC _airport_depots_city[] = {{5, 0}};
|
||||
static const byte _airport_terminal_city[] = {1, 3};
|
||||
static const TileIndex _airport_depots_city[] = {TILE_XY(5,0)};
|
||||
static const AirportFTAbuildup _airport_fta_city[] = {
|
||||
{ 0,HANGAR,NOTHING_block,1}, {0,TAKEOFF,OUT_WAY_block,1}, {0,0,0,1},
|
||||
{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
|
||||
@@ -330,8 +327,7 @@ static const AirportFTAbuildup _airport_fta_city[] = {
|
||||
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
static const TileIndexDiffC _airport_depots_metropolitan[] = {{5, 0}};
|
||||
static const byte _airport_terminal_metropolitan[] = {1, 3};
|
||||
static const TileIndex _airport_depots_metropolitan[] = {TILE_XY(5,0)};
|
||||
static const AirportFTAbuildup _airport_fta_metropolitan[] = {
|
||||
{ 0,HANGAR,NOTHING_block,1},
|
||||
{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
|
||||
@@ -367,9 +363,7 @@ static const AirportFTAbuildup _airport_fta_metropolitan[] = {
|
||||
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
static const TileIndexDiffC _airport_depots_international[] = {{0, 3}, {6, 1}};
|
||||
static const byte _airport_terminal_international[] = {2, 3, 3};
|
||||
static const byte _airport_helipad_international[] = {1, 2};
|
||||
static const TileIndex _airport_depots_international[] = {TILE_XY(0,3), TILE_XY(6,1)};
|
||||
static const AirportFTAbuildup _airport_fta_international[] = {
|
||||
{ 0,HANGAR,NOTHING_block,2}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER1_block,1}, {0,HELITAKEOFF,HELIPAD1_block,2}, {0,0,0,2},
|
||||
{ 1,HANGAR,NOTHING_block,3}, {1,255,HANGAR2_AREA_block,1}, {1,HELITAKEOFF,HELIPAD2_block,3}, {1,0,0,3},
|
||||
@@ -432,7 +426,6 @@ static const AirportFTAbuildup _airport_fta_international[] = {
|
||||
};
|
||||
|
||||
// heliports, oilrigs don't have depots
|
||||
static const byte _airport_helipad_heliport_oilrig[] = {1, 1};
|
||||
static const AirportFTAbuildup _airport_fta_heliport_oilrig[] = {
|
||||
{0,HELIPAD1,HELIPAD1_block,1},
|
||||
{1,HELITAKEOFF,NOTHING_block,0}, // takeoff
|
||||
@@ -447,22 +440,12 @@ static const AirportFTAbuildup _airport_fta_heliport_oilrig[] = {
|
||||
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
static const AirportMovingData * const _airport_moving_datas[] = {
|
||||
static const AirportMovingData * const _airport_moving_datas[6] = {
|
||||
_airport_moving_data_country, // Country Airfield (small) 4x3
|
||||
_airport_moving_data_town, // City Airport (large) 6x6
|
||||
_airport_moving_data_heliport, // Heliport
|
||||
_airport_moving_data_metropolitan, // Metropolitain Airport (large) - 2 runways
|
||||
_airport_moving_data_international, // International Airport (xlarge) - 2 runways
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
_airport_moving_data_oilrig // Oilrig
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file has the core function for AyStar
|
||||
* AyStar is a fast pathfinding routine and is used for things like
|
||||
@@ -17,19 +15,17 @@
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "aystar.h"
|
||||
// This looks in the Hash if a node exists in ClosedList
|
||||
// If so, it returns the PathNode, else NULL
|
||||
static PathNode *AyStarMain_ClosedList_IsInList(AyStar *aystar, AyStarNode *node)
|
||||
{
|
||||
PathNode *AyStarMain_ClosedList_IsInList(AyStar *aystar, AyStarNode *node) {
|
||||
return (PathNode*)Hash_Get(&aystar->ClosedListHash, node->tile, node->direction);
|
||||
}
|
||||
|
||||
// This adds a node to the ClosedList
|
||||
// It makes a copy of the data
|
||||
static void AyStarMain_ClosedList_Add(AyStar *aystar, PathNode *node)
|
||||
{
|
||||
void AyStarMain_ClosedList_Add(AyStar *aystar, PathNode *node) {
|
||||
// Add a node to the ClosedList
|
||||
PathNode *new_node = malloc(sizeof(PathNode));
|
||||
*new_node = *node;
|
||||
@@ -38,16 +34,14 @@ static void AyStarMain_ClosedList_Add(AyStar *aystar, PathNode *node)
|
||||
|
||||
// Checks if a node is in the OpenList
|
||||
// If so, it returns the OpenListNode, else NULL
|
||||
static OpenListNode *AyStarMain_OpenList_IsInList(AyStar *aystar, AyStarNode *node)
|
||||
{
|
||||
OpenListNode *AyStarMain_OpenList_IsInList(AyStar *aystar, AyStarNode *node) {
|
||||
return (OpenListNode*)Hash_Get(&aystar->OpenListHash, node->tile, node->direction);
|
||||
}
|
||||
|
||||
// Gets the best node from OpenList
|
||||
// returns the best node, or NULL of none is found
|
||||
// Also it deletes the node from the OpenList
|
||||
static OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar)
|
||||
{
|
||||
OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar) {
|
||||
// Return the item the Queue returns.. the best next OpenList item.
|
||||
OpenListNode* res = (OpenListNode*)aystar->OpenListQueue.pop(&aystar->OpenListQueue);
|
||||
if (res != NULL)
|
||||
@@ -58,8 +52,7 @@ static OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar)
|
||||
|
||||
// Adds a node to the OpenList
|
||||
// It makes a copy of node, and puts the pointer of parent in the struct
|
||||
static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, AyStarNode *node, int f, int g)
|
||||
{
|
||||
void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, AyStarNode *node, int f, int g, int userdata) {
|
||||
// Add a new Node to the OpenList
|
||||
OpenListNode* new_node = malloc(sizeof(OpenListNode));
|
||||
new_node->g = g;
|
||||
@@ -108,7 +101,7 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare
|
||||
|
||||
// Check if this item is already in the OpenList
|
||||
if ((check = AyStarMain_OpenList_IsInList(aystar, current)) != NULL) {
|
||||
uint i;
|
||||
int i;
|
||||
// Yes, check if this g value is lower..
|
||||
if (new_g > check->g) return AYSTAR_DONE;
|
||||
aystar->OpenListQueue.del(&aystar->OpenListQueue, check, 0);
|
||||
@@ -122,7 +115,7 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare
|
||||
aystar->OpenListQueue.push(&aystar->OpenListQueue, check, new_f);
|
||||
} else {
|
||||
// A new node, add him to the OpenList
|
||||
AyStarMain_OpenList_Add(aystar, closedlist_parent, current, new_f, new_g);
|
||||
AyStarMain_OpenList_Add(aystar, closedlist_parent, current, new_f, new_g, 0);
|
||||
}
|
||||
|
||||
return AYSTAR_DONE;
|
||||
@@ -222,7 +215,7 @@ void AyStarMain_Clear(AyStar *aystar) {
|
||||
int AyStarMain_Main(AyStar *aystar) {
|
||||
int r, i = 0;
|
||||
// Loop through the OpenList
|
||||
// Quit if result is no AYSTAR_STILL_BUSY or is more than loops_per_tick
|
||||
// Quit if result is no AYSTAR_STILL_BUSY or is more then loops_per_tick
|
||||
while ((r = aystar->loop(aystar)) == AYSTAR_STILL_BUSY && (aystar->loops_per_tick == 0 || ++i < aystar->loops_per_tick)) { }
|
||||
#ifdef AYSTAR_DEBUG
|
||||
if (r == AYSTAR_FOUND_END_NODE)
|
||||
@@ -250,14 +243,12 @@ int AyStarMain_Main(AyStar *aystar) {
|
||||
* if wanted. You should make sure that clear() is called before adding nodes
|
||||
* if the AyStar has been used before (though the normal main loop calls
|
||||
* clear() automatically when the algorithm finishes
|
||||
* g is the cost for starting with this node.
|
||||
*/
|
||||
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g) {
|
||||
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node) {
|
||||
#ifdef AYSTAR_DEBUG
|
||||
printf("[AyStar] Starting A* Algorithm from node (%d, %d, %d)\n",
|
||||
TileX(start_node->tile), TileY(start_node->tile), start_node->direction);
|
||||
printf("[AyStar] Starting A* Algorithm from node (%d, %d, %d)\n", GET_TILE_X(start_node->tile), GET_TILE_Y(start_node->tile), start_node->direction);
|
||||
#endif
|
||||
AyStarMain_OpenList_Add(aystar, NULL, start_node, 0, g);
|
||||
AyStarMain_OpenList_Add(aystar, NULL, start_node, 0, 0, 0);
|
||||
}
|
||||
|
||||
void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets) {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file has the header for AyStar
|
||||
* AyStar is a fast pathfinding routine and is used for things like
|
||||
@@ -29,7 +27,7 @@ enum{
|
||||
|
||||
typedef struct AyStarNode AyStarNode;
|
||||
struct AyStarNode {
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
uint direction;
|
||||
uint user_data[2];
|
||||
};
|
||||
@@ -58,14 +56,6 @@ typedef struct AyStar AyStar;
|
||||
* AYSTAR_FOUND_END_NODE : indicates this is the end tile
|
||||
* AYSTAR_DONE : indicates this is not the end tile (or direction was wrong)
|
||||
*/
|
||||
/*
|
||||
* The 2nd parameter should be OpenListNode, and NOT AyStarNode. AyStarNode is
|
||||
* part of OpenListNode and so it could be accessed without any problems.
|
||||
* The good part about OpenListNode is, and how AIs use it, that you can
|
||||
* access the parent of the current node, and so check if you, for example
|
||||
* don't try to enter the file tile with a 90-degree curve. So please, leave
|
||||
* this an OpenListNode, it works just fine -- TrueLight
|
||||
*/
|
||||
typedef int32 AyStar_EndNodeCheck(AyStar *aystar, OpenListNode *current);
|
||||
|
||||
/*
|
||||
@@ -99,7 +89,7 @@ typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current);
|
||||
typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
|
||||
|
||||
// For internal use, see aystar.c
|
||||
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode* start_node, uint g);
|
||||
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode* start_node);
|
||||
typedef int AyStar_Main(AyStar *aystar);
|
||||
typedef int AyStar_Loop(AyStar *aystar);
|
||||
typedef int AyStar_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
||||
@@ -163,7 +153,7 @@ struct AyStar {
|
||||
};
|
||||
|
||||
|
||||
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
|
||||
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node);
|
||||
int AyStarMain_Main(AyStar *aystar);
|
||||
int AyStarMain_Loop(AyStar *aystar);
|
||||
int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
||||
@@ -176,4 +166,4 @@ void AyStarMain_Clear(AyStar *aystar);
|
||||
void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets);
|
||||
|
||||
|
||||
#endif /* AYSTAR_H */
|
||||
#endif
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file bridge.h Header file for bridges */
|
||||
|
||||
#ifndef BRIDGE_H
|
||||
#define BRIDGE_H
|
||||
|
||||
/** Struct containing information about a single bridge type
|
||||
*/
|
||||
typedef struct Bridge {
|
||||
byte avail_year; ///< the year in which the bridge becomes available
|
||||
byte min_length; ///< the minimum length of the bridge (not counting start and end tile)
|
||||
byte max_length; ///< the maximum length of the bridge (not counting start and end tile)
|
||||
uint16 price; ///< the relative price of the bridge
|
||||
uint16 speed; ///< maximum travel speed
|
||||
PalSpriteID sprite; ///< the sprite which is used in the GUI (possibly with a recolor sprite)
|
||||
StringID material; ///< the string that contains the bridge description
|
||||
PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge
|
||||
byte flags; ///< bit 0 set: disable drawing of far pillars.
|
||||
} Bridge;
|
||||
|
||||
extern const Bridge orig_bridge[MAX_BRIDGES];
|
||||
extern Bridge _bridge[MAX_BRIDGES];
|
||||
|
||||
#endif /* BRIDGE_H */
|
||||
+51
-52
@@ -1,11 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file bridge_gui.c Graphical user interface for bridge construction*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
@@ -13,19 +8,23 @@
|
||||
#include "gfx.h"
|
||||
#include "command.h"
|
||||
#include "sound.h"
|
||||
#include "variables.h"
|
||||
#include "bridge.h"
|
||||
|
||||
static struct BridgeData {
|
||||
uint count;
|
||||
int count;
|
||||
TileIndex start_tile;
|
||||
TileIndex end_tile;
|
||||
byte type;
|
||||
byte indexes[MAX_BRIDGES];
|
||||
int32 costs[MAX_BRIDGES];
|
||||
} _bridgedata;
|
||||
} _bridge;
|
||||
|
||||
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
extern const uint16 _bridge_type_price_mod[MAX_BRIDGES];
|
||||
|
||||
extern const PalSpriteID _bridge_sprites[MAX_BRIDGES];
|
||||
extern const uint16 _bridge_speeds[MAX_BRIDGES];
|
||||
extern const StringID _bridge_material[MAX_BRIDGES];
|
||||
|
||||
void CcBuildBridge(bool success, uint tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
|
||||
}
|
||||
@@ -33,8 +32,7 @@ void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
static void BuildBridge(Window *w, int i)
|
||||
{
|
||||
DeleteWindow(w);
|
||||
DoCommandP(_bridgedata.end_tile, _bridgedata.start_tile,
|
||||
_bridgedata.indexes[i] | (_bridgedata.type << 8), CcBuildBridge,
|
||||
DoCommandP(_bridge.end_tile, _bridge.start_tile, _bridge.indexes[i] | (_bridge.type << 8), CcBuildBridge,
|
||||
CMD_BUILD_BRIDGE | CMD_AUTO | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
|
||||
}
|
||||
|
||||
@@ -42,25 +40,25 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
uint i;
|
||||
int i;
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
for (i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) {
|
||||
const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]];
|
||||
for(i=0; i < 4 && i + w->vscroll.pos < _bridge.count; i++) {
|
||||
int ind = _bridge.indexes[i + w->vscroll.pos];
|
||||
|
||||
SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
|
||||
SetDParam(1, (b->speed >> 4) * 10);
|
||||
SetDParam(0, b->material);
|
||||
DrawSprite(b->sprite, 3, 15 + i * 22);
|
||||
SetDParam(2, _bridge.costs[i + w->vscroll.pos]);
|
||||
SetDParam(1, (_bridge_speeds[ind] >> 4) * 10);
|
||||
SetDParam(0, _bridge_material[ind]);
|
||||
DrawSprite(_bridge_sprites[ind], 3, 15 + i * 22);
|
||||
|
||||
DrawString(44, 15 + i * 22 , STR_500D, 0);
|
||||
DrawString(44, 15 + i*22 , STR_500D, 0);
|
||||
}
|
||||
} break;
|
||||
|
||||
case WE_KEYPRESS: {
|
||||
uint i = e->keypress.keycode - '1';
|
||||
if (i < 9 && i < _bridgedata.count) {
|
||||
if (i < 9 && i < (uint)_bridge.count) {
|
||||
e->keypress.cont = false;
|
||||
BuildBridge(w, i);
|
||||
}
|
||||
@@ -69,9 +67,9 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
|
||||
case WE_CLICK:
|
||||
if (e->click.widget == 2) {
|
||||
if (e->click.widget == 2) {
|
||||
uint ind = ((int)e->click.pt.y - 14) / 22;
|
||||
if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count)
|
||||
if (ind < 4 && (ind += w->vscroll.pos) < (uint)_bridge.count)
|
||||
BuildBridge(w, ind);
|
||||
}
|
||||
break;
|
||||
@@ -79,10 +77,10 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
|
||||
static const Widget _build_bridge_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
|
||||
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_MATRIX, 7, 0, 188, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
|
||||
{ WWT_SCROLLBAR, 7, 189, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -96,10 +94,10 @@ static const WindowDesc _build_bridge_desc = {
|
||||
|
||||
|
||||
static const Widget _build_road_bridge_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
|
||||
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_MATRIX, 7, 0, 188, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
|
||||
{ WWT_SCROLLBAR, 7, 189, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -112,56 +110,57 @@ static const WindowDesc _build_road_bridge_desc = {
|
||||
};
|
||||
|
||||
|
||||
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
|
||||
void ShowBuildBridgeWindow(uint start, uint end, byte bridge_type)
|
||||
{
|
||||
uint j = 0;
|
||||
int j = 0;
|
||||
int32 ret;
|
||||
StringID errmsg;
|
||||
uint16 errmsg;
|
||||
|
||||
DeleteWindowById(WC_BUILD_BRIDGE, 0);
|
||||
|
||||
_bridgedata.type = bridge_type;
|
||||
_bridgedata.start_tile = start;
|
||||
_bridgedata.end_tile = end;
|
||||
_bridge.type = bridge_type;
|
||||
_bridge.start_tile = start;
|
||||
_bridge.end_tile = end;
|
||||
|
||||
errmsg = INVALID_STRING_ID;
|
||||
errmsg = 0xFFFF;
|
||||
|
||||
// only query bridge building possibility once, result is the same for all bridges!
|
||||
// returns CMD_ERROR on failure, and price on success
|
||||
// returns CMD_ERROR on failure, and priCe on success
|
||||
ret = DoCommandByTile(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
|
||||
|
||||
if (CmdFailed(ret)) {
|
||||
if (ret == CMD_ERROR) {
|
||||
errmsg = _error_message;
|
||||
} else {
|
||||
// check which bridges can be built
|
||||
}
|
||||
// check which bridges can be built
|
||||
else {
|
||||
int bridge_len; // length of the middle parts of the bridge
|
||||
int tot_bridgedata_len; // total length of bridge
|
||||
int tot_bridge_len; // total length of bridge
|
||||
|
||||
// get absolute bridge length
|
||||
bridge_len = GetBridgeLength(start, end);
|
||||
tot_bridgedata_len = bridge_len + 2;
|
||||
tot_bridge_len = bridge_len + 2;
|
||||
|
||||
tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len);
|
||||
tot_bridge_len = CalcBridgeLenCostFactor(tot_bridge_len);
|
||||
|
||||
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { // loop for all bridgetypes
|
||||
|
||||
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
|
||||
const Bridge *b = &_bridge[bridge_type];
|
||||
// bridge is accepted, add to list
|
||||
// add to terraforming & bulldozing costs the cost of the bridge itself (not computed with DC_QUERY_COST)
|
||||
_bridgedata.costs[j] = ret + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8);
|
||||
_bridgedata.indexes[j] = bridge_type;
|
||||
_bridge.costs[j] = ret + (((int64)tot_bridge_len * _price.build_bridge * _bridge_type_price_mod[bridge_type]) >> 8);
|
||||
_bridge.indexes[j] = bridge_type;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_bridgedata.count = j;
|
||||
_bridge.count = j;
|
||||
|
||||
if (j != 0) {
|
||||
Window *w = AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
|
||||
Window *w = AllocateWindowDesc((_bridge.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
|
||||
w->vscroll.cap = 4;
|
||||
w->vscroll.count = (byte)j;
|
||||
} else {
|
||||
ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * 16, TileY(end) * 16);
|
||||
ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, GET_TILE_X(end) * 16, GET_TILE_Y(end) * 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef BRIDGE_MAP_H
|
||||
#define BRIDGE_MAP_H
|
||||
|
||||
#include "direction.h"
|
||||
#include "macros.h"
|
||||
#include "map.h"
|
||||
#include "rail.h"
|
||||
#include "tile.h"
|
||||
|
||||
|
||||
static inline bool IsBridge(TileIndex t)
|
||||
{
|
||||
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
||||
return HASBIT(_m[t].m5, 7);
|
||||
}
|
||||
|
||||
static inline bool IsBridgeTile(TileIndex t)
|
||||
{
|
||||
return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
|
||||
}
|
||||
|
||||
|
||||
static inline bool IsBridgeRamp(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeTile(t));
|
||||
return !HASBIT(_m[t].m5, 6);
|
||||
}
|
||||
|
||||
static inline bool IsBridgeMiddle(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeTile(t));
|
||||
return HASBIT(_m[t].m5, 6);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the direction pointing onto the bridge
|
||||
*/
|
||||
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeRamp(t));
|
||||
/* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of
|
||||
* bridges to a DiagDirection
|
||||
*/
|
||||
return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4);
|
||||
}
|
||||
|
||||
|
||||
static inline Axis GetBridgeAxis(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeMiddle(t));
|
||||
return (Axis)GB(_m[t].m5, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
static inline bool IsTransportUnderBridge(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeMiddle(t));
|
||||
return HASBIT(_m[t].m5, 5);
|
||||
}
|
||||
|
||||
#endif
|
||||
+4
-17
@@ -1,8 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "callback_table.h"
|
||||
#include "ttd.h"
|
||||
#include "functions.h"
|
||||
|
||||
// If you add a callback for DoCommandP, also add the callback in here
|
||||
@@ -11,7 +8,6 @@
|
||||
|
||||
/* aircraft_gui.c */
|
||||
CommandCallback CcBuildAircraft;
|
||||
CommandCallback CcCloneAircraft;
|
||||
|
||||
/* airport_gui.c */
|
||||
CommandCallback CcBuildAirport;
|
||||
@@ -27,6 +23,7 @@ CommandCallback CcBuildCanal;
|
||||
CommandCallback CcPlaySound10;
|
||||
CommandCallback CcPlaceSign;
|
||||
CommandCallback CcTerraform;
|
||||
//CommandCallback CcDemolish;
|
||||
CommandCallback CcBuildTown;
|
||||
|
||||
/* rail_gui.c */
|
||||
@@ -42,18 +39,13 @@ CommandCallback CcRoadDepot;
|
||||
|
||||
/* roadveh_gui.c */
|
||||
CommandCallback CcBuildRoadVeh;
|
||||
CommandCallback CcCloneRoadVeh;
|
||||
|
||||
/* ship_gui.c */
|
||||
CommandCallback CcBuildShip;
|
||||
CommandCallback CcCloneShip;
|
||||
|
||||
/* train_gui.c */
|
||||
CommandCallback CcBuildWagon;
|
||||
CommandCallback CcBuildLoco;
|
||||
CommandCallback CcCloneTrain;
|
||||
|
||||
CommandCallback CcAI;
|
||||
|
||||
CommandCallback *_callback_table[] = {
|
||||
/* 0x00 */ NULL,
|
||||
@@ -76,12 +68,7 @@ CommandCallback *_callback_table[] = {
|
||||
/* 0x11 */ CcPlaySound1D,
|
||||
/* 0x12 */ CcPlaySound1E,
|
||||
/* 0x13 */ CcStation,
|
||||
/* 0x14 */ CcTerraform,
|
||||
/* 0x15 */ CcCloneAircraft,
|
||||
/* 0x16 */ CcCloneRoadVeh,
|
||||
/* 0x17 */ CcCloneShip,
|
||||
/* 0x18 */ CcCloneTrain,
|
||||
/* 0x19 */ CcAI
|
||||
/* 0x14 */ CcTerraform
|
||||
};
|
||||
|
||||
const int _callback_table_count = lengthof(_callback_table);
|
||||
const int _callback_table_count = sizeof (_callback_table) / sizeof (*_callback_table);
|
||||
|
||||
+1
-5
@@ -1,11 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef CALLBACK_TABLE_H
|
||||
#define CALLBACK_TABLE_H
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
extern CommandCallback *_callback_table[];
|
||||
extern const int _callback_table_count;
|
||||
|
||||
#endif /* CALLBACK_TABLE_H */
|
||||
#endif
|
||||
|
||||
-512
@@ -1,515 +1,3 @@
|
||||
0.4.8 (2006-08-12)
|
||||
------------------------------------------------------------------------
|
||||
- Fix: A ship in a depot must be stopped before it can be cloned.
|
||||
- Fix: After changing directory in 'Play Scenario', the default scenarios didn't show up in 'New Game'
|
||||
0.4.8-RC2 (2006-07-31)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: Add Italian town names as we have an official Italian translation
|
||||
- Codechange: Verify the presence of music files in the gm/ folder. This should also solve some 100% CPU buildup for some users.
|
||||
- Fix: Certain combinations of trains crash when moved around inside the depot.
|
||||
- Fix: Reversed arrow-sign in the multiplayer list column headers on sort by name
|
||||
- Fix: Industry production change button doesn't work for oilrig passangers.
|
||||
- Fix: Helicopters stopping in depot after autorenew/autoreplace
|
||||
- Fix: MorphOS crashes when you go a level up in the root level
|
||||
- Fix: UDP sockets were used even if network-availability was set to false
|
||||
- Fix: Crash when trying to build a vehicle type that is set to a max of zero
|
||||
|
||||
0.4.8-RC1 (2006-06-28)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: Add Turkish town names as we have an official Turkish translation
|
||||
- Feature: Add a fully optional configure script that is a wrapper around the cumbersome makefile.config
|
||||
- Codechange: [NPF] Disable NPF totally for ships as it wholly kills performance (blathijs). Only for 0.4/ branch and 0.4.8.
|
||||
- Fix: Redraw the screen when switching the signal side in the patches window
|
||||
- Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
|
||||
- Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
|
||||
- Fix: Fix several glitches concerning foundations. Houses, property (rail/road/bridge/etc.) and cursor are now aligned properly
|
||||
- Fix: Prohibit altering a road tile while road works are in progress. This fixes some glitches like "turning" the excavation by adding/removing road bits or removing the road piece
|
||||
- Fix: Only advertise the server to your external IP/network (eg not to 127.0.0.1) and use proper broadcast addresses
|
||||
- Fix: '-f' switch is not valid on windows, so don't show it in help
|
||||
- Fix: [autoreplace] Autoreplaced trains can leave all wagons in depot under certain circumstances
|
||||
- Fix: The wrong IP could get unbanned, e.g. 'unban 1.2.3.42' could result in unbanning 1.2.3.4
|
||||
- Fix: It was possible to convert the railtype of a bridge while a train was on it
|
||||
- Fix: It was possible to rename signs or waypoints with the chat box
|
||||
- Fix: Be more strict what it means for an aircraft to be in a hangar: It's not just being stopped on a hangar tile
|
||||
- Fix: If a road vehicle is on a road depot tile and stopped doesn't mean it's in the depot. Use the proper test for this
|
||||
- Fix: [AI] The AI should send a plane into a hangar if it's not in a hangar _or_ not stopped, not when it's not in a hangar _and_ not stopped
|
||||
- Fix: [AI] The trolly AI used information from the wrong industry when calculating the amount of to be transported goods
|
||||
- Fix: [NTP] Fix NTP over bridges: don't check the rail type when on a bridge
|
||||
- Fix: Truncate text in dropdown lists to stop text overflowing.
|
||||
- Fix: "Erroneous train reversal on waypoints". When processing the next train order, do not even consider reversing the train if the last order was to a waypoint.
|
||||
- Fix: Starting a new scenario did not adhere to local difficulty settings but took it from the scenario itself. That mode is for 'play scenario'
|
||||
- Fix: Vehicles on a sloped tile under a bridge were affected by the bridge speed limit
|
||||
- Fix: Issue with train pathfinding over level crossings.
|
||||
- Fix: [AI] The AI no longer attempts to build signals under bridges.
|
||||
- Fix: Refresh build vehicle window (if opened) when converting rail depot
|
||||
- Fix: Crash when sorting an empty server list.
|
||||
- Fix: The build-tree window button defaulted to a place-push-button on opening where no treetype is selected.
|
||||
- Fix: Game crashes when cloning/autoreplace reaches train-limit
|
||||
- Fix: [NTP] properly check for railtypes on non-plain-rail-tiles
|
||||
- Fix: Trains could enter certain sloped rail tiles under bridges with incompatible rail type
|
||||
- Fix: Ensure the map memory is cleared after it is allocated. This fixes random deserts that sometimes occurred.
|
||||
- Fix: Some weird behaviour with tile selection near bridges
|
||||
- Fix: Don't allow PF to enter train depot from the back (signal updates)
|
||||
- Fix: Game no longer crashes when the last vehicle servicing a station has been deleted
|
||||
- Fix: Reset the last built railtype when starting a new game
|
||||
- Fix: Cloned vehicles get the same service interval as the original vehicle
|
||||
- Fix: Game no longer errors out when "Many random towns" is selected in the scenario editor.
|
||||
- Fix: Obscure road dragging bug. The road build command did not return the appropiate error message of invalid-slope when building road.
|
||||
- Fix: Temperate bank will no longer appear (during game) in tropic landscape. This bug is from the original game.
|
||||
- Fix: Specify the 'stopall' console command as a debug command.
|
||||
- Fix: Fixed a problem that caused DeliverGoodsToIndustry to not work as intended
|
||||
- Fix: Ships and aircraft can now be used as feeders as well
|
||||
- Fix: When a multiheaded train is sold the pointers were not updated correctly causing sporadious crashes/disconnects.
|
||||
- Fix: New plantations now cause the correct ".. being planted .." news item
|
||||
- Fix: Danish town names were saved/loaded as Swiss
|
||||
- Fix: Removing roads on crossings was done without a check for ownership
|
||||
- Fix: [autoreplace] Fix drawing of train list for outdated engines
|
||||
- Fix: Malicious clients/servers could crash the game
|
||||
- Fix: [autoreplace] allow replacement of wagons even when the engine fails to be replaced
|
||||
- Fix: Certain operations involving trains inside a depot could cause a crash
|
||||
- Fix: [autoreplace] cost for refitting a new vehicle is added to the cost animation (player always paid for it, it just wasn't shown)
|
||||
- Fix: [OSX] Save/Load issues solved for OSX 10.3.9 universal binaries
|
||||
- Fix: Illegal servers in the master-server list could kick the client back to the main menu, effectively making Multiplayer impossible
|
||||
- Fix: [NPF] Don't mark tiles when debugging in multiplayer, this will cause desyncs
|
||||
- Fix: Several fixes to chatbox code, mainly plug a buffer overflow
|
||||
|
||||
0.4.7 (2006-03-26)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
- Feature: [OSX] Add support for triple-binaries (PPC, PPC970, i386) (r4102)
|
||||
- Fix: [OSX] crash when going to fullscreen (r4100)
|
||||
- Fix: Allow unused wagons to have their first cache set. Fixes faulty cache-warning message and noticably speeds up depot operations (r4094)
|
||||
- Fix: [NPF] Trains & busses were unable to find a route when leaving a depot or bus stop. (r4072)
|
||||
|
||||
0.4.6 (2006-03-22)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
- Codechange: [win32] Show the revision in crash.txt and enable the button to show the crash text in the crash-window (r3965)
|
||||
- Codechange: Add additional linker information to release builds to help figure out crashes more easily (r3526)
|
||||
- Fix: [OSX 10.3 and newer] [ 1157244 ] Can't save game if name contains german umlauts (loading savegames with certain chars still look odd) (r4038)
|
||||
- Fix: [OSX] major speedup for PPC fullscreen (r4034)
|
||||
- Fix: [Makefile] Make sure the ICON_DIR gets created before copying files there. (r4032)
|
||||
- Fix: [win32] Change compiler settings to use the multithreaded CRT. This prevents certain crashes on multi-threaded machines. (r4031)
|
||||
- Fix: [ 1453646 NPF ] Road vehicles planning through the back of depots and stations. (r4029)
|
||||
- Fix: Use the title of a savegame in the saveload dialog-editbox. (r4018)
|
||||
- Fix: Improper resolution written to the configuration file when exiting from fullscreen. (r4017)
|
||||
- Fix: When removing rail track from a tile where only X and Y pieces exist, explicitly update signals in both directions. (r4016)
|
||||
- Fix: Default the patch-setting 'pause_on_join' to true. (r4015)
|
||||
- Fix: Slope and height information returned for some tile types is wrong (r4014)
|
||||
- Fix: Fixes a bug introduced by r3228 which allowed steep rail tiles resulting in ... unwanted effects such as display artifacts. (r4012)
|
||||
- Fix: Update french translation (r3978)
|
||||
- Fix: FS#56 - [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font. (r3970)
|
||||
- Fix: [ 1439907 ] Increase client list window width so at least most languages fit. (r3969)
|
||||
- Fix: Update german and finnish languages. (r3968)
|
||||
- Fix: Properly set back the owner of a crossing/road-under bridge after removing it. (r3967)
|
||||
- Fix: [autoreplace]: (FS#67) autoreplacing trains now keep their tile length instead of their pixel length. (r3964)
|
||||
- Fix: Mark the right tile as dirty. It's just a graphical glitch which happend in r1592. (r3962)
|
||||
- Fix: Fix crash when resizing news history window. (r3961)
|
||||
- Fix: Correctly implement minimum search, so road vehicles head twoards the closest station, not the last one in the list. (r3960)
|
||||
- Fix: [FS#61] The tooltips for raising and lowering land buttons in the scenario editor are interchanged (r3959)
|
||||
- Fix: Correctly restore the roadside after roadworks are finished. (r3957)
|
||||
- Fix: [Multistop] Check the status of the destination road stop instead of a station's first road stop. This only has effect with road vehicle queuing disabled. (r3956)
|
||||
- Fix: validate the setting of max_companies/spectators through the console. (r3955)
|
||||
- Fix: Improve game-load times. (r3954)
|
||||
- Fix: On loading a game, GetPlayerRailtypes() didn't account for the fact that vehicles are introduced a year after their introduction date. This will also relieve possible (rare) network desyncs. (r3952)
|
||||
- Fix: Restore plural forms of cargo types for several languages. (r3951)
|
||||
- Fix: [win32] Add directives to allow Visual Studio 2005 compilation. (r3950)
|
||||
- Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (r3948)
|
||||
|
||||
0.4.5 (2006-01-31)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
- Feature: [newgrf] Implement varaction2 property 0x41 and 0xDA. (2361)
|
||||
- Feature: giving server_ip a value of 'all' will make the server listen on any interface (2374)
|
||||
- Feature: shortcut CTRL + U that clears the current input-box (2385)
|
||||
- Feature: [newgrf] Implement the mechanism for handling newgrf callbacks (2389)
|
||||
- Feature: [newgrf] Implement the 'refit capacity' callback (2389)
|
||||
- Feature: saving games happen in a seperate thread (2391)
|
||||
- Feature: [newgrf] Implement powered wagons, and the callback that goes with it (2414)
|
||||
- Feature: [newgrf] Implement shorter train vehicles (2428)
|
||||
- Feature: New display option: 'transparent station signs' (2438)
|
||||
- Feature: You can now give transfer order to set up feeder systems (2441)
|
||||
- Feature: Removing tracks with the 'remove' tool, automatically removes signals on the tracks (2469)
|
||||
- Feature: [localisation] Allow changing the order of parameters in translated strings (2573)
|
||||
- Feature: [localisation] New way to specify plural forms (2592)
|
||||
- Feature: [localisation] Support genders (2594)
|
||||
- Feature: [localisation] Support cases (2597)
|
||||
- Feature: add support for truncating strings to a given (pixel) length (2607)
|
||||
- Feature: Overhaul DirectMusic MIDI backend, remove "experimental" status (2712)
|
||||
- Feature: Change the driver probing algorithm: Use the first music/sound/video which succeeds initialising instead of bailing out after the first. No need to specify -snull if no soundcard is present anymore (2728)
|
||||
- Feature: The Main Toolbar Dropdown Menu can now display disabled items (2734)
|
||||
- Feature: Clone vehicles (2764)
|
||||
- Feature: When starting without a config file determine the language on basis of the current locale (2777)
|
||||
- Feature: [NewGRF] Add support for "extended bytes" (2872)
|
||||
- Feature: [localisation] Major step twoards ISO-8859-15: Implement missing characters (2879)
|
||||
- Feature: Implement the console command rm to remove savegames (2941)
|
||||
- Feature: Danish town names (2957)
|
||||
- Feature: Menu option to toggle console (2958)
|
||||
- Feature: Calculate proportions of non-square giant screenshot correctly (2963)
|
||||
- Feature: [newgrf] Implement current set of action D (ParamSet) operations (2968)
|
||||
- Feature: [newgrf] Show a wagon's speed limit in purchase list (2969)
|
||||
- Feature: [newgrf] Support loading VarAction2 parameter for variables 0x60-0x7F (2971)
|
||||
- Feature: [newgrf] Add patch option for wagon speed limits (2982)
|
||||
- Feature: [newgrf] Support loading of bridge attributes and tables from GRF (3004)
|
||||
- Feature: Native Support for Win64 (3008)
|
||||
- Feature: OSX now uses quicktime to play midi files (3022)
|
||||
- Feature: [OSX] Command+Q now works in main menu (3027)
|
||||
- Feature: Allow unbanning players based on banlist-id (as well as IP) (3067)
|
||||
- Feature: 'status' and 'clients' now show the IP of the players (3067)
|
||||
- Feature: Make it possible to create a screenshot from the console that is both big and has no console, or any combination of (3068)
|
||||
- Feature: [newgrf] Add support for rail vehicle weight greater than 255 tons (3071)
|
||||
- Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (3096)
|
||||
- Feature: Turkish translation (3120)
|
||||
- Feature: [newgrf] Support positioning of rail vehicle visual effects (3132)
|
||||
- Feature: [newgrf] Support for articulated rail vehicles (3139)
|
||||
- Feature: [newgrf] Add support for cargo refitting specification by cargo classes (3148)
|
||||
- Feature: [newgrf] Action 7/9 new value : is it TTDPatch or OpenTTD? (3152)
|
||||
- Feature: Drag and drop rocky areas in scenario editor (3153)
|
||||
- Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars (3157)
|
||||
- Feature: Right-Click-Scrolling optionally moves in the opposite direction (3222)
|
||||
- Feature: Native cocoa sound and video drivers for OSX (3281)
|
||||
- Feature: [newgrf] Allow train running cost class to differ from engine class (3388)
|
||||
- Feature: Kick and ban now with IP numbers (3407)
|
||||
- Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console (3427)
|
||||
- Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending) (3441)
|
||||
- Feature: Make it possible to ban offline clients (3469)
|
||||
- Fix: The refit window now shows the correct refit options (2365)
|
||||
- Fix: Refitting to a cargo which is already carried by some vehicles takes their capacities into account for display (2365)
|
||||
- Fix: Add 'multihead' TTDPatch option to OpenTTD newgrf flags-emulation (2368)
|
||||
- Fix: make install tried to install scenarios in the (non-existing) personal dir when USE_HOMEDIR is specified (2371)
|
||||
- Fix: [console] update the example scripts in the scripts/ directory to reflect the new console functionality (2372)
|
||||
- Fix: [console] any line starting with a '#' is a comment so ignore it (2372)
|
||||
- Fix: [console] The special variables whose value can only be set by a custom process should, also print out their newly set value there (2372)
|
||||
- Fix: [newgrf] Ignore action 0 prop 0x20 (air drag) (2377)
|
||||
- Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data (2378)
|
||||
- Fix: Build year for mail compartment of planes was not set correctly, affected station ratings (2380)
|
||||
- Fix: Endgame window on easy difficulty resulted in infinite loop (2381)
|
||||
- Fix: Check the airport type when building an airport (2382)
|
||||
- Fix: Monkey-testing turned up some command crashes (2383)
|
||||
- Fix: Check selling land and setting player colour. Also an extra map-bounds check for terraforming (2384)
|
||||
- Fix: [realistic accel] Very slow trains no longer get an increase in maximum speed when part of them is in a depot (2388)
|
||||
- Fix: [newgrf] Load power for dual-headed engines correctly (2400)
|
||||
- Fix: [newgrf] When resolving callbacks, dont ignore wagon overrides (2410)
|
||||
- Fix: Station ratings aren't affected by speed limits from realistic acceleration anymore (2411)
|
||||
- Fix: building vehicles without depot crashed the game (2412)
|
||||
- Fix: certain resolutions caused a crash when minimap was partly dragged outside the game window (2424)
|
||||
- Fix: Deleting canals under bridges removed bridges first in certain configurations (2436)
|
||||
- Fix: [NPF] Vehicles try to drive into a tunnel entrance from above (2471)
|
||||
- Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong) (2474)
|
||||
- Fix: The console variable autoclean_unprotected was linked to the variable _network_autoclean_protected (2498)
|
||||
- Fix: Old bug in the PCX writer: The first pixel column contained garbage, the picture was shifted one to the right, and the last column was dropped (2512)
|
||||
- Fix: Using the mouse wheel could lead to a crash if mouse was not over a widget (2530)
|
||||
- Fix: blinking 'lock' gfx in multiplayer games (2548)
|
||||
- Fix: Remove original train pathfinder. Enhanced old pathfinder. (2553)
|
||||
- Fix: Spaces in the path to the MIDI files caused the win32 MIDI player to fail (2563)
|
||||
- Fix: set server map name to the loaded name of the game/scenario (2610)
|
||||
- Fix: Improve the old pathfinder. Changed it to A* instead of Dijkstra. Benchmark shows that NTP is now around 10x faster than NPF (2635)
|
||||
- Fix: Correctly save and load company_value, it's 64 bits wide, not 32 bits (2684)
|
||||
- Fix: Volume control works now for the DirectMusic MIDI backend (2712)
|
||||
- Fix: Change the fence algorithm so it removes fences when no farm tile is adjacent (2739)
|
||||
- Fix: Tree tiles above the snow line got redrawn disproportionately often (2750)
|
||||
- Fix: Depots could build trains of the wrong track type (2764)
|
||||
- Fix: Sort the directories in the scenarion/savegame list (2860)
|
||||
- Fix: On OS/2 show the trailing \ if the current directory is a root directory (2860)
|
||||
- Fix: Return a proper version number, when testing the TTDPatch version in the SkipIf action (2862)
|
||||
- Fix: Change the way NewGRFs are loaded, this saves quite some sprite slots - about 2000 for DBSetXL for example (2868)
|
||||
- Fix: Several format string vulnerabilities and buffer overflows in the network code (2899)
|
||||
- Fix: fixed issue where autorenewed vehicles didn't get all stats updated (2912)
|
||||
- Fix: Exit the child of the extmidi backend with _exit() instead of exit(), because we don't want any atexit handlers - especially flushing output streams - to run, if exec() fails (2938)
|
||||
- Fix: Server crash with "say"-command (2950)
|
||||
- Fix: Fix win32 midi volume level control which didn't work (2960)
|
||||
- Fix: [OSX] quitting the game no longer leaves a process behind that eats all the CPU power (3281)
|
||||
- Fix: Fix for [ 1216203 ] UFO-broken waypoint (2961)
|
||||
- Fix: [newgrf] Include missing grf feature canal
|
||||
- Fix: [newgrf] Add bounds checking to VehicleChangeInfo for vehicles
|
||||
- Fix: [newgrf] Wagon speed limits don't apply for wagons with livery overrides
|
||||
- Fix: Align settings pool items to the size of void* to fix bus errors on 64bit architectures which require aligned variables (2976)
|
||||
- Fix: restart_game_date is an UINT16, not a BYTE. Now setting the game restart year via the console should work (2987)
|
||||
- Fix: [newgrf] Some GRF files don't specify a name or description, in which case the Action 8 is 8 bytes, not 9 (3005)
|
||||
- Fix: The finnish markka was never abbreviated with capital letters (3021)
|
||||
- Fix: Improve handling of non-existent sprite sets (3044)
|
||||
- Fix: Don't attempt to map and empty sprite group to a vehicle (3045)
|
||||
- Fix: Fixed typo and hang for BeOS Networking (3053)
|
||||
- Fix: On Win98 and lower when you go to the root directory of a drive (eg. C:\) you were stuck there indefinitely and couldn't change any directories or see any files (3056)
|
||||
- Fix: Complete rewrite of autoreplace; multiheaded train engines are replaced correctly (3081)
|
||||
- Fix: A new train is now made if the front unit is an engine and the former front engine is moved away (3144)
|
||||
- Fix: There are only 2 possible directions for ship depots, not 4 (3199)
|
||||
- Fix: Allow bribing up to the maximum rating for bribing, don't disable this option at some arbitrary value early (3201)
|
||||
- Fix: Don't lower land on tunnel, even with diag tracks on it (3228)
|
||||
- Fix: Crash when making a screenshotin the main menu (3235)
|
||||
- Fix: Crash when starting a scenarion via 'New Game' fails (3235)
|
||||
- Fix: Determine clicked status of sticky icon from window flags rather than the widget click state (3247)
|
||||
- Fix: Graphical glitch with autorail tool on a certain tile-types (3254)
|
||||
- Fix: Center the X of the window close button (3302)
|
||||
- Fix: [newgrf] Unload engine names before loading grf files (3316)
|
||||
- Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received (3322)
|
||||
- Fix: Build failed if SDL is built without pthread support (3326)
|
||||
- Fix: Move initialization of vehicle random_bits to DC_EXEC blocks to allow use of Random() instead of InteractiveRandom(), which will alleviate some possib le network desyncs (3352)
|
||||
- Fix: The default AI tried to change the service intervals of vehicles via the CMD_CHANGE_TRAIN_SERVICE_INT command - regardless of the type of the vehicle (3367)
|
||||
- Fix: Out-of-bounds array access when road vehicles overtook in a curve caused desyncs (3371)
|
||||
- Fix: Update signal states when building or removing rail station blocks (3372)
|
||||
- Fix: Don't allow trains to get bigger than 100 via drag and drop (3374)
|
||||
- Fix: Don't reset date in the scenario editor when pressing RandomLand (3376)
|
||||
- Fix: [newgrf] Running cost should be halved for dual head vehicles (3384)
|
||||
- Fix: No fence was placed when placing fences and the neighbouring tile is a rail configuration which permits a fence but has a signal (3389)
|
||||
- Fix: [newgrf] Ignore non-climate dependent cargo types (3394)
|
||||
- Fix: [newgrf] Only add a random number of days to an engine's base introduction date if that date is not 0 (3410)
|
||||
- Fix: When changing the server password via the console, actually set the password as well as flag whether it is required (3411)
|
||||
- Fix: Under certain conditions placing a road tile parallel under a bridge would, instead of failing, succeed and place a perpendicular piece (3413)
|
||||
- Fix: Disable the Fund New Industry menu item and window when connected to a server as a spectator (3414)
|
||||
- Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator (3415)
|
||||
- Fix: Disallow building an oil rig above sea level (3416)
|
||||
- Fix: When removing a town-owned tunnel the player's rating was not reduced (3418)
|
||||
- Fix: (Possible) game crash on removing track/road under bridge if a vehicle was on the track/road under the bridge and the track/road sloped (3419)
|
||||
- Fix: [newgrf] Only power should decide whether a rail vehicle is an engine or a wagon. (fixes SHIKI 810 in jpsetw.grf) (3424)
|
||||
- Fix: Incorrect validating of tree-planting command which can allow a buffer-overflow (3446)
|
||||
- Fix: [newgrf] When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf) (3449)
|
||||
- Fix: You couldn't remove an item from a list-type of config ingame from the configuration file (3475)
|
||||
- Fix: [newgrf] Always reinitialize the ttdpatch flags as patch settings may have changed (3486)
|
||||
- Fix: Price for demolishing a bridge was dependent on orientation and map size (3487)
|
||||
|
||||
|
||||
0.4.0.1 (2005-05-21)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
- Feature: Add 'clear' command and CTRL+L to empty console window
|
||||
- Feature: add the possibility to print out the current debug-level
|
||||
- Fix: [MacOSX] default path for midi player on mac is now correct again
|
||||
- Fix: Updated makefile for FreeBSD
|
||||
- Fix: Text overflows in about box
|
||||
- Fix: Link error while compiling as dedicated server
|
||||
- Fix: Do not execute empty commands
|
||||
- Fix: Make OpenTTD icon look good on Win2K and earlier
|
||||
- Fix: NetworkUDPRemoveAdvertise wasn't completely correct
|
||||
- Fix: Signs in multiplayer didn't work
|
||||
- Fix: Dedicated server desyncs
|
||||
- Fix: [ 1197216 ] Error: !invalid string id 0 in GetString, dedicated server endgame crash
|
||||
- Fix: Don't allow things to be renamed to nothing
|
||||
- Fix: Windows installer deletes spritecache files on uninstall
|
||||
- Fix: Depot window did not get redrawn when a non-train-engine was sold
|
||||
- Fix: Do not scroll the game with the arrow keys when the chatbox is open
|
||||
- Fix: Remove warning from release build when assertions are no longer active
|
||||
- Fix: It was possible to open more than one tree window
|
||||
|
||||
|
||||
0.4.0 (2005-05-15)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: Bigger maps. Enjoy playing up to 2028x2048 (64 times as big as you were used to!)
|
||||
- Feature: New realistic acceleration; should be much better. Inlcudes gigger penalty on narrow curves and speedlimits in depots/stations
|
||||
- Feature: It is now possible to build multiple road stations (up to 8) on a single station (multibus).
|
||||
- Feature: New PathFinder (NPF). Support for train/road and ship based on A*. No more braindead pathfinding
|
||||
- Feature: Dynamic towns/industries/stations/vehicles/signs/orders/everything, up to 64K
|
||||
- Feature: Brand new OldLoader so OpenTTD is TTD(Patch) compatible again. Also endian safe
|
||||
- Feature: Even better newgrf support, except for callbacks, everything works (ok, almost)
|
||||
- Feature: Improved multiplayer. More console options, less desyncs and more fun
|
||||
- Feature: Protected OpenTTD from interference of hacked clients, so it should be safe to play again.
|
||||
- Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type
|
||||
- Feature: [ 1107690 ] Resizable orders GUI
|
||||
- Feature: [ 1166978 ] Focus keyboard on input-box in Multiplayer Menu
|
||||
- Feature: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
|
||||
- Feature: Complete rework of console and new commands like ls, save, load, help, etc.
|
||||
- Feature: Signs are shown in the colour of the player who created them
|
||||
- Feature: Add cheat option to set production of raw-material industries in game
|
||||
- Feature: Replace trian GUI remembers railtype selected from the dropdown menu
|
||||
- Feature: Improved Autoreplace
|
||||
- Feature: many more smaller features :D
|
||||
- Fix: [ 1108618 ] A wrong error message was displayed when trying to
|
||||
- Fix: [ 1110407 ] Game does not crash any more when a newgrf file doesn't exist
|
||||
- Fix: [ 1112469 ] Clearing land for free by reallocating HQ
|
||||
- Fix: [ 1112469 ] Clearing land for free by reallocating HQ
|
||||
- Fix: [ 1113037 ] crash when accessing hi-scores in editor, it is now disabled.
|
||||
- Fix: [ 1113399 ] Game no longer crashes when right-clicking a disabled Full Load button
|
||||
- Fix: [ 1114100 ] Dedicated server boots again
|
||||
- Fix: [ 1114950 ] Game crashed sometimes when there were no industries in the map
|
||||
- Fix: [ 1115200 ] In the main menu, when starting a new game while the load game dialog is open, openttd asserts.
|
||||
- Fix: [ 1117538 ] non-stop orders are no longer accidently skipped
|
||||
- Fix: [ 1116619 ] Generate the correct smoke type for diesel trains
|
||||
- Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
|
||||
- Fix: [ 1109400 ] Better test if a string actually contains any console command
|
||||
- Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
|
||||
- Fix: [ 1143587 ] carriages of newgrfs can be refitted again
|
||||
- Fix: [ 1117730 ] Production values of temperate-climate banks can now be altered
|
||||
- Fix: [ 1118810 ] openttd: ship_cmd.c:642 ... Assertion failed. Mapwrap fixed in ship_cmd.c (was implicitely ok before biggermaps).
|
||||
- Fix: [ 1117327 ] Assertion error on kick. When a company is cleaned all its windows need to be closed. For global vehicle lists, the no-staiton index of -1 was not taken into account
|
||||
- Fix: [ 1114261 ] Speeding up when pressing ALT+TAB (Windows)
|
||||
- Fix: [ 1149403 ] Signals dissaper after typing text and pressing enter!. Signs in Scenario Editor have no owner so ignore that.
|
||||
- Fix: [ 1149766 ] Single tile Bridge in Volcano City scenario. Some bridges still had the old single-tile bridge bug that was caused by improper town growth in combination with DC_AUTO. Fixed the scenario.
|
||||
- Fix: [ 1119147 ] Stop startup memory corruption crash using optimized MSVC6. MSVC6 workaround as it's too stupid again for its own good
|
||||
- Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
|
||||
- Fix: [ 1155696 ] Crash with german umlauts in station names.
|
||||
- Fix: [ 1158618 ] Segmentation fault when loading savegame, out of bounds array check.
|
||||
- Fix: [ 1149487 ] Autosave ignoring settings
|
||||
- Fix: [ 1024703 ] Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines.
|
||||
- Fix: [ 1095110 ] Create Lake and draggable Create Desert tools
|
||||
- Fix: [ 1172878 ] Trains "Go to depot" button: click twice skip to next order
|
||||
- Fix: [ 1146215 ] Engine power not updated w/auto replace" autoreplace now forces an update of the cache.
|
||||
- Fix: [ 1173690 ] Path displaying as "C:\\" in saveload window win32-only
|
||||
- Fix: [ 1179892 ] click & drag removal of road assertion fail.
|
||||
- Fix: [ 1174237 ] Max loan always in euros, use _opt_ptr instead of _opt
|
||||
- Fix: [ 1184201 ] AI orders its vehicles to a competitor's truck stop.
|
||||
- Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
|
||||
- Fix: [ 1188777 ] Non-existing sprite #5125 (presignal). The DOS grf file trgi.grf has 6 less sprites than the windows one.
|
||||
- Fix: [ 1190625 ] Changing mapsize crashes game with highlighting.
|
||||
- Fix: [ 1190896 1184378 ] [NPF] Trains ignoring their railtype (mono, maglev)
|
||||
- Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer().
|
||||
- Fix: [ 1187613 ] No HQ present for competitor, disable 'View HQ' button
|
||||
- Fix: [ 1193048 ] Pre-signal stays red when there is only a single exit signal
|
||||
- Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code
|
||||
- Fix: [newgrf] rotors of custom helicopters are displayed correctly in the hangar window
|
||||
- Fix: Scenario Editor now handles human-made roads better (try to build a city layout before placing the city, finally that works very nice)
|
||||
- Fix: [Newgrf] helicopters are correctly recognized
|
||||
- Fix: [autoreplace] made sure that planes only show planes in replace GUI and helicopters only show helicopters
|
||||
- Fix: (Work around?) crash when generating tropical maps
|
||||
- Fix: [autoreplace] Cheaters can no longer exploit autoreplace to get vehicles, that's not invented yet
|
||||
- Fix: [autoreplace] Fixed a stupid bug introduced in r1687, that made a crash if anybody tried to autoreplace anything but an aircraft
|
||||
- Fix: expand railroad stations beyond maximum spread
|
||||
- Fix: [autoreplace] fixed a typo that could prevent autoreplaced aircraft from automatically go to a hangar
|
||||
- Fix: Hacked clients can no longer be used to build vehicles that are not available yet
|
||||
- Fix: Minimum profit of vehicles was calculated wrong for Performance Rating
|
||||
- Fix: no longer a station where you only unload is bad for your town-rating
|
||||
- Fix: Crash in scenario-editor with terraforming out-of-map bounds.
|
||||
- Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid.
|
||||
- Fix: Scrolling with the arrow keys is now smooth and it now also scrolls exactly in tile direction if e.g. up and left are pressed
|
||||
- Fix: many more fixes but I am too tired to list them all
|
||||
|
||||
|
||||
0.3.6 (2005-01-24)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: resizable windows. All useful windows are already made resizable.
|
||||
- Feature: highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
|
||||
- Feature: endgame score on 1 jan 2051 where you are added to the highscore if sufficiently large points have been accumulated. Game is paused while
|
||||
- Feature: Visually enhanced autorail placing
|
||||
When using the autorail tool, the rail pieces which are going to be build are highlighted.
|
||||
If a piece is shown in red, this indicates that the slope/rail combination is impossible. It does not tell you if
|
||||
the rail line construction might not be possible because of other obstacles, e.g. houses or water.
|
||||
- Feature: Autoreplace Vehicles (accessible from the vehicle lists)
|
||||
This feature works much like autorenew, but it will get you a new engine type instead of a new one of the same type. Once
|
||||
ordered, it will automatically replace the engines while they visits a depot. The GUI for setting this up have been added on the
|
||||
vehicle overview windows (Bjarni)
|
||||
- Feature: A counter to tell how many engines you have of each type to the autoreplace vehicle windows (Bjarni)
|
||||
- Feature: A display for the total map population to the town display
|
||||
- Feature: [network] RCon (Remote Connection).
|
||||
A server can set: 'set rcon_pw <password>' to enable rcon
|
||||
A client can now do: 'rcon <password> "<command>"'
|
||||
!!Warning!!: do not give your rcon password to people you do not thrust!
|
||||
- Feature: hotkeys for dock and airport toolbar (see http://wiki.openttd.org/index.php/Hotkeys)
|
||||
- Feature: [Network] banning system (mostly tnx to guru3) A server can ban people via ClientList using 'ban', 'unban', 'banlist'.
|
||||
- Feature: [Network] server can now pause and unpause a game through the console. Use 'pause' and 'unpause'
|
||||
- Feature: [OS/2] OS/2 support is now finished (Fixes for networking, file selection, keyboard input, plus many other minor issues)
|
||||
- Feature: [SDL] Show revision number in window title
|
||||
- Feature: [Unix] Check which gcc version is present and only set available compiler flags
|
||||
- Feature: [Windows] CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc.
|
||||
- Feature: [Windows] dedicated server is now functioning correctly
|
||||
- Feature: Addded keyboard shortcuts for the order window
|
||||
- Feature: Aircraft refit options have been restricted to "sane" values.
|
||||
- Feature: allows setting the production values of the rawmaterial producing industries in the editor
|
||||
- Feature: console support for loading maps. Use 'load', 'list_files' and 'goto_dir' to navigate and load games.
|
||||
- Feature: Display server port in the multiplayer game info window
|
||||
- Feature: dynamite in landscaping toolbar (hotkey 'D')
|
||||
- Feature: Improved Network Lobby GUI with a green dot if company income is positive (else red dot) and lock icon if company is password protected
|
||||
- Feature: Make ottd compile on Zeta
|
||||
- Feature: MD5 hash check for TTD files (The original TTD files are now checked with a MD5 sum to determine which version of the grf files is used and to warn about possible file corruptions. Thanks to ledow for the original patch)
|
||||
- Feature: New companies receive a 5-year protection period against buying-up
|
||||
- Feature: norwegian townnames (Simen Graaten)
|
||||
- Feature: Order Checking is only execute for ONE vehicle in an order-share system
|
||||
- Feature: Passengers aircraft now ignore the amount of mail for "full load any" options
|
||||
- Feature: place multiple accepting industies nearby in the editor mode if the appropriate patches are set
|
||||
- Feature: population in label of the town (patch setting)
|
||||
- Feature: scrolling credits list (in alphabetical order)
|
||||
- Feature: Train window now shows the number of vehicles per row (mpetrov)
|
||||
- Feature: [ 1039061 ] Swiss town-names (vulvulune)
|
||||
- Feature: [ 1090950 ] Adding 16:10 resolutions for mainly laptops (doode)
|
||||
- Feature: [ 1098254 ] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
|
||||
- Fix: [ 1031451 ] Catchment area shows when buying sign
|
||||
- Fix: [ 1040119 ] Flood and wagons in depot
|
||||
- Fix: [ 1050990 ] Buying trains sometimes accounted for incorrectly.
|
||||
- Fix: [ 1084074 ] Delayed news messages
|
||||
- Fix: [ 1090495 ] Slopes under high bridges weren't flooded
|
||||
- Fix: [ 1092473 ] In scenario editor, when trees are placed randomly, they are no longer placed on farmland
|
||||
- Fix: [ 1092661 ] On create, the scrollbar of the server-list was not updated
|
||||
- Fix: [ 1092707 ] placing rocks in scenario editor. You can place rocks on trees and vice versa
|
||||
- Fix: [ 1093200 ] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
|
||||
- Fix: [ 1093466 ] no more glitches with many maps in the scenario list when creating server
|
||||
- Fix: [ 1093485 ] Dissappearing rocks in Scenario Editor
|
||||
- Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
|
||||
- Fix: [ 1095020 ] When all stations in an aircraft's order list are demolished, the plane eventually crashes (running out of fuel)
|
||||
- Fix: [ 1095143 ] Servers list now also saves the port
|
||||
- Fix: [ 1098553 ] Crash when all vehicles from a vehicles per station list had been removed
|
||||
- Fix: [ 1099101 ] starting year patch goes out of range. Clamped year between 1920-2090
|
||||
- Fix: [ 1099225 ] Bug Fix - Vehicle Lists not updated at Acqusition (thx tamlin and mpetrov)
|
||||
- Fix: [ 1099451 ] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
|
||||
- Fix: [ 1100736 ] wrong tooltip for place desert button
|
||||
- Fix: [ 1100767 ] fast forward in main menu
|
||||
- Fix: [ 1101179 ] Crash if generating land while industry window is open. This also happened for towns and the land information window
|
||||
- Fix: [ 1101906 ] Configure Patches window text overflow
|
||||
- Fix: [ 1101963 ] console in dedicated server
|
||||
- Fix: [ 1102275 ] Game crashed when clicking "new face" or "company color" twice
|
||||
- Fix: [ 1102776 ], [ 1099535 ] Vehicle lists are now redrawn when a vehicle arrives in a depot. Station-specific vehicle lists are now redrawn daily as well (not only the master list)
|
||||
- Fix: [ 1103113 ] font size changing. Dedicated server did not have code filtering, 'tab' could result in bigger fonts
|
||||
- Fix: [ 1103187 ] Order Check messages are now validated before displayed
|
||||
- Fix: [ 1103301 ] Railroad tracks on slopes weren't flooded
|
||||
- Fix: [ 1104350 ] Crashed trains do not initiate the lost vehicle message anymore
|
||||
- Fix: [ 110452 ] On horizontal/vertical tracks you are also charged for building/removing signals on the parallel track on the same tile.
|
||||
- Fix: [ 1104969 ] Aircraft in hangar messages are now revalidated before display
|
||||
- Fix: [ 1105112 ] Destroyed train locks crossings
|
||||
- Fix: [ 1105281 ] upgrade rail fails when train under bridge
|
||||
- Fix: [ 1105959 ] Trains don't think they're on a slope any more while they drive around in a tunnel
|
||||
- Fix: [ 1105963 ] Buoys can now only be removed if no ship has it in their schedule. (This makes buoys more useable in multiplayer games again, as buoys can't be deleted by other players if they are used.)
|
||||
- Fix: [ 1106354 ] Graph's keys get confused
|
||||
- Fix: [ 1106930 ] placing signals with 2x1 drags is treated as placing a single signal
|
||||
- Fix: [ 1107350 ] console ignoring return character occasionally.
|
||||
- Fix: [ 1108008 ] Scenario creation bug; engines are of correct year when scenario is saved
|
||||
- Fix: [ 1092474 ] little red box in scenario editor
|
||||
- Fix: [ 1099197 ] scrolling through console sometimes crashed the whole game.
|
||||
- Fix: [ 1099209 ] Catchment area with drag&drop stations
|
||||
- Fix: [Network] 'kick 1' did crash dedicated servers
|
||||
- Fix: [Network] A server no longer crashes when a client sends an invalid DoCommand, but drops the client instead.
|
||||
- Fix: [Network] Added packet protection. No longer a client or server
|
||||
- Fix: [Network] Bug in bind system. Advertising failed on systems with more then 1 ip, and server_bind active to one of them.
|
||||
- Fix: [Network] Disabled 'money-cheat' (read: bug which could give people a lot of money)
|
||||
- Fix: [SDL] now the binary never links to SDL if DEDICATED is set.
|
||||
- Fix: [Windows] somehow mousewheel was disabled on windows using SDL; reenabled again
|
||||
- Fix: a modified client could try to replace a vehicle to an invalid engine ID and crash the server.
|
||||
- Fix: autoreplace vehicle lists are now redrawn when a new vehicle becomes available
|
||||
- Fix: Buy Vehicle GUI now shows HPs bigger than 32000 correctly
|
||||
- Fix: Console alias, load_game functionality and load fix
|
||||
- Fix: correct error message for when trying to build a railroad station over a bus/truck/etc-station.
|
||||
- Fix: Correct landscaping buttons in monorail and maglev toolbars
|
||||
- Fix: dedicated server also writes to log file if active
|
||||
- Fix: Desert-landscape does no longer crash
|
||||
- Fix: Expand town is a bit more agressive
|
||||
- Fix: finally zooming in/out always works.
|
||||
- Fix: fixed chat-bug (that from a certain moment, nobody could talk)
|
||||
- Fix: fixed weight for double-head trains and with that the acceleration (now maglev lvl4 can reach their top speed, and are faster than lvl3)
|
||||
- Fix: Full-Loading trains no longer get "lost" after a while (Hackykid)
|
||||
- Fix: Graphs were not updated correctly when one graph with a certain selection was already open and another graph window was opened
|
||||
- Fix: in multiplayer clientlist can only be opened once
|
||||
- Fix: Loan does not count against the company value
|
||||
- Fix: nasty bug where one could build one station OVER the other
|
||||
- Fix: No crash when creating a game with New English town names any more
|
||||
- Fix: now helicopters will use a hangar in schedule to be replaced in, even if they are only set to service there. Since helicopters are serviced at helipads, they will only go there if they needs to be replaced or renewed. They will also use a hangar in an airport in the schedule if needed. (Bjarni)
|
||||
- Fix: only a server can rename a town in a MP game
|
||||
- Fix: really old maps do load again (Darkvater / TrueLight)
|
||||
- Fix: Refit engine button is now disabled when cargo capacity equals zero
|
||||
- Fix: server issue where some company names were wrong
|
||||
- Fix: Ship Vehicle Lists are now redrawn correctly
|
||||
- Fix: signal stays red if a track is removed (Darkvater / Tron / TrueLight)
|
||||
- Fix: solve AI related order-problem
|
||||
- Fix: starting openttd with -g <invalid_name> now acts normal
|
||||
- Fix: The cost for an autorenew was not always send to the right player ;)
|
||||
- Fix: Autorenewing multiheaded train engines now costs the correct amount. Used to be twice the correct price
|
||||
- Fix: the scrollbar in the network gui (server list) now updates when scrolling (HackyKid)
|
||||
- Fix: Train crashes should no longer desync the game.
|
||||
- Fix: When deleting an order, the next pointer was not cleared, resulting in some unusual behavoir from time to time
|
||||
- Fix: You can now also delete automatically found servers by pressing "del"
|
||||
- Fix: You should no longer be able to delete bridges on any type of underground when there is a vehicle on it
|
||||
- Add: A brand new set of icons.
|
||||
- Change: AutoRenew is now a client-side patch instead of a game-side patch
|
||||
- Change: Removed the 'close ALL windows' from the toolbar since shift+del does this.
|
||||
- Language: Updated all languages
|
||||
- Fix: Many more things....
|
||||
|
||||
|
||||
0.3.5 (2004-12-24)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: [Network] New network, very stable, a lot of new features
|
||||
|
||||
+257
-303
@@ -1,17 +1,9 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "player.h"
|
||||
#include "tile.h"
|
||||
#include "viewport.h"
|
||||
#include "command.h"
|
||||
#include "tunnel_map.h"
|
||||
#include "variables.h"
|
||||
#include "table/sprites.h"
|
||||
|
||||
typedef struct TerraformerHeightMod {
|
||||
TileIndex tile;
|
||||
@@ -38,11 +30,13 @@ static int TerraformAllowTileProcess(TerraformerState *ts, TileIndex tile)
|
||||
TileIndex *t;
|
||||
int count;
|
||||
|
||||
if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return -1;
|
||||
if ((GET_TILE_X(tile) == TILE_X_MAX) || (GET_TILE_Y(tile) == TILE_Y_MAX))
|
||||
return -1;
|
||||
|
||||
t = ts->tile_table;
|
||||
for (count = ts->tile_table_count; count != 0; count--, t++) {
|
||||
if (*t == tile) return 0;
|
||||
for(count = ts->tile_table_count; count != 0; count--,t++) {
|
||||
if (*t == tile)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -53,11 +47,12 @@ static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile)
|
||||
TerraformerHeightMod *mod = ts->modheight;
|
||||
int count;
|
||||
|
||||
for (count = ts->modheight_count; count != 0; count--, mod++) {
|
||||
if (mod->tile == tile) return mod->height;
|
||||
for(count = ts->modheight_count; count != 0; count--, mod++) {
|
||||
if (mod->tile == tile)
|
||||
return mod->height;
|
||||
}
|
||||
|
||||
return TileHeight(tile);
|
||||
return _map_type_and_height[tile] & 0xF;
|
||||
}
|
||||
|
||||
static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
|
||||
@@ -67,10 +62,12 @@ static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
|
||||
|
||||
count = ts->tile_table_count;
|
||||
|
||||
if (count >= 625) return;
|
||||
if (count >= 625)
|
||||
return;
|
||||
|
||||
for(t = ts->tile_table; count != 0; count--,t++) {
|
||||
if (*t == tile) return;
|
||||
if (*t == tile)
|
||||
return;
|
||||
}
|
||||
|
||||
ts->tile_table[ts->tile_table_count++] = tile;
|
||||
@@ -78,35 +75,33 @@ static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
|
||||
|
||||
static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile)
|
||||
{
|
||||
TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1));
|
||||
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1));
|
||||
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, 0));
|
||||
TerraformAddDirtyTile(ts, tile+TILE_XY(0,-1));
|
||||
TerraformAddDirtyTile(ts, tile+TILE_XY(-1,-1));
|
||||
TerraformAddDirtyTile(ts, tile+TILE_XY(-1,0));
|
||||
TerraformAddDirtyTile(ts, tile);
|
||||
}
|
||||
|
||||
static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
|
||||
static int TerraformProc(TerraformerState *ts, uint tile, int mode)
|
||||
{
|
||||
int r;
|
||||
int32 ret;
|
||||
|
||||
assert(tile < MapSize());
|
||||
assert(tile < TILES_X * TILES_Y);
|
||||
|
||||
r = TerraformAllowTileProcess(ts, tile);
|
||||
if (r <= 0) return r;
|
||||
if ((r=TerraformAllowTileProcess(ts, tile)) <= 0)
|
||||
return r;
|
||||
|
||||
if (IsTileType(tile, MP_RAILWAY)) {
|
||||
static const TrackBits safe_track[] = { TRACK_BIT_LOWER, TRACK_BIT_LEFT, TRACK_BIT_UPPER, TRACK_BIT_RIGHT };
|
||||
static const Slope unsafe_slope[] = { SLOPE_S, SLOPE_W, SLOPE_N, SLOPE_E };
|
||||
|
||||
Slope tileh;
|
||||
uint z;
|
||||
if ((_map_type_and_height[tile] >> 4) == MP_RAILWAY) {
|
||||
static const byte _railway_modes[4] = {8, 0x10, 4, 0x20};
|
||||
static const byte _railway_dangslopes[4] = {0xd, 0xe, 7, 0xb};
|
||||
static const byte _railway_dangslopes2[4] = {0x2, 0x1, 0x8, 0x4};
|
||||
|
||||
// Nothing could be built at the steep slope - this avoids a bug
|
||||
// when you have a single diagonal track in one corner on a
|
||||
// basement and then you raise/lower the other corner.
|
||||
tileh = GetTileSlope(tile, &z);
|
||||
if (tileh == unsafe_slope[mode] ||
|
||||
tileh == ComplementSlope(unsafe_slope[mode])) {
|
||||
int tileh = GetTileSlope(tile, NULL) & 0xF;
|
||||
if (tileh == _railway_dangslopes[mode] ||
|
||||
tileh == _railway_dangslopes2[mode]) {
|
||||
_terraform_err_tile = tile;
|
||||
_error_message = STR_1008_MUST_REMOVE_RAILROAD_TRACK;
|
||||
return -1;
|
||||
@@ -114,21 +109,8 @@ static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
|
||||
|
||||
// If we have a single diagonal track there, the other side of
|
||||
// tile can be terraformed.
|
||||
if (IsPlainRailTile(tile) && GetTrackBits(tile) == safe_track[mode]) {
|
||||
/* If terraforming downwards prevent damaging a potential tunnel below.
|
||||
* This check is only necessary for flat tiles, because if the tile is
|
||||
* non-flat, then the corner opposing the rail is raised. Only this corner
|
||||
* can be lowered and this is a safe action
|
||||
*/
|
||||
if (tileh == SLOPE_FLAT &&
|
||||
ts->direction == -1 &&
|
||||
IsTunnelInWay(tile, z - TILE_HEIGHT)) {
|
||||
_terraform_err_tile = tile;
|
||||
_error_message = STR_1002_EXCAVATION_WOULD_DAMAGE;
|
||||
return -1;
|
||||
}
|
||||
if ((_map5[tile]&~0x40) == _railway_modes[mode])
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ret = DoCommandByTile(tile, 0,0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
@@ -140,19 +122,20 @@ static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
|
||||
|
||||
ts->cost += ret;
|
||||
|
||||
if (ts->tile_table_count >= 625) return -1;
|
||||
if (ts->tile_table_count >= 625)
|
||||
return -1;
|
||||
ts->tile_table[ts->tile_table_count++] = tile;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
|
||||
static bool TerraformTileHeight(TerraformerState *ts, uint tile, int height)
|
||||
{
|
||||
int nh;
|
||||
TerraformerHeightMod *mod;
|
||||
int count;
|
||||
|
||||
assert(tile < MapSize());
|
||||
assert(tile < TILES_X * TILES_Y);
|
||||
|
||||
if (height < 0) {
|
||||
_error_message = STR_1003_ALREADY_AT_SEA_LEVEL;
|
||||
@@ -161,49 +144,54 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height
|
||||
|
||||
_error_message = STR_1004_TOO_HIGH;
|
||||
|
||||
if (height > 15) return false;
|
||||
if (height > 0xF)
|
||||
return false;
|
||||
|
||||
nh = TerraformGetHeightOfTile(ts, tile);
|
||||
if (nh < 0 || height == nh) return false;
|
||||
if (nh < 0 || height == nh)
|
||||
return false;
|
||||
|
||||
if (TerraformProc(ts, tile, 0) < 0) return false;
|
||||
if (TerraformProc(ts, tile + TileDiffXY( 0, -1), 1) < 0) return false;
|
||||
if (TerraformProc(ts, tile + TileDiffXY(-1, -1), 2) < 0) return false;
|
||||
if (TerraformProc(ts, tile + TileDiffXY(-1, 0), 3) < 0) return false;
|
||||
if (TerraformProc(ts, tile, 0)<0)
|
||||
return false;
|
||||
|
||||
if (TerraformProc(ts, tile + TILE_XY(0,-1), 1)<0)
|
||||
return false;
|
||||
|
||||
if (TerraformProc(ts, tile + TILE_XY(-1,-1), 2)<0)
|
||||
return false;
|
||||
|
||||
if (TerraformProc(ts, tile + TILE_XY(-1,0), 3)<0)
|
||||
return false;
|
||||
|
||||
mod = ts->modheight;
|
||||
count = ts->modheight_count;
|
||||
|
||||
for (;;) {
|
||||
for(;;) {
|
||||
if (count == 0) {
|
||||
if (ts->modheight_count >= 576)
|
||||
return false;
|
||||
ts->modheight_count++;
|
||||
break;
|
||||
}
|
||||
if (mod->tile == tile) break;
|
||||
if (mod->tile == (TileIndex)tile)
|
||||
break;
|
||||
mod++;
|
||||
count--;
|
||||
}
|
||||
|
||||
mod->tile = tile;
|
||||
mod->tile = (TileIndex)tile;
|
||||
mod->height = (byte)height;
|
||||
|
||||
ts->cost += _price.terraform;
|
||||
|
||||
{
|
||||
int direction = ts->direction, r;
|
||||
const TileIndexDiffC *ttm;
|
||||
const TileIndexDiff *ttm;
|
||||
|
||||
static const TileIndexDiffC _terraform_tilepos[] = {
|
||||
{ 1, 0},
|
||||
{-2, 0},
|
||||
{ 1, 1},
|
||||
{ 0, -2}
|
||||
};
|
||||
static const TileIndexDiff _terraform_tilepos[5] = {TILE_XY(1,0), TILE_XY(-2,0), TILE_XY(1,1), TILE_XY(0,-2), 0 };
|
||||
|
||||
for(ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
|
||||
tile += ToTileIndexDiff(*ttm);
|
||||
for(ttm = _terraform_tilepos; *ttm != 0; ttm++) {
|
||||
tile += *ttm;
|
||||
|
||||
r = TerraformGetHeightOfTile(ts, tile);
|
||||
if (r != height && r-direction != height && r+direction != height) {
|
||||
@@ -216,15 +204,15 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Terraform land
|
||||
* @param x,y coordinates to terraform
|
||||
* @param p1 corners to terraform.
|
||||
* @param p2 direction; eg up or down
|
||||
/* Terraform land
|
||||
* p1 - corners
|
||||
* p2 - direction
|
||||
*/
|
||||
|
||||
int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
TerraformerState ts;
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
int direction;
|
||||
|
||||
TerraformerHeightMod modheight_data[576];
|
||||
@@ -232,6 +220,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
_error_message = INVALID_STRING_ID;
|
||||
_terraform_err_tile = 0;
|
||||
|
||||
ts.direction = direction = p2 ? 1 : -1;
|
||||
@@ -241,32 +230,29 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
ts.modheight = modheight_data;
|
||||
ts.tile_table = tile_table_data;
|
||||
|
||||
tile = TileVirtXY(x, y);
|
||||
|
||||
/* Make an extra check for map-bounds cause we add tiles to the originating tile */
|
||||
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
|
||||
tile = TILE_FROM_XY(x,y);
|
||||
|
||||
if (p1 & 1) {
|
||||
if (!TerraformTileHeight(&ts, tile + TileDiffXY(1, 0),
|
||||
TileHeight(tile + TileDiffXY(1, 0)) + direction))
|
||||
if (!TerraformTileHeight(&ts, tile+TILE_XY(1,0),
|
||||
(_map_type_and_height[tile+TILE_XY(1,0)]&0xF) + direction))
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (p1 & 2) {
|
||||
if (!TerraformTileHeight(&ts, tile + TileDiffXY(1, 1),
|
||||
TileHeight(tile + TileDiffXY(1, 1)) + direction))
|
||||
if (!TerraformTileHeight(&ts, tile+TILE_XY(1,1),
|
||||
(_map_type_and_height[tile+TILE_XY(1,1)]&0xF) + direction))
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (p1 & 4) {
|
||||
if (!TerraformTileHeight(&ts, tile + TileDiffXY(0, 1),
|
||||
TileHeight(tile + TileDiffXY(0, 1)) + direction))
|
||||
if (!TerraformTileHeight(&ts, tile+TILE_XY(0,1),
|
||||
(_map_type_and_height[tile+TILE_XY(0,1)]&0xF) + direction))
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (p1 & 8) {
|
||||
if (!TerraformTileHeight(&ts, tile + TileDiffXY(0, 0),
|
||||
TileHeight(tile + TileDiffXY(0, 0)) + direction))
|
||||
if (!TerraformTileHeight(&ts, tile+TILE_XY(0,0),
|
||||
(_map_type_and_height[tile+TILE_XY(0,0)]&0xF) + direction))
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
@@ -275,21 +261,20 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
int count;
|
||||
TileIndex *ti = ts.tile_table;
|
||||
|
||||
for (count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
for(count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
uint z, t;
|
||||
TileIndex tile = *ti;
|
||||
uint tile = *ti;
|
||||
|
||||
z = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
|
||||
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
|
||||
z = TerraformGetHeightOfTile(&ts, tile + TILE_XY(0,0));
|
||||
t = TerraformGetHeightOfTile(&ts, tile + TILE_XY(1,0));
|
||||
if (t <= z) z = t;
|
||||
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
|
||||
t = TerraformGetHeightOfTile(&ts, tile + TILE_XY(1,1));
|
||||
if (t <= z) z = t;
|
||||
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
|
||||
t = TerraformGetHeightOfTile(&ts, tile + TILE_XY(0,1));
|
||||
if (t <= z) z = t;
|
||||
|
||||
if (IsTunnelInWay(tile, z * TILE_HEIGHT)) {
|
||||
if (!CheckTunnelInWay(tile, z*8))
|
||||
return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +283,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
int count;
|
||||
TileIndex *ti = ts.tile_table;
|
||||
for (count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
for(count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
DoCommandByTile(*ti, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||
}
|
||||
}
|
||||
@@ -307,12 +292,15 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
int count;
|
||||
TerraformerHeightMod *mod;
|
||||
uint til;
|
||||
|
||||
mod = ts.modheight;
|
||||
for (count = ts.modheight_count; count != 0; count--, mod++) {
|
||||
TileIndex til = mod->tile;
|
||||
for(count = ts.modheight_count; count != 0; count--, mod++) {
|
||||
til = mod->tile;
|
||||
|
||||
// Change tile height
|
||||
_map_type_and_height[til] = (_map_type_and_height[til]&~0x0F)|mod->height;
|
||||
|
||||
SetTileHeight(til, mod->height);
|
||||
TerraformAddDirtyTileAround(&ts, til);
|
||||
}
|
||||
}
|
||||
@@ -321,7 +309,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
int count;
|
||||
TileIndex *ti = ts.tile_table;
|
||||
for (count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
for(count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
MarkTileDirtyByTile(*ti);
|
||||
}
|
||||
}
|
||||
@@ -330,34 +318,29 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
}
|
||||
|
||||
|
||||
/** Levels a selected (rectangle) area of land
|
||||
* @param x,y end tile of area-drag
|
||||
* @param p1 start tile of area drag
|
||||
* @param p2 unused
|
||||
/*
|
||||
* p1 - start
|
||||
*/
|
||||
|
||||
int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
int size_x, size_y;
|
||||
int sx, sy;
|
||||
uint h, curh;
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
int32 ret, cost, money;
|
||||
|
||||
if (p1 >= MapSize()) return CMD_ERROR;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
// remember level height
|
||||
h = TileHeight(p1);
|
||||
h = _map_type_and_height[p1]&0xF;
|
||||
|
||||
ex >>= 4; ey >>= 4;
|
||||
|
||||
// make sure sx,sy are smaller than ex,ey
|
||||
sx = TileX(p1);
|
||||
sy = TileY(p1);
|
||||
sx = GET_TILE_X(p1);
|
||||
sy = GET_TILE_Y(p1);
|
||||
if (ex < sx) intswap(ex, sx);
|
||||
if (ey < sy) intswap(ey, sy);
|
||||
tile = TileXY(sx, sy);
|
||||
tile = TILE_XY(sx,sy);
|
||||
|
||||
size_x = ex-sx+1;
|
||||
size_y = ey-sy+1;
|
||||
@@ -365,11 +348,11 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
||||
money = GetAvailableMoneyForCommand();
|
||||
cost = 0;
|
||||
|
||||
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
|
||||
curh = TileHeight(tile2);
|
||||
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile)
|
||||
curh = _map_type_and_height[tile2]&0xF;
|
||||
while (curh != h) {
|
||||
ret = DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
|
||||
if (CmdFailed(ret)) break;
|
||||
ret = DoCommandByTile(tile2, 8, (curh > h)?0:1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
|
||||
if (ret == CMD_ERROR) break;
|
||||
cost += ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
@@ -377,39 +360,42 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
||||
_additional_cash_required = ret;
|
||||
return cost - ret;
|
||||
}
|
||||
DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
|
||||
DoCommandByTile(tile2, 8, (curh > h)?0:1, flags, CMD_TERRAFORM_LAND);
|
||||
}
|
||||
|
||||
curh += (curh > h) ? -1 : 1;
|
||||
}
|
||||
} END_TILE_LOOP(tile2, size_x, size_y, tile)
|
||||
END_TILE_LOOP(tile2, size_x, size_y, tile)
|
||||
|
||||
return (cost == 0) ? CMD_ERROR : cost;
|
||||
if (cost == 0) return CMD_ERROR;
|
||||
return cost;
|
||||
}
|
||||
|
||||
/** Purchase a land area. Actually you only purchase one tile, so
|
||||
* the name is a bit confusing ;p
|
||||
* @param x,y the tile the player is purchasing
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
/* Purchase a land area
|
||||
* p1 = unused
|
||||
* p2 = unused
|
||||
*/
|
||||
|
||||
int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
int32 cost;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
tile = TileVirtXY(x, y);
|
||||
tile = TILE_FROM_XY(x,y);
|
||||
|
||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
||||
if (!EnsureNoVehicle(tile))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (IsTileType(tile, MP_UNMOVABLE) && _m[tile].m5 == 3 &&
|
||||
IsTileOwner(tile, _current_player))
|
||||
if (IS_TILETYPE(tile, MP_UNMOVABLE) &&
|
||||
_map5[tile] == 3 &&
|
||||
_map_owner[tile] == _current_player)
|
||||
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
|
||||
|
||||
cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||
if (CmdFailed(cost)) return CMD_ERROR;
|
||||
if (cost == CMD_ERROR)
|
||||
return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
ModifyTile(tile,
|
||||
@@ -422,114 +408,90 @@ int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
}
|
||||
|
||||
|
||||
static int32 ClearTile_Clear(TileIndex tile, byte flags)
|
||||
{
|
||||
static const int32 null = 0;
|
||||
static const int32* clear_price_table[] = {
|
||||
&null,
|
||||
&_price.clear_1,
|
||||
&_price.clear_1,
|
||||
&_price.clear_1,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.clear_2,
|
||||
&_price.clear_2,
|
||||
&_price.clear_2,
|
||||
&_price.clear_2,
|
||||
&_price.clear_3,
|
||||
&_price.clear_3,
|
||||
&_price.clear_3,
|
||||
&_price.clear_3,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.clear_2,
|
||||
&_price.clear_2,
|
||||
&_price.clear_2,
|
||||
&_price.clear_2,
|
||||
int32 ClearTile_Clear(uint tile, byte flags) {
|
||||
static const int32 * _clear_price_table[] = {
|
||||
NULL,
|
||||
&_price.clear_1, &_price.clear_1,&_price.clear_1,
|
||||
&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,
|
||||
&_price.clear_2,&_price.clear_2,&_price.clear_2,&_price.clear_2,
|
||||
&_price.clear_3,&_price.clear_3,&_price.clear_3,&_price.clear_3,
|
||||
&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,
|
||||
&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,
|
||||
&_price.clear_2,&_price.clear_2,&_price.clear_2,&_price.clear_2,
|
||||
};
|
||||
const int32 *price = clear_price_table[GB(_m[tile].m5, 0, 5)];
|
||||
|
||||
if (flags & DC_EXEC) DoClearSquare(tile);
|
||||
|
||||
return *price;
|
||||
}
|
||||
|
||||
/** Sell a land area. Actually you only sell one tile, so
|
||||
* the name is a bit confusing ;p
|
||||
* @param x,y the tile the player is selling
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
*/
|
||||
int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
TileIndex tile;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
tile = TileVirtXY(x, y);
|
||||
|
||||
if (!IsTileType(tile, MP_UNMOVABLE) || _m[tile].m5 != 3) return CMD_ERROR;
|
||||
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
|
||||
|
||||
|
||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
||||
const int32 *price = _clear_price_table[_map5[tile] & 0x1F];
|
||||
|
||||
if (flags & DC_EXEC)
|
||||
DoClearSquare(tile);
|
||||
|
||||
return - _price.purchase_land * 2;
|
||||
if (price == NULL)
|
||||
return 0;
|
||||
return *price;
|
||||
}
|
||||
|
||||
int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
uint tile;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
tile = TILE_FROM_XY(x,y);
|
||||
|
||||
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
|
||||
return CMD_ERROR;
|
||||
|
||||
if (!EnsureNoVehicle(tile))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC)
|
||||
DoClearSquare(tile);
|
||||
|
||||
return - _price.purchase_land*2;
|
||||
}
|
||||
|
||||
|
||||
#include "table/clear_land.h"
|
||||
|
||||
|
||||
void DrawClearLandTile(const TileInfo *ti, byte set)
|
||||
void DrawClearLandTile(TileInfo *ti, byte set)
|
||||
{
|
||||
DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19);
|
||||
DrawGroundSprite(0xF54 + _tileh_to_sprite[ti->tileh] + set * 19);
|
||||
}
|
||||
|
||||
void DrawHillyLandTile(const TileInfo *ti)
|
||||
void DrawHillyLandTile(TileInfo *ti)
|
||||
{
|
||||
if (ti->tileh != 0) {
|
||||
DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh]);
|
||||
DrawGroundSprite(0xFA0 + _tileh_to_sprite[ti->tileh]);
|
||||
} else {
|
||||
DrawGroundSprite(_landscape_clear_sprites[GB(ti->x ^ ti->y, 4, 3)]);
|
||||
DrawGroundSprite(_landscape_clear_sprites[((ti->x^ti->y) >> 4) & 0x7]);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawClearLandFence(const TileInfo *ti)
|
||||
void DrawClearLandFence(TileInfo *ti, byte img)
|
||||
{
|
||||
byte m4 = _m[ti->tile].m4;
|
||||
byte z = ti->z;
|
||||
|
||||
if (ti->tileh & 2) {
|
||||
z += 8;
|
||||
if (ti->tileh == 0x17) z += 8;
|
||||
if (ti->tileh == 0x17)
|
||||
z += 8;
|
||||
}
|
||||
|
||||
if (GB(m4, 5, 3) != 0) {
|
||||
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GB(m4, 5, 3) - 1] + _fence_mod_by_tileh[ti->tileh], ti->x, ti->y, z);
|
||||
if (img & 0x38) {
|
||||
DrawGroundSpriteAt(_clear_land_fence_sprites_1[((img >> 3) & 7) - 1] + _fence_mod_by_tileh[ti->tileh], ti->x, ti->y, z);
|
||||
}
|
||||
|
||||
if (GB(m4, 2, 3) != 0) {
|
||||
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GB(m4, 2, 3) - 1] + _fence_mod_by_tileh_2[ti->tileh], ti->x, ti->y, z);
|
||||
if (img & 0x7) {
|
||||
DrawGroundSpriteAt(_clear_land_fence_sprites_1[(img & 7) - 1] + _fence_mod_by_tileh_2[ti->tileh], ti->x, ti->y, z);
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawTile_Clear(TileInfo *ti)
|
||||
{
|
||||
switch (GB(ti->map5, 2, 3)) {
|
||||
|
||||
switch((ti->map5 & (7<<2)) >> 2) {
|
||||
case 0:
|
||||
DrawClearLandTile(ti, GB(ti->map5, 0, 2));
|
||||
DrawClearLandTile(ti, (ti->map5 & 3));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -537,111 +499,100 @@ static void DrawTile_Clear(TileInfo *ti)
|
||||
break;
|
||||
|
||||
case 2:
|
||||
DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh]);
|
||||
DrawGroundSprite(0xFB7 + _tileh_to_sprite[ti->tileh]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
DrawGroundSprite(_clear_land_sprites_1[GB(_m[ti->tile].m3, 0, 4)] + _tileh_to_sprite[ti->tileh]);
|
||||
DrawGroundSprite( _clear_land_sprites_1[_map3_lo[ti->tile]&0xF] + _tileh_to_sprite[ti->tileh]);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
DrawGroundSprite(_clear_land_sprites_2[GB(ti->map5, 0, 2)] + _tileh_to_sprite[ti->tileh]);
|
||||
DrawGroundSprite( _clear_land_sprites_2[ti->map5&3] + _tileh_to_sprite[ti->tileh]);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
DrawGroundSprite(_clear_land_sprites_3[GB(ti->map5, 0, 2)] + _tileh_to_sprite[ti->tileh]);
|
||||
DrawGroundSprite( _clear_land_sprites_3[ti->map5&3] + _tileh_to_sprite[ti->tileh]);
|
||||
break;
|
||||
}
|
||||
|
||||
DrawClearLandFence(ti);
|
||||
DrawClearLandFence(ti, _map3_hi[ti->tile] >> 2);
|
||||
}
|
||||
|
||||
static uint GetSlopeZ_Clear(const TileInfo* ti)
|
||||
{
|
||||
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
|
||||
}
|
||||
uint GetSlopeZ_Clear(TileInfo *ti) { return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z; }
|
||||
|
||||
static uint GetSlopeTileh_Clear(const TileInfo *ti)
|
||||
uint GetSlopeTileh_Clear(TileInfo *ti)
|
||||
{
|
||||
return ti->tileh;
|
||||
}
|
||||
|
||||
static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac)
|
||||
static void GetAcceptedCargo_Clear(uint tile, AcceptedCargo ac)
|
||||
{
|
||||
/* unused */
|
||||
}
|
||||
|
||||
static void AnimateTile_Clear(TileIndex tile)
|
||||
static void AnimateTile_Clear(uint tile)
|
||||
{
|
||||
/* unused */
|
||||
}
|
||||
|
||||
void TileLoopClearHelper(TileIndex tile)
|
||||
void TileLoopClearHelper(uint tile)
|
||||
{
|
||||
byte self;
|
||||
byte neighbour;
|
||||
TileIndex dirty = INVALID_TILE;
|
||||
byte img_1, img_2;
|
||||
static byte img_by_map5[8] = { 0,0,0,2, 1,1,0,0, };
|
||||
uint dirty = -1;
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_CLEAR:
|
||||
self = (GB(_m[tile].m5, 0, 5) == 15);
|
||||
break;
|
||||
|
||||
default:
|
||||
self = 0;
|
||||
break;
|
||||
img_1 = 0;
|
||||
if (IS_TILETYPE(tile, MP_CLEAR)) {
|
||||
img_1 = img_by_map5[(_map5[tile] & 0x1C) >> 2];
|
||||
} else if (IS_TILETYPE(tile, MP_TREES) && (_map2[tile] & 0x30) == 0x20) {
|
||||
img_1 = 1;
|
||||
}
|
||||
|
||||
switch (GetTileType(TILE_ADDXY(tile, 1, 0))) {
|
||||
case MP_CLEAR:
|
||||
neighbour = (GB(_m[TILE_ADDXY(tile, 1, 0)].m5, 0, 5) == 15);
|
||||
break;
|
||||
|
||||
default:
|
||||
neighbour = 0;
|
||||
break;
|
||||
img_2 = 0;
|
||||
if (IS_TILETYPE(TILE_ADDXY(tile, 1, 0), MP_CLEAR)) {
|
||||
img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 1, 0)] & 0x1C) >> 2];
|
||||
} else if (IS_TILETYPE(TILE_ADDXY(tile, 1, 0), MP_TREES) && (_map2[TILE_ADDXY(tile, 1, 0)] & 0x30) == 0x20) {
|
||||
img_2 = 1;
|
||||
}
|
||||
|
||||
if (GB(_m[tile].m4, 5, 3) == 0) {
|
||||
if (self != neighbour) {
|
||||
SB(_m[tile].m4, 5, 3, 3);
|
||||
if (!(_map3_hi[tile] & 0xE0)) {
|
||||
if ( (img_1&2) != (img_2&2) ) {
|
||||
_map3_hi[tile] |= 3 << 5;
|
||||
dirty = tile;
|
||||
}
|
||||
} else {
|
||||
if (self == 0 && neighbour == 0) {
|
||||
SB(_m[tile].m4, 5, 3, 0);
|
||||
if (img_1 == 1 && img_2 == 1) {
|
||||
_map3_hi[tile] &= ~(3 << 5);
|
||||
dirty = tile;
|
||||
}
|
||||
}
|
||||
|
||||
switch (GetTileType(TILE_ADDXY(tile, 0, 1))) {
|
||||
case MP_CLEAR:
|
||||
neighbour = (GB(_m[TILE_ADDXY(tile, 0, 1)].m5, 0, 5) == 15);
|
||||
break;
|
||||
|
||||
default:
|
||||
neighbour = 0;
|
||||
break;
|
||||
img_2 = 0;
|
||||
if (IS_TILETYPE(TILE_ADDXY(tile, 0, 1), MP_CLEAR)) {
|
||||
img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 0, 1)] & 0x1C) >> 2];
|
||||
} else if (IS_TILETYPE(TILE_ADDXY(tile, 0, 1), MP_TREES) && (_map2[TILE_ADDXY(tile, 0, 1)] & 0x30) == 0x20) {
|
||||
img_2 = 1;
|
||||
}
|
||||
|
||||
if (GB(_m[tile].m4, 2, 3) == 0) {
|
||||
if (self != neighbour) {
|
||||
SB(_m[tile].m4, 2, 3, 3);
|
||||
if (!(_map3_hi[tile] & 0x1C)) {
|
||||
if ( (img_1&2) != (img_2&2) ) {
|
||||
_map3_hi[tile] |= 3 << 2;
|
||||
dirty = tile;
|
||||
}
|
||||
} else {
|
||||
if (self == 0 && neighbour == 0) {
|
||||
SB(_m[tile].m4, 2, 3, 0);
|
||||
if (img_1 == 1 && img_2 == 1) {
|
||||
_map3_hi[tile] &= ~(3 << 2);
|
||||
dirty = tile;
|
||||
}
|
||||
}
|
||||
|
||||
if (dirty != INVALID_TILE) MarkTileDirtyByTile(dirty);
|
||||
if (dirty != -1)
|
||||
MarkTileDirtyByTile(dirty);
|
||||
}
|
||||
|
||||
|
||||
/* convert into snowy tiles */
|
||||
static void TileLoopClearAlps(TileIndex tile)
|
||||
static void TileLoopClearAlps(uint tile)
|
||||
{
|
||||
int k;
|
||||
byte m5,tmp;
|
||||
@@ -649,8 +600,8 @@ static void TileLoopClearAlps(TileIndex tile)
|
||||
/* distance from snow line, in steps of 8 */
|
||||
k = GetTileZ(tile) - _opt.snow_line;
|
||||
|
||||
m5 = _m[tile].m5 & 0x1C;
|
||||
tmp = _m[tile].m5 & 3;
|
||||
m5 = _map5[tile] & 0x1C;
|
||||
tmp = _map5[tile] & 3;
|
||||
|
||||
if (k < -8) {
|
||||
/* snow_m2_down */
|
||||
@@ -698,29 +649,30 @@ static void TileLoopClearAlps(TileIndex tile)
|
||||
return;
|
||||
}
|
||||
|
||||
_m[tile].m5 = m5;
|
||||
_map5[tile] = m5;
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
static void TileLoopClearDesert(TileIndex tile)
|
||||
static void TileLoopClearDesert(uint tile)
|
||||
{
|
||||
if ((_m[tile].m5 & 0x1C) == 0x14) return;
|
||||
if ( (_map5[tile] & 0x1C) == 0x14)
|
||||
return;
|
||||
|
||||
if (GetMapExtraBits(tile) == 1) {
|
||||
_m[tile].m5 = 0x17;
|
||||
_map5[tile] = 0x17;
|
||||
} else {
|
||||
if (GetMapExtraBits(tile + TileDiffXY( 1, 0)) != 1 &&
|
||||
GetMapExtraBits(tile + TileDiffXY(-1, 0)) != 1 &&
|
||||
GetMapExtraBits(tile + TileDiffXY( 0, 1)) != 1 &&
|
||||
GetMapExtraBits(tile + TileDiffXY( 0, -1)) != 1)
|
||||
return;
|
||||
_m[tile].m5 = 0x15;
|
||||
if (GetMapExtraBits(tile+TILE_XY(1,0)) != 1 &&
|
||||
GetMapExtraBits(tile+TILE_XY(-1,0)) != 1 &&
|
||||
GetMapExtraBits(tile+TILE_XY(0,1)) != 1 &&
|
||||
GetMapExtraBits(tile+TILE_XY(0,-1)) != 1)
|
||||
return;
|
||||
_map5[tile] = 0x15;
|
||||
}
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
static void TileLoop_Clear(TileIndex tile)
|
||||
static void TileLoop_Clear(uint tile)
|
||||
{
|
||||
byte m5,m3;
|
||||
|
||||
@@ -732,22 +684,24 @@ static void TileLoop_Clear(TileIndex tile)
|
||||
TileLoopClearAlps(tile);
|
||||
}
|
||||
|
||||
m5 = _m[tile].m5;
|
||||
if ((m5 & 0x1C) == 0x10 || (m5 & 0x1C) == 0x14) return;
|
||||
m5 = _map5[tile];
|
||||
if ( (m5 & 0x1C) == 0x10 || (m5 & 0x1C) == 0x14)
|
||||
return;
|
||||
|
||||
if ((m5 & 0x1C) != 0xC) {
|
||||
if ((m5 & 3) == 3) return;
|
||||
if ( (m5 & 0x1C) != 0xC) {
|
||||
if ( (m5 & 3) == 3)
|
||||
return;
|
||||
|
||||
if (_game_mode != GM_EDITOR) {
|
||||
m5 += 0x20;
|
||||
if (m5 >= 0x20) {
|
||||
// Didn't overflow
|
||||
_m[tile].m5 = m5;
|
||||
_map5[tile] = m5;
|
||||
return;
|
||||
}
|
||||
/* did overflow, so continue */
|
||||
} else {
|
||||
m5 = (GB(Random(), 0, 8) > 21) ? 2 : 6;
|
||||
m5 = ((byte)Random() > 21) ? (2) : (6);
|
||||
}
|
||||
m5++;
|
||||
} else if (_game_mode != GM_EDITOR) {
|
||||
@@ -755,48 +709,48 @@ static void TileLoop_Clear(TileIndex tile)
|
||||
m5 += 0x20;
|
||||
if (m5 >= 0x20) {
|
||||
// Didn't overflow
|
||||
_m[tile].m5 = m5;
|
||||
_map5[tile] = m5;
|
||||
return;
|
||||
}
|
||||
/* overflowed */
|
||||
m3 = _m[tile].m3 + 1;
|
||||
m3 = _map3_lo[tile] + 1;
|
||||
assert( (m3 & 0xF) != 0);
|
||||
if ( (m3 & 0xF) >= 9) /* NOTE: will not work properly if m3&0xF == 0xF */
|
||||
m3 &= ~0xF;
|
||||
_m[tile].m3 = m3;
|
||||
_map3_lo[tile] = m3;
|
||||
}
|
||||
|
||||
_m[tile].m5 = m5;
|
||||
_map5[tile] = m5;
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
void GenerateClearTile(void)
|
||||
void GenerateClearTile()
|
||||
{
|
||||
uint i;
|
||||
TileIndex tile;
|
||||
int i,j;
|
||||
uint tile,tile_new;
|
||||
uint32 r;
|
||||
|
||||
/* add hills */
|
||||
i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400);
|
||||
i = (Random() & 0x3FF) | 0x400;
|
||||
do {
|
||||
tile = RandomTile();
|
||||
if (IsTileType(tile, MP_CLEAR)) SB(_m[tile].m5, 2, 2, 1);
|
||||
tile = TILE_MASK(Random());
|
||||
if (IS_TILETYPE(tile, MP_CLEAR))
|
||||
_map5[tile] = (byte)((_map5[tile] & ~(3<<2)) | (1<<2));
|
||||
} while (--i);
|
||||
|
||||
/* add grey squares */
|
||||
i = ScaleByMapSize(GB(Random(), 0, 7) + 0x80);
|
||||
i = (Random() & 0x7F) | 0x80;
|
||||
do {
|
||||
uint32 r = Random();
|
||||
tile = RandomTileSeed(r);
|
||||
if (IsTileType(tile, MP_CLEAR)) {
|
||||
uint j = GB(r, 16, 4) + 5;
|
||||
r = Random();
|
||||
tile = TILE_MASK(r);
|
||||
if (IS_TILETYPE(tile, MP_CLEAR)) {
|
||||
j = ((r >> 16) & 0xF) + 5;
|
||||
for(;;) {
|
||||
TileIndex tile_new;
|
||||
|
||||
SB(_m[tile].m5, 2, 2, 2);
|
||||
_map5[tile] = (byte)((_map5[tile] & ~(3<<2)) | (2<<2));
|
||||
do {
|
||||
if (--j == 0) goto get_out;
|
||||
tile_new = tile + TileOffsByDir(GB(Random(), 0, 2));
|
||||
} while (!IsTileType(tile_new, MP_CLEAR));
|
||||
tile_new = tile + _tileoffs_by_dir[Random() & 3];
|
||||
} while (!IS_TILETYPE(tile_new, MP_CLEAR));
|
||||
tile = tile_new;
|
||||
}
|
||||
get_out:;
|
||||
@@ -804,17 +758,17 @@ get_out:;
|
||||
} while (--i);
|
||||
}
|
||||
|
||||
static void ClickTile_Clear(TileIndex tile)
|
||||
static void ClickTile_Clear(uint tile)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode)
|
||||
static uint32 GetTileTrackStatus_Clear(uint tile, TransportType mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const StringID _clear_land_str[] = {
|
||||
static const StringID _clear_land_str[4+8-1] = {
|
||||
STR_080B_ROUGH_LAND,
|
||||
STR_080A_ROCKS,
|
||||
STR_080E_FIELDS,
|
||||
@@ -828,21 +782,21 @@ static const StringID _clear_land_str[] = {
|
||||
STR_080D_GRASS,
|
||||
};
|
||||
|
||||
static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
|
||||
static void GetTileDesc_Clear(uint tile, TileDesc *td)
|
||||
{
|
||||
uint i = GB(_m[tile].m5, 2, 3);
|
||||
if (i == 0) i = GB(_m[tile].m5, 0, 2) + 8;
|
||||
int i = (_map5[tile]>>2) & 7;
|
||||
if (i == 0)
|
||||
i = (_map5[tile] & 3) + 8;
|
||||
td->str = _clear_land_str[i - 1];
|
||||
td->owner = GetTileOwner(tile);
|
||||
td->owner = _map_owner[tile];
|
||||
}
|
||||
|
||||
static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID new_player)
|
||||
static void ChangeTileOwner_Clear(uint tile, byte old_player, byte new_player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void InitializeClearLand(void)
|
||||
{
|
||||
void InitializeClearLand() {
|
||||
_opt.snow_line = _patches.snow_line_height * 8;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "gui.h"
|
||||
#include "command.h"
|
||||
#include "player.h"
|
||||
#include "network.h"
|
||||
#include "variables.h"
|
||||
|
||||
const char* _cmd_text = NULL;
|
||||
|
||||
#define DEF_COMMAND(yyyy) int32 yyyy(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
@@ -28,8 +22,8 @@ DEF_COMMAND(CmdBuildRailroadStation);
|
||||
DEF_COMMAND(CmdRemoveFromRailroadStation);
|
||||
DEF_COMMAND(CmdConvertRail);
|
||||
|
||||
DEF_COMMAND(CmdBuildSingleSignal);
|
||||
DEF_COMMAND(CmdRemoveSingleSignal);
|
||||
DEF_COMMAND(CmdBuildSignals);
|
||||
DEF_COMMAND(CmdRemoveSignals);
|
||||
|
||||
DEF_COMMAND(CmdTerraformLand);
|
||||
|
||||
@@ -43,7 +37,9 @@ DEF_COMMAND(CmdBuildTrainWaypoint);
|
||||
DEF_COMMAND(CmdRenameWaypoint);
|
||||
DEF_COMMAND(CmdRemoveTrainWaypoint);
|
||||
|
||||
DEF_COMMAND(CmdBuildRoadStop);
|
||||
DEF_COMMAND(CmdBuildTruckStation);
|
||||
|
||||
DEF_COMMAND(CmdBuildBusStation);
|
||||
|
||||
DEF_COMMAND(CmdBuildLongRoad);
|
||||
DEF_COMMAND(CmdRemoveLongRoad);
|
||||
@@ -69,7 +65,7 @@ DEF_COMMAND(CmdStartStopTrain);
|
||||
|
||||
DEF_COMMAND(CmdSellRailWagon);
|
||||
|
||||
DEF_COMMAND(CmdSendTrainToDepot);
|
||||
DEF_COMMAND(CmdTrainGotoDepot);
|
||||
DEF_COMMAND(CmdForceTrainProceed);
|
||||
DEF_COMMAND(CmdReverseTrainDirection);
|
||||
|
||||
@@ -77,12 +73,14 @@ DEF_COMMAND(CmdModifyOrder);
|
||||
DEF_COMMAND(CmdSkipOrder);
|
||||
DEF_COMMAND(CmdDeleteOrder);
|
||||
DEF_COMMAND(CmdInsertOrder);
|
||||
DEF_COMMAND(CmdChangeServiceInt);
|
||||
DEF_COMMAND(CmdChangeTrainServiceInt);
|
||||
DEF_COMMAND(CmdRestoreOrderIndex);
|
||||
|
||||
DEF_COMMAND(CmdBuildIndustry);
|
||||
//DEF_COMMAND(CmdDestroyIndustry);
|
||||
|
||||
DEF_COMMAND(CmdBuildCompanyHQ);
|
||||
DEF_COMMAND(CmdDestroyCompanyHQ);
|
||||
DEF_COMMAND(CmdSetPlayerFace);
|
||||
DEF_COMMAND(CmdSetPlayerColor);
|
||||
|
||||
@@ -103,6 +101,7 @@ DEF_COMMAND(CmdSellAircraft);
|
||||
DEF_COMMAND(CmdStartStopAircraft);
|
||||
DEF_COMMAND(CmdBuildAircraft);
|
||||
DEF_COMMAND(CmdSendAircraftToHangar);
|
||||
DEF_COMMAND(CmdChangeAircraftServiceInt);
|
||||
DEF_COMMAND(CmdRefitAircraft);
|
||||
|
||||
DEF_COMMAND(CmdPlaceSign);
|
||||
@@ -113,8 +112,10 @@ DEF_COMMAND(CmdStartStopRoadVeh);
|
||||
DEF_COMMAND(CmdSellRoadVeh);
|
||||
DEF_COMMAND(CmdSendRoadVehToDepot);
|
||||
DEF_COMMAND(CmdTurnRoadVeh);
|
||||
DEF_COMMAND(CmdChangeRoadVehServiceInt);
|
||||
|
||||
DEF_COMMAND(CmdPause);
|
||||
DEF_COMMAND(CmdResume);
|
||||
|
||||
DEF_COMMAND(CmdBuyShareInCompany);
|
||||
DEF_COMMAND(CmdSellShareInCompany);
|
||||
@@ -126,6 +127,7 @@ DEF_COMMAND(CmdRenameTown);
|
||||
DEF_COMMAND(CmdDoTownAction);
|
||||
|
||||
DEF_COMMAND(CmdSetRoadDriveSide);
|
||||
DEF_COMMAND(CmdSetTownNameType);
|
||||
|
||||
DEF_COMMAND(CmdChangeDifficultyLevel);
|
||||
DEF_COMMAND(CmdChangePatchSetting);
|
||||
@@ -134,8 +136,18 @@ DEF_COMMAND(CmdStartStopShip);
|
||||
DEF_COMMAND(CmdSellShip);
|
||||
DEF_COMMAND(CmdBuildShip);
|
||||
DEF_COMMAND(CmdSendShipToDepot);
|
||||
DEF_COMMAND(CmdChangeShipServiceInt);
|
||||
DEF_COMMAND(CmdRefitShip);
|
||||
|
||||
|
||||
DEF_COMMAND(CmdStartNewGame);
|
||||
DEF_COMMAND(CmdLoadGame);
|
||||
DEF_COMMAND(CmdCreateScenario);
|
||||
DEF_COMMAND(CmdSetSinglePlayer);
|
||||
|
||||
DEF_COMMAND(CmdSetNewLandscapeType);
|
||||
|
||||
DEF_COMMAND(CmdGenRandomNewGame);
|
||||
DEF_COMMAND(CmdCloneOrder);
|
||||
|
||||
DEF_COMMAND(CmdClearArea);
|
||||
@@ -151,199 +163,181 @@ DEF_COMMAND(CmdLevelLand);
|
||||
|
||||
DEF_COMMAND(CmdRefitRailVehicle);
|
||||
|
||||
DEF_COMMAND(CmdBuildSignalTrack);
|
||||
DEF_COMMAND(CmdRemoveSignalTrack);
|
||||
|
||||
DEF_COMMAND(CmdReplaceVehicle);
|
||||
|
||||
DEF_COMMAND(CmdCloneVehicle);
|
||||
DEF_COMMAND(CmdStartScenario);
|
||||
|
||||
DEF_COMMAND(CmdBuildManySignals);
|
||||
|
||||
/* The master command table */
|
||||
static const Command _command_proc_table[] = {
|
||||
{CmdBuildRailroadTrack, 0}, /* 0 */
|
||||
{CmdRemoveRailroadTrack, 0}, /* 1 */
|
||||
{CmdBuildSingleRail, 0}, /* 2 */
|
||||
{CmdRemoveSingleRail, 0}, /* 3 */
|
||||
{CmdLandscapeClear, 0}, /* 4 */
|
||||
{CmdBuildBridge, 0}, /* 5 */
|
||||
{CmdBuildRailroadStation, 0}, /* 6 */
|
||||
{CmdBuildTrainDepot, 0}, /* 7 */
|
||||
{CmdBuildSingleSignal, 0}, /* 8 */
|
||||
{CmdRemoveSingleSignal, 0}, /* 9 */
|
||||
{CmdTerraformLand, 0}, /* 10 */
|
||||
{CmdPurchaseLandArea, 0}, /* 11 */
|
||||
{CmdSellLandArea, 0}, /* 12 */
|
||||
{CmdBuildTunnel, 0}, /* 13 */
|
||||
{CmdRemoveFromRailroadStation, 0}, /* 14 */
|
||||
{CmdConvertRail, 0}, /* 15 */
|
||||
{CmdBuildTrainWaypoint, 0}, /* 16 */
|
||||
{CmdRenameWaypoint, 0}, /* 17 */
|
||||
{CmdRemoveTrainWaypoint, 0}, /* 18 */
|
||||
{NULL, 0}, /* 19 */
|
||||
{NULL, 0}, /* 20 */
|
||||
{CmdBuildRoadStop, 0}, /* 21 */
|
||||
{NULL, 0}, /* 22 */
|
||||
{CmdBuildLongRoad, 0}, /* 23 */
|
||||
{CmdRemoveLongRoad, 0}, /* 24 */
|
||||
{CmdBuildRoad, 0}, /* 25 */
|
||||
{CmdRemoveRoad, 0}, /* 26 */
|
||||
{CmdBuildRoadDepot, 0}, /* 27 */
|
||||
{NULL, 0}, /* 28 */
|
||||
{CmdBuildAirport, 0}, /* 29 */
|
||||
{CmdBuildDock, 0}, /* 30 */
|
||||
{CmdBuildShipDepot, 0}, /* 31 */
|
||||
{CmdBuildBuoy, 0}, /* 32 */
|
||||
{CmdPlantTree, 0}, /* 33 */
|
||||
{CmdBuildRailVehicle, 0}, /* 34 */
|
||||
{CmdMoveRailVehicle, 0}, /* 35 */
|
||||
{CmdStartStopTrain, 0}, /* 36 */
|
||||
{NULL, 0}, /* 37 */
|
||||
{CmdSellRailWagon, 0}, /* 38 */
|
||||
{CmdSendTrainToDepot, 0}, /* 39 */
|
||||
{CmdForceTrainProceed, 0}, /* 40 */
|
||||
{CmdReverseTrainDirection, 0}, /* 41 */
|
||||
static CommandProc * const _command_proc_table[] = {
|
||||
CmdBuildRailroadTrack, /* 0 */
|
||||
CmdRemoveRailroadTrack, /* 1 */
|
||||
CmdBuildSingleRail, /* 2 */
|
||||
CmdRemoveSingleRail, /* 3 */
|
||||
CmdLandscapeClear, /* 4 */
|
||||
CmdBuildBridge, /* 5 */
|
||||
CmdBuildRailroadStation, /* 6 */
|
||||
CmdBuildTrainDepot, /* 7 */
|
||||
CmdBuildSignals, /* 8 */
|
||||
CmdRemoveSignals, /* 9 */
|
||||
CmdTerraformLand, /* 10 */
|
||||
CmdPurchaseLandArea, /* 11 */
|
||||
CmdSellLandArea, /* 12 */
|
||||
CmdBuildTunnel, /* 13 */
|
||||
CmdRemoveFromRailroadStation, /* 14 */
|
||||
CmdConvertRail, /* 15 */
|
||||
CmdBuildTrainWaypoint, /* 16 */
|
||||
CmdRenameWaypoint, /* 17 */
|
||||
CmdRemoveTrainWaypoint, /* 18 */
|
||||
CmdBuildTruckStation, /* 19 */
|
||||
NULL, /* 20 */
|
||||
CmdBuildBusStation, /* 21 */
|
||||
NULL, /* 22 */
|
||||
CmdBuildLongRoad, /* 23 */
|
||||
CmdRemoveLongRoad, /* 24 */
|
||||
CmdBuildRoad, /* 25 */
|
||||
CmdRemoveRoad, /* 26 */
|
||||
CmdBuildRoadDepot, /* 27 */
|
||||
NULL, /* 28 */
|
||||
CmdBuildAirport, /* 29 */
|
||||
CmdBuildDock, /* 30 */
|
||||
CmdBuildShipDepot, /* 31 */
|
||||
CmdBuildBuoy, /* 32 */
|
||||
CmdPlantTree, /* 33 */
|
||||
CmdBuildRailVehicle, /* 34 */
|
||||
CmdMoveRailVehicle, /* 35 */
|
||||
CmdStartStopTrain, /* 36 */
|
||||
NULL, /* 37 */
|
||||
CmdSellRailWagon, /* 38 */
|
||||
CmdTrainGotoDepot, /* 39 */
|
||||
CmdForceTrainProceed, /* 40 */
|
||||
CmdReverseTrainDirection, /* 41 */
|
||||
|
||||
{CmdModifyOrder, 0}, /* 42 */
|
||||
{CmdSkipOrder, 0}, /* 43 */
|
||||
{CmdDeleteOrder, 0}, /* 44 */
|
||||
{CmdInsertOrder, 0}, /* 45 */
|
||||
CmdModifyOrder, /* 42 */
|
||||
CmdSkipOrder, /* 43 */
|
||||
CmdDeleteOrder, /* 44 */
|
||||
CmdInsertOrder, /* 45 */
|
||||
|
||||
{CmdChangeServiceInt, 0}, /* 46 */
|
||||
CmdChangeTrainServiceInt, /* 46 */
|
||||
|
||||
{CmdBuildIndustry, 0}, /* 47 */
|
||||
{CmdBuildCompanyHQ, 0}, /* 48 */
|
||||
{CmdSetPlayerFace, 0}, /* 49 */
|
||||
{CmdSetPlayerColor, 0}, /* 50 */
|
||||
CmdBuildIndustry, /* 47 */
|
||||
CmdBuildCompanyHQ, /* 48 */
|
||||
CmdSetPlayerFace, /* 49 */
|
||||
CmdSetPlayerColor, /* 50 */
|
||||
|
||||
{CmdIncreaseLoan, 0}, /* 51 */
|
||||
{CmdDecreaseLoan, 0}, /* 52 */
|
||||
CmdIncreaseLoan, /* 51 */
|
||||
CmdDecreaseLoan, /* 52 */
|
||||
|
||||
{CmdWantEnginePreview, 0}, /* 53 */
|
||||
CmdWantEnginePreview, /* 53 */
|
||||
|
||||
{CmdNameVehicle, 0}, /* 54 */
|
||||
{CmdRenameEngine, 0}, /* 55 */
|
||||
CmdNameVehicle, /* 54 */
|
||||
CmdRenameEngine, /* 55 */
|
||||
|
||||
{CmdChangeCompanyName, 0}, /* 56 */
|
||||
{CmdChangePresidentName, 0}, /* 57 */
|
||||
CmdChangeCompanyName, /* 56 */
|
||||
CmdChangePresidentName, /* 57 */
|
||||
|
||||
{CmdRenameStation, 0}, /* 58 */
|
||||
CmdRenameStation, /* 58 */
|
||||
|
||||
{CmdSellAircraft, 0}, /* 59 */
|
||||
{CmdStartStopAircraft, 0}, /* 60 */
|
||||
CmdSellAircraft, /* 59 */
|
||||
CmdStartStopAircraft, /* 60 */
|
||||
CmdBuildAircraft, /* 61 */
|
||||
CmdSendAircraftToHangar, /* 62 */
|
||||
CmdChangeAircraftServiceInt, /* 63 */
|
||||
CmdRefitAircraft, /* 64 */
|
||||
|
||||
{CmdBuildAircraft, 0}, /* 61 */
|
||||
{CmdSendAircraftToHangar, 0}, /* 62 */
|
||||
{NULL, 0}, /* 63 */
|
||||
{CmdRefitAircraft, 0}, /* 64 */
|
||||
CmdPlaceSign, /* 65 */
|
||||
CmdRenameSign, /* 66 */
|
||||
|
||||
{CmdPlaceSign, 0}, /* 65 */
|
||||
{CmdRenameSign, 0}, /* 66 */
|
||||
CmdBuildRoadVeh, /* 67 */
|
||||
CmdStartStopRoadVeh, /* 68 */
|
||||
CmdSellRoadVeh, /* 69 */
|
||||
CmdSendRoadVehToDepot, /* 70 */
|
||||
CmdTurnRoadVeh, /* 71 */
|
||||
CmdChangeRoadVehServiceInt, /* 72 */
|
||||
|
||||
{CmdBuildRoadVeh, 0}, /* 67 */
|
||||
{CmdStartStopRoadVeh, 0}, /* 68 */
|
||||
{CmdSellRoadVeh, 0}, /* 69 */
|
||||
{CmdSendRoadVehToDepot, 0}, /* 70 */
|
||||
{CmdTurnRoadVeh, 0}, /* 71 */
|
||||
{NULL, 0}, /* 72 */
|
||||
CmdPause, /* 73 */
|
||||
|
||||
{CmdPause, CMD_SERVER}, /* 73 */
|
||||
CmdBuyShareInCompany, /* 74 */
|
||||
CmdSellShareInCompany, /* 75 */
|
||||
CmdBuyCompany, /* 76 */
|
||||
|
||||
{CmdBuyShareInCompany, 0}, /* 74 */
|
||||
{CmdSellShareInCompany, 0}, /* 75 */
|
||||
{CmdBuyCompany, 0}, /* 76 */
|
||||
CmdBuildTown, /* 77 */
|
||||
NULL, /* 78 */
|
||||
NULL, /* 79 */
|
||||
CmdRenameTown, /* 80 */
|
||||
CmdDoTownAction, /* 81 */
|
||||
|
||||
{CmdBuildTown, CMD_OFFLINE}, /* 77 */
|
||||
{NULL, 0}, /* 78 */
|
||||
{NULL, 0}, /* 79 */
|
||||
{CmdRenameTown, CMD_SERVER}, /* 80 */
|
||||
{CmdDoTownAction, 0}, /* 81 */
|
||||
CmdSetRoadDriveSide, /* 82 */
|
||||
CmdSetTownNameType, /* 83 */
|
||||
NULL, /* 84 */
|
||||
CmdChangeDifficultyLevel, /* 85 */
|
||||
|
||||
{CmdSetRoadDriveSide, CMD_SERVER}, /* 82 */
|
||||
{NULL, 0}, /* 83 */
|
||||
{NULL, 0}, /* 84 */
|
||||
{CmdChangeDifficultyLevel, CMD_SERVER}, /* 85 */
|
||||
CmdStartStopShip, /* 86 */
|
||||
CmdSellShip, /* 87 */
|
||||
CmdBuildShip, /* 88 */
|
||||
CmdSendShipToDepot, /* 89 */
|
||||
CmdChangeShipServiceInt, /* 90 */
|
||||
CmdRefitShip, /* 91 */
|
||||
|
||||
{CmdStartStopShip, 0}, /* 86 */
|
||||
{CmdSellShip, 0}, /* 87 */
|
||||
{CmdBuildShip, 0}, /* 88 */
|
||||
{CmdSendShipToDepot, 0}, /* 89 */
|
||||
{NULL, 0}, /* 90 */
|
||||
{CmdRefitShip, 0}, /* 91 */
|
||||
CmdStartNewGame, /* 92 */
|
||||
CmdLoadGame, /* 93 */
|
||||
CmdCreateScenario, /* 94 */
|
||||
CmdSetSinglePlayer, /* 95 */
|
||||
NULL, /* 96 */
|
||||
CmdSetNewLandscapeType, /* 97 */
|
||||
|
||||
{NULL, 0}, /* 92 */
|
||||
{NULL, 0}, /* 93 */
|
||||
{NULL, 0}, /* 94 */
|
||||
{NULL, 0}, /* 95 */
|
||||
{NULL, 0}, /* 96 */
|
||||
{NULL, 0}, /* 97 */
|
||||
{NULL, 0}, /* 98 */
|
||||
CmdGenRandomNewGame, /* 98 */
|
||||
|
||||
{CmdCloneOrder, 0}, /* 99 */
|
||||
CmdCloneOrder, /* 99 */
|
||||
|
||||
{CmdClearArea, 0}, /* 100 */
|
||||
{NULL, 0}, /* 101 */
|
||||
CmdClearArea, /* 100 */
|
||||
CmdResume, /* 101 */
|
||||
|
||||
{CmdMoneyCheat, CMD_OFFLINE}, /* 102 */
|
||||
{CmdBuildCanal, 0}, /* 103 */
|
||||
{CmdPlayerCtrl, 0}, /* 104 */
|
||||
CmdMoneyCheat, /* 102 */
|
||||
CmdBuildCanal, /* 103 */
|
||||
CmdPlayerCtrl, /* 104 */
|
||||
|
||||
{CmdLevelLand, 0}, /* 105 */
|
||||
CmdLevelLand, /* 105 */
|
||||
|
||||
{CmdRefitRailVehicle, 0}, /* 106 */
|
||||
{CmdRestoreOrderIndex, 0}, /* 107 */
|
||||
{CmdBuildLock, 0}, /* 108 */
|
||||
{NULL, 0}, /* 109 */
|
||||
{CmdBuildSignalTrack, 0}, /* 110 */
|
||||
{CmdRemoveSignalTrack, 0}, /* 111 */
|
||||
{NULL, 0}, /* 112 */
|
||||
{CmdGiveMoney, 0}, /* 113 */
|
||||
{CmdChangePatchSetting, CMD_SERVER}, /* 114 */
|
||||
{CmdReplaceVehicle, 0}, /* 115 */
|
||||
{CmdCloneVehicle, 0}, /* 116 */
|
||||
CmdRefitRailVehicle, /* 106 */
|
||||
CmdRestoreOrderIndex, /* 107 */
|
||||
CmdBuildLock, /* 108 */
|
||||
CmdStartScenario, /* 109 */
|
||||
CmdBuildManySignals, /* 110 */
|
||||
//CmdDestroyIndustry, /* 109 */
|
||||
CmdDestroyCompanyHQ, /* 111 */
|
||||
CmdGiveMoney, /* 112 */
|
||||
CmdChangePatchSetting, /* 113 */
|
||||
};
|
||||
|
||||
/* This function range-checks a cmd, and checks if the cmd is not NULL */
|
||||
bool IsValidCommand(uint cmd)
|
||||
{
|
||||
cmd &= 0xFF;
|
||||
|
||||
return
|
||||
cmd < lengthof(_command_proc_table) &&
|
||||
_command_proc_table[cmd].proc != NULL;
|
||||
}
|
||||
|
||||
byte GetCommandFlags(uint cmd) {return _command_proc_table[cmd & 0xFF].flags;}
|
||||
|
||||
int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
|
||||
{
|
||||
return DoCommand(TileX(tile) * 16, TileY(tile) * 16, p1, p2, flags, procc);
|
||||
return DoCommand(GET_TILE_X(tile)*16, GET_TILE_Y(tile)*16, p1, p2, flags, procc);
|
||||
}
|
||||
|
||||
|
||||
static int _docommand_recursive;
|
||||
//extern void _stdcall Sleep(int s);
|
||||
|
||||
int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
|
||||
{
|
||||
int32 res;
|
||||
CommandProc *proc;
|
||||
|
||||
/* Do not even think about executing out-of-bounds tile-commands */
|
||||
if (TileVirtXY(x, y) >= MapSize()) {
|
||||
_cmd_text = NULL;
|
||||
return CMD_ERROR;
|
||||
proc = _command_proc_table[procc];
|
||||
|
||||
if (_docommand_recursive == 0) {
|
||||
_error_message = INVALID_STRING_ID;
|
||||
// update last build coord of player
|
||||
if ( (x|y) != 0 && _current_player < MAX_PLAYERS) {
|
||||
DEREF_PLAYER(_current_player)->last_build_coordinate = TILE_FROM_XY(x,y);
|
||||
}
|
||||
}
|
||||
|
||||
proc = _command_proc_table[procc].proc;
|
||||
|
||||
if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID;
|
||||
|
||||
_docommand_recursive++;
|
||||
|
||||
// only execute the test call if it's toplevel, or we're not execing.
|
||||
if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
|
||||
res = proc(x, y, flags&~DC_EXEC, p1, p2);
|
||||
if (CmdFailed(res)) {
|
||||
if ((uint32)res >> 16 == 0x8000) {
|
||||
if (res & 0xFFFF) _error_message = res & 0xFFFF;
|
||||
goto error;
|
||||
}
|
||||
@@ -355,40 +349,33 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
|
||||
|
||||
if (!(flags & DC_EXEC)) {
|
||||
_docommand_recursive--;
|
||||
_cmd_text = NULL;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/* Execute the command here. All cost-relevant functions set the expenses type
|
||||
* themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
|
||||
// execute the command here.
|
||||
_yearly_expenses_type = 0;
|
||||
res = proc(x, y, flags, p1, p2);
|
||||
if (CmdFailed(res)) {
|
||||
if ((uint32)res >> 16 == 0x8000) {
|
||||
if (res & 0xFFFF) _error_message = res & 0xFFFF;
|
||||
error:
|
||||
_docommand_recursive--;
|
||||
_cmd_text = NULL;
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
// if toplevel, subtract the money.
|
||||
if (--_docommand_recursive == 0) {
|
||||
SubtractMoneyFromPlayer(res);
|
||||
// XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player
|
||||
if ( (x|y) != 0 && _current_player < MAX_PLAYERS) {
|
||||
GetPlayer(_current_player)->last_build_coordinate = TileVirtXY(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
_cmd_text = NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
int32 GetAvailableMoneyForCommand(void)
|
||||
int32 GetAvailableMoneyForCommand()
|
||||
{
|
||||
PlayerID pid = _current_player;
|
||||
uint pid = _current_player;
|
||||
if (pid >= MAX_PLAYERS) return 0x7FFFFFFF; // max int
|
||||
return GetPlayer(pid)->player_money;
|
||||
return DEREF_PLAYER(pid)->player_money;
|
||||
}
|
||||
|
||||
// toplevel network safe docommand function for the current player. must not be called recursively.
|
||||
@@ -400,14 +387,8 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
uint32 flags;
|
||||
bool notest;
|
||||
|
||||
int x = TileX(tile) * 16;
|
||||
int y = TileY(tile) * 16;
|
||||
|
||||
/* Do not even think about executing out-of-bounds tile-commands */
|
||||
if (tile >= MapSize()) {
|
||||
_cmd_text = NULL;
|
||||
return false;
|
||||
}
|
||||
int x = GET_TILE_X(tile)*16;
|
||||
int y = GET_TILE_Y(tile)*16;
|
||||
|
||||
assert(_docommand_recursive == 0);
|
||||
|
||||
@@ -415,11 +396,9 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
_error_message_2 = cmd >> 16;
|
||||
_additional_cash_required = 0;
|
||||
|
||||
/** Spectator has no rights except for the dedicated server which
|
||||
* is a spectator but is the server, so can do anything */
|
||||
if (_current_player == OWNER_SPECTATOR && !_network_dedicated) {
|
||||
// spectator has no rights.
|
||||
if (_current_player == OWNER_SPECTATOR) {
|
||||
ShowErrorMessage(_error_message, _error_message_2, x, y);
|
||||
_cmd_text = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -429,13 +408,9 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
|
||||
// get pointer to command handler
|
||||
assert((cmd & 0xFF) < lengthof(_command_proc_table));
|
||||
proc = _command_proc_table[cmd & 0xFF].proc;
|
||||
if (proc == NULL) {
|
||||
_cmd_text = NULL;
|
||||
return false;
|
||||
}
|
||||
proc = _command_proc_table[cmd & 0xFF];
|
||||
|
||||
// Some commands have a different output in dryrun than the realrun
|
||||
// Some commands have a different output in dryrun then the realrun
|
||||
// e.g.: if you demolish a whole town, the dryrun would say okay.
|
||||
// but by really destroying, your rating drops and at a certain point
|
||||
// it will fail. so res and res2 are different
|
||||
@@ -448,16 +423,15 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
(cmd & 0xFF) == CMD_CLEAR_AREA ||
|
||||
(cmd & 0xFF) == CMD_CONVERT_RAIL ||
|
||||
(cmd & 0xFF) == CMD_LEVEL_LAND ||
|
||||
(cmd & 0xFF) == CMD_REMOVE_ROAD ||
|
||||
(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD;
|
||||
(cmd & 0xFF) == CMD_REMOVE_ROAD;
|
||||
|
||||
_docommand_recursive = 1;
|
||||
|
||||
// cost estimation only?
|
||||
if (_shift_pressed && IsLocalPlayer() && !(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR))) {
|
||||
if (_shift_pressed && _current_player == _local_player && !(cmd & CMD_NETWORK_COMMAND)) {
|
||||
// estimate the cost.
|
||||
res = proc(x, y, flags, p1, p2);
|
||||
if (CmdFailed(res)) {
|
||||
if ((uint32)res >> 16 == 0x8000) {
|
||||
if (res & 0xFFFF) _error_message = res & 0xFFFF;
|
||||
ShowErrorMessage(_error_message, _error_message_2, x, y);
|
||||
} else {
|
||||
@@ -465,7 +439,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
}
|
||||
|
||||
_docommand_recursive = 0;
|
||||
_cmd_text = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -473,7 +446,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
|
||||
// first test if the command can be executed.
|
||||
res = proc(x,y, flags, p1, p2);
|
||||
if (CmdFailed(res)) {
|
||||
if ((uint32)res >> 16 == 0x8000) {
|
||||
if (res & 0xFFFF) _error_message = res & 0xFFFF;
|
||||
goto show_error;
|
||||
}
|
||||
@@ -482,36 +455,28 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
/** If we are in network, and the command is not from the network
|
||||
* send it to the command-queue and abort execution
|
||||
* If we are a dedicated server temporarily switch local player, otherwise
|
||||
* the other parties won't be able to execute our command and will desync.
|
||||
* @todo Rewrite dedicated server to something more than a dirty hack!
|
||||
*/
|
||||
// If we are in network, and the command is not from the network
|
||||
// send it to the command-queue and abort execution
|
||||
if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
|
||||
if (_network_dedicated) _local_player = 0;
|
||||
NetworkSend_Command(tile, p1, p2, cmd, callback);
|
||||
if (_network_dedicated) _local_player = OWNER_SPECTATOR;
|
||||
_docommand_recursive = 0;
|
||||
_cmd_text = NULL;
|
||||
return true;
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
// update last build coordinate of player.
|
||||
if ( tile != 0 && _current_player < MAX_PLAYERS) GetPlayer(_current_player)->last_build_coordinate = tile;
|
||||
if ( tile != 0 && _current_player < MAX_PLAYERS) DEREF_PLAYER(_current_player)->last_build_coordinate = tile;
|
||||
|
||||
/* Actually try and execute the command. If no cost-type is given
|
||||
* use the construction one */
|
||||
_yearly_expenses_type = EXPENSES_CONSTRUCTION;
|
||||
// actually try and execute the command.
|
||||
_yearly_expenses_type = 0;
|
||||
res2 = proc(x,y, flags|DC_EXEC, p1, p2);
|
||||
|
||||
// If notest is on, it means the result of the test can be different than
|
||||
// If notest is on, it means the result of the test can be different then
|
||||
// the real command.. so ignore the test
|
||||
if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
|
||||
assert(res == res2); // sanity check
|
||||
} else {
|
||||
if (CmdFailed(res2)) {
|
||||
if ((uint32)res2 >> 16 == 0x8000) {
|
||||
if (res2 & 0xFFFF) _error_message = res2 & 0xFFFF;
|
||||
goto show_error;
|
||||
}
|
||||
@@ -519,7 +484,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
|
||||
SubtractMoneyFromPlayer(res2);
|
||||
|
||||
if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
|
||||
if (_current_player == _local_player && _game_mode != GM_EDITOR) {
|
||||
if (res2 != 0)
|
||||
ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2);
|
||||
if (_additional_cash_required) {
|
||||
@@ -532,18 +497,16 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
_docommand_recursive = 0;
|
||||
|
||||
if (callback) callback(true, tile, p1, p2);
|
||||
_cmd_text = NULL;
|
||||
return true;
|
||||
|
||||
show_error:
|
||||
// show error message if the command fails?
|
||||
if (IsLocalPlayer() && _error_message_2 != 0)
|
||||
if (_current_player == _local_player && _error_message_2 != 0)
|
||||
ShowErrorMessage(_error_message, _error_message_2, x,y);
|
||||
|
||||
callb_err:
|
||||
_docommand_recursive = 0;
|
||||
|
||||
if (callback) callback(false, tile, p1, p2);
|
||||
_cmd_text = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
@@ -26,7 +24,8 @@ enum {
|
||||
CMD_RENAME_WAYPOINT = 17,
|
||||
CMD_REMOVE_TRAIN_WAYPOINT = 18,
|
||||
|
||||
CMD_BUILD_ROAD_STOP = 21,
|
||||
CMD_BUILD_TRUCK_STATION = 19,
|
||||
CMD_BUILD_BUS_STATION = 21,
|
||||
CMD_BUILD_LONG_ROAD = 23,
|
||||
CMD_REMOVE_LONG_ROAD = 24,
|
||||
CMD_BUILD_ROAD = 25,
|
||||
@@ -58,7 +57,7 @@ enum {
|
||||
CMD_DELETE_ORDER = 44,
|
||||
CMD_INSERT_ORDER = 45,
|
||||
|
||||
CMD_CHANGE_SERVICE_INT = 46,
|
||||
CMD_CHANGE_TRAIN_SERVICE_INT = 46,
|
||||
|
||||
CMD_BUILD_INDUSTRY = 47,
|
||||
|
||||
@@ -81,6 +80,7 @@ enum {
|
||||
CMD_START_STOP_AIRCRAFT = 60,
|
||||
CMD_BUILD_AIRCRAFT = 61,
|
||||
CMD_SEND_AIRCRAFT_TO_HANGAR = 62,
|
||||
CMD_CHANGE_AIRCRAFT_SERVICE_INT = 63,
|
||||
CMD_REFIT_AIRCRAFT = 64,
|
||||
|
||||
CMD_PLACE_SIGN = 65,
|
||||
@@ -91,6 +91,7 @@ enum {
|
||||
CMD_SELL_ROAD_VEH = 69,
|
||||
CMD_SEND_ROADVEH_TO_DEPOT = 70,
|
||||
CMD_TURN_ROADVEH = 71,
|
||||
CMD_CHANGE_ROADVEH_SERVICE_INT = 72,
|
||||
|
||||
CMD_PAUSE = 73,
|
||||
|
||||
@@ -104,6 +105,8 @@ enum {
|
||||
CMD_DO_TOWN_ACTION = 81,
|
||||
|
||||
CMD_SET_ROAD_DRIVE_SIDE = 82,
|
||||
CMD_SET_TOWN_NAME_TYPE = 83,
|
||||
|
||||
|
||||
CMD_CHANGE_DIFFICULTY_LEVEL = 85,
|
||||
|
||||
@@ -111,11 +114,23 @@ enum {
|
||||
CMD_SELL_SHIP = 87,
|
||||
CMD_BUILD_SHIP = 88,
|
||||
CMD_SEND_SHIP_TO_DEPOT = 89,
|
||||
CMD_CHANGE_SHIP_SERVICE_INT = 90,
|
||||
CMD_REFIT_SHIP = 91,
|
||||
|
||||
CMD_START_NEW_GAME = 92,
|
||||
CMD_LOAD_GAME = 93,
|
||||
CMD_CREATE_SCENARIO = 94,
|
||||
CMD_SET_SINGLE_PLAYER = 95,
|
||||
|
||||
CMD_SET_NEW_LANDSCAPE_TYPE = 97,
|
||||
|
||||
CMD_GEN_RANDOM_NEW_GAME = 98,
|
||||
|
||||
CMD_CLONE_ORDER = 99,
|
||||
CMD_CLEAR_AREA = 100,
|
||||
|
||||
CMD_RESUME = 101,
|
||||
|
||||
CMD_MONEY_CHEAT = 102,
|
||||
CMD_BUILD_CANAL = 103,
|
||||
|
||||
@@ -126,16 +141,13 @@ enum {
|
||||
CMD_RESTORE_ORDER_INDEX = 107,
|
||||
CMD_BUILD_LOCK = 108,
|
||||
|
||||
CMD_BUILD_SIGNAL_TRACK = 110,
|
||||
CMD_REMOVE_SIGNAL_TRACK = 111,
|
||||
|
||||
CMD_GIVE_MONEY = 113,
|
||||
CMD_CHANGE_PATCH_SETTING = 114,
|
||||
|
||||
CMD_REPLACE_VEHICLE = 115,
|
||||
|
||||
CMD_CLONE_VEHICLE = 116,
|
||||
CMD_START_SCENARIO = 109,
|
||||
CMD_BUILD_MANY_SIGNALS = 110,
|
||||
|
||||
//CMD_DESTROY_INDUSTRY = 109,
|
||||
CMD_DESTROY_COMPANY_HQ = 111,
|
||||
CMD_GIVE_MONEY = 112,
|
||||
CMD_CHANGE_PATCH_SETTING = 113,
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -158,44 +170,15 @@ enum {
|
||||
CMD_NO_WATER = 0x400,
|
||||
CMD_NETWORK_COMMAND = 0x800, // execute the command without sending it on the network
|
||||
CMD_NO_TEST_IF_IN_NETWORK = 0x1000, // When enabled, the command will bypass the no-DC_EXEC round if in network
|
||||
CMD_SHOW_NO_ERROR = 0x2000,
|
||||
};
|
||||
|
||||
/** Command flags for the command table
|
||||
* @see _command_proc_table
|
||||
*/
|
||||
enum {
|
||||
CMD_SERVER = 0x1, /// the command can only be initiated by the server
|
||||
CMD_OFFLINE = 0x2, /// the command cannot be executed in a multiplayer game; single-player only
|
||||
};
|
||||
|
||||
typedef struct Command {
|
||||
CommandProc *proc;
|
||||
byte flags;
|
||||
} Command;
|
||||
|
||||
//#define return_cmd_error(errcode) do { _error_message=(errcode); return CMD_ERROR; } while(0)
|
||||
#define return_cmd_error(errcode) do { return CMD_ERROR | (errcode); } while (0)
|
||||
|
||||
/**
|
||||
* Check the return value of a DoCommand*() function
|
||||
* @param res the resulting value from the command to be checked
|
||||
* @return Return true if the command failed, false otherwise
|
||||
*/
|
||||
static inline bool CmdFailed(int32 res)
|
||||
{
|
||||
// lower 16bits are the StringID of the possible error
|
||||
return res <= (CMD_ERROR | INVALID_STRING_ID);
|
||||
}
|
||||
|
||||
/* command.c */
|
||||
int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc);
|
||||
int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
|
||||
|
||||
extern const char* _cmd_text; // Text, which gets sent with a command
|
||||
|
||||
bool IsValidCommand(uint cmd);
|
||||
byte GetCommandFlags(uint cmd);
|
||||
int32 GetAvailableMoneyForCommand(void);
|
||||
int32 GetAvailableMoneyForCommand();
|
||||
|
||||
#endif /* COMMAND_H */
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This 'configure' script is a very easy wrapper around 'make updateconf'
|
||||
# It allows cross-compilers to do their job much more easy.
|
||||
|
||||
function showhelp() {
|
||||
echo "Configure for OpenTTD"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " $0 --your_options"
|
||||
echo ""
|
||||
echo "Params:"
|
||||
echo " --debug Create debug-release [no]"
|
||||
echo " --profile Create profile-release [no]"
|
||||
echo " --dedicated Make a dedicated build [no]"
|
||||
echo " --revision Set the revision of the compilation [detected]"
|
||||
echo " --target-cc Sets the target-compiler [\$CC]"
|
||||
echo " --target-cxx Sets the C++ target-compiler []"
|
||||
echo " --host-cc Sets the host-compiler [\$CC]"
|
||||
echo " --os Sets the OS. Listens to: [detected]"
|
||||
echo " UNIX, OSX, FREEBSD, MORPHOS"
|
||||
echo " BEOS, SUNOS, CYGWIN, MINGW"
|
||||
echo " --windres Sets the windres (Windows) [windres]"
|
||||
echo " --force-le Force LE platform [no]"
|
||||
echo " --force-be Force BE platform [no]"
|
||||
echo ""
|
||||
echo "Params that can be used with --with or --without"
|
||||
echo " (e.g.: --without-static disables static (default))"
|
||||
echo " static Do you want a static build? [no]"
|
||||
echo " directmusic Do you want direct-music? [no]"
|
||||
echo " zlib Do you want zlib-support? [yes]"
|
||||
echo " sdl Do you want SDL-support? [yes]"
|
||||
echo " png Do you want PNG-support? [yes]"
|
||||
echo " cocoa Do you want cocoa-support? (MacOSX) [no]"
|
||||
echo ""
|
||||
echo "Params used to configure external libs:"
|
||||
echo " --static-zlib-path Set the path to your static zlib []"
|
||||
echo " --sdl-config Where is your sdl-config [sdl-config]"
|
||||
echo " --libpng-config Where is your libpng-config [libpng-config]"
|
||||
echo " "
|
||||
}
|
||||
|
||||
function handle() {
|
||||
PARAM="$PARAM \"$1=`awk 'BEGIN { FS="="; $0="'"$2"'"; print $2;}'`\""
|
||||
}
|
||||
|
||||
# The things you can use inside this case:
|
||||
# handle NAME VALUE - Sets the value to give the 'make upgradeconf'
|
||||
# Value is in form: tag=REAL_VALUE
|
||||
# ITEM="NAME" - Will set the value as above, only with the next param
|
||||
# SITEM="NAME" - Will set the var $NAME to the next param
|
||||
for n in "$@"
|
||||
do
|
||||
case "$n" in
|
||||
--help | -h)
|
||||
showhelp
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--debug)
|
||||
DEBUG_SET=1
|
||||
ITEM="DEBUG"
|
||||
;;
|
||||
--debug=*)
|
||||
handle "DEBUG" "$n"
|
||||
;;
|
||||
--profile)
|
||||
PARAM="$PARAM PROFILE=1"
|
||||
;;
|
||||
--dedicated)
|
||||
PARAM="$PARAM DEDICATED=1"
|
||||
;;
|
||||
--revision=*)
|
||||
RELEASE=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
|
||||
;;
|
||||
--revision)
|
||||
SITEM="RELEASE"
|
||||
;;
|
||||
--target-cc=*)
|
||||
handle "CC_TARGET" "$n"
|
||||
;;
|
||||
--target-cc)
|
||||
ITEM="CC_TARGET"
|
||||
;;
|
||||
--target-cxx=*)
|
||||
TARGET_CXX=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
|
||||
;;
|
||||
--target-cxx)
|
||||
SITEM="TARGET_CXX"
|
||||
;;
|
||||
--host-cc=*)
|
||||
handle CC_HOST "$n"
|
||||
;;
|
||||
--host-cc)
|
||||
ITEM="CC_HOST"
|
||||
;;
|
||||
--host-cflags=*)
|
||||
handle CFLAGS_HOST "$n"
|
||||
;;
|
||||
--host-cflags)
|
||||
ITEM="CFLAGS_HOST"
|
||||
;;
|
||||
--os=*)
|
||||
TARGET_OS=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
|
||||
;;
|
||||
--os)
|
||||
SITEM="TARGET_OS"
|
||||
;;
|
||||
--windres=*)
|
||||
handle WINDRES "$n"
|
||||
;;
|
||||
--windres)
|
||||
ITEM="WINDRES"
|
||||
;;
|
||||
--force-le)
|
||||
PARAM="$PARAM ENDIAN_FORCE=LE"
|
||||
;;
|
||||
--force-be)
|
||||
PARAM="$PARAM ENDIAN_FORCE=BE"
|
||||
;;
|
||||
|
||||
--with-static)
|
||||
PARAM="$PARAM STATIC=1"
|
||||
;;
|
||||
--without-static)
|
||||
PARAM="$PARAM STATIC="
|
||||
;;
|
||||
--with-directmusic)
|
||||
PARAM="$PARAM WITH_DIRECTMUSIC=1"
|
||||
;;
|
||||
--without-directmusic)
|
||||
PARAM="$PARAM WITH_DIRECTMUSIC="
|
||||
;;
|
||||
--with-zlib)
|
||||
PARAM="$PARAM WITH_ZLIB=1"
|
||||
;;
|
||||
--without-zlib)
|
||||
PARAM="$PARAM WITH_ZLIB="
|
||||
;;
|
||||
--with-sdl)
|
||||
PARAM="$PARAM WITH_SDL=1"
|
||||
;;
|
||||
--without-sdl)
|
||||
PARAM="$PARAM WITH_SDL="
|
||||
;;
|
||||
--with-png)
|
||||
PARAM="$PARAM WITH_PNG=1"
|
||||
;;
|
||||
--without-png)
|
||||
PARAM="$PARAM WITH_PNG="
|
||||
;;
|
||||
--with-cocoa)
|
||||
PARAM="$PARAM WITH_COCOA=1"
|
||||
;;
|
||||
--without-cocoa)
|
||||
PARAM="$PARAM WITH_COCOA="
|
||||
;;
|
||||
--static-zlib-path=*)
|
||||
handle STATIC_ZLIB_PATH "$n"
|
||||
;;
|
||||
--static-zlib-path)
|
||||
ITEM="STATIC_ZLIB_PATH"
|
||||
;;
|
||||
--sdl-config=*)
|
||||
handle SDL_CONFIG "$n"
|
||||
;;
|
||||
--sdl-config)
|
||||
ITEM="SDL_CONFIG"
|
||||
;;
|
||||
--libpng-config=*)
|
||||
handle LIBPNG_CONFIG "$n"
|
||||
;;
|
||||
--lib-png-config)
|
||||
ITEM="LIBPNG_CONFIG"
|
||||
;;
|
||||
|
||||
--*=*)
|
||||
echo -n "Unknown switch "
|
||||
echo `awk 'BEGIN { FS="="; $0="'"$n"'"; print $1;}'`
|
||||
exit 1
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown switch $n"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
if ! test -z "$ITEM"
|
||||
then
|
||||
PARAM="$PARAM $ITEM=\"$n\""
|
||||
ITEM="";
|
||||
elif ! test -z "$SITEM"
|
||||
then
|
||||
export $SITEM="$n"
|
||||
SITEM=""
|
||||
else
|
||||
echo "Unknown switch $n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ! test -z "$TARGET_OS"
|
||||
then
|
||||
TARGET_OS=`echo $TARGET_OS | tr '[:lower:]' '[:upper:]'`
|
||||
case "$TARGET_OS" in
|
||||
WIN32)
|
||||
PARAM="$PARAM WIN32=1"
|
||||
;;
|
||||
UNIX)
|
||||
PARAM="$PARAM UNIX=1"
|
||||
;;
|
||||
OSX)
|
||||
PARAM="$PARAM OSX=1 UNIX=1"
|
||||
;;
|
||||
FREEBSD)
|
||||
PARAM="$PARAM FREEBSD=1"
|
||||
;;
|
||||
MORPHOS)
|
||||
PARAM="$PARAM MORPHOS=1 UNIX=1"
|
||||
;;
|
||||
BEOS)
|
||||
PARAM="$PARAM BEOS=1 UNIX=1"
|
||||
;;
|
||||
SUNOS)
|
||||
PARAM="$PARAM SUNOS=1 UNIX=1"
|
||||
;;
|
||||
CYGWIN)
|
||||
PARAM="$PARAM CYGWIN=1 WIN32=1"
|
||||
;;
|
||||
MINGW)
|
||||
PARAM="$PARAM MINGW=1 WIN32=1"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown OS: $TARGET_OS"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
PARAM="$PARAM BYPASS_OS_DETECT=1"
|
||||
fi
|
||||
|
||||
if ! test -z "$DEBUG_SET"
|
||||
then
|
||||
if test -z "`echo $PARAM | grep "DEBUG="`"
|
||||
then
|
||||
# Someone did --debug, without assigning a value, assume 1
|
||||
PARAM="$PARAM DEBUG=1"
|
||||
fi
|
||||
fi
|
||||
|
||||
# First remove the Makefile.config, else you can have double entries
|
||||
if test -e "Makefile.config"
|
||||
then
|
||||
rm -f Makefile.config
|
||||
fi
|
||||
|
||||
echo "make upgradeconf $PARAM" > Makefile.run
|
||||
. Makefile.run
|
||||
rm -f Makefile.run
|
||||
|
||||
# Makefile.config currently doesn't support custom CXX, so, we add the line
|
||||
# ourself!
|
||||
|
||||
if ! test -z "$TARGET_CXX"
|
||||
then
|
||||
echo "CXX=$TARGET_CXX" >> Makefile.config
|
||||
fi
|
||||
|
||||
# Same for RELEASE (read: REVISION)
|
||||
|
||||
if ! test -z "$RELEASE"
|
||||
then
|
||||
echo "RELEASE=$RELEASE" >> Makefile.config
|
||||
fi
|
||||
|
||||
@@ -1,160 +1,159 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
// maximum length of a typed in command
|
||||
#define ICON_CMDLN_SIZE 255
|
||||
// maximum length of a totally expanded command
|
||||
#define ICON_MAX_STREAMSIZE 1024
|
||||
// ** console parser ** //
|
||||
|
||||
typedef enum IConsoleVarTypes {
|
||||
typedef enum _iconsole_var_types {
|
||||
ICONSOLE_VAR_NONE,
|
||||
ICONSOLE_VAR_BOOLEAN,
|
||||
ICONSOLE_VAR_BYTE,
|
||||
ICONSOLE_VAR_UINT8,
|
||||
ICONSOLE_VAR_UINT16,
|
||||
ICONSOLE_VAR_UINT32,
|
||||
ICONSOLE_VAR_INT16,
|
||||
ICONSOLE_VAR_INT32,
|
||||
ICONSOLE_VAR_STRING
|
||||
} IConsoleVarTypes;
|
||||
ICONSOLE_VAR_STRING,
|
||||
ICONSOLE_VAR_POINTER,
|
||||
ICONSOLE_VAR_REFERENCE,
|
||||
ICONSOLE_VAR_UNKNOWN
|
||||
} _iconsole_var_types;
|
||||
|
||||
typedef enum IConsoleModes {
|
||||
typedef enum {
|
||||
ICONSOLE_FULL,
|
||||
ICONSOLE_OPENED,
|
||||
ICONSOLE_CLOSED
|
||||
} IConsoleModes;
|
||||
} _iconsole_modes;
|
||||
|
||||
typedef enum IConsoleHookTypes {
|
||||
typedef enum _iconsole_hook_types {
|
||||
ICONSOLE_HOOK_ACCESS,
|
||||
ICONSOLE_HOOK_PRE_ACTION,
|
||||
ICONSOLE_HOOK_POST_ACTION
|
||||
} IConsoleHookTypes;
|
||||
ICONSOLE_HOOK_BEFORE_CHANGE,
|
||||
ICONSOLE_HOOK_BEFORE_EXEC,
|
||||
ICONSOLE_HOOK_AFTER_CHANGE,
|
||||
ICONSOLE_HOOK_AFTER_EXEC
|
||||
} _iconsole_hook_types;
|
||||
|
||||
/** --Hooks--
|
||||
* Hooks are certain triggers get get accessed/executed on either
|
||||
* access, before execution/change or after execution/change. This allows
|
||||
* for general flow of permissions or special action needed in some cases
|
||||
*/
|
||||
typedef bool IConsoleHook(void);
|
||||
typedef struct IConsoleHooks{
|
||||
IConsoleHook *access; // trigger when accessing the variable/command
|
||||
IConsoleHook *pre; // trigger before the variable/command is changed/executed
|
||||
IConsoleHook *post; // trigger after the variable/command is changed/executed
|
||||
} IConsoleHooks;
|
||||
struct _iconsole_var;
|
||||
typedef bool (*iconsole_var_hook)(struct _iconsole_var* hook_var);
|
||||
|
||||
/** --Commands--
|
||||
* Commands are commands, or functions. They get executed once and any
|
||||
* effect they produce are carried out. The arguments to the commands
|
||||
* are given to them, each input word seperated by a double-quote (") is an argument
|
||||
* If you want to handle multiple words as one, enclose them in double-quotes
|
||||
* eg. 'say "hello sexy boy"'
|
||||
*/
|
||||
typedef bool (IConsoleCmdProc)(byte argc, char *argv[]);
|
||||
typedef struct _iconsole_var {
|
||||
// --------------- //
|
||||
union {
|
||||
void* addr;
|
||||
bool* bool_;
|
||||
byte* byte_;
|
||||
uint16* uint16_;
|
||||
uint32* uint32_;
|
||||
int16* int16_;
|
||||
int32* int32_;
|
||||
char* string_;
|
||||
struct _iconsole_var* reference_;
|
||||
} data;
|
||||
char* name;
|
||||
_iconsole_var_types type;
|
||||
// -------------- //
|
||||
iconsole_var_hook hook_access;
|
||||
iconsole_var_hook hook_before_change;
|
||||
iconsole_var_hook hook_after_change;
|
||||
// -------------- //
|
||||
struct _iconsole_var* _next;
|
||||
bool _malloc;
|
||||
} _iconsole_var;
|
||||
|
||||
struct IConsoleCmd;
|
||||
typedef struct IConsoleCmd {
|
||||
char *name; // name of command
|
||||
struct IConsoleCmd *next; // next command in list
|
||||
struct _iconsole_cmd;
|
||||
typedef bool (*iconsole_cmd_hook)(struct _iconsole_cmd* hook_cmd);
|
||||
|
||||
IConsoleCmdProc *proc; // process executed when command is typed
|
||||
IConsoleHooks hook; // any special trigger action that needs executing
|
||||
} IConsoleCmd;
|
||||
typedef _iconsole_var* (*_iconsole_cmd_addr)(byte argc, char* argv[], byte argt[]);
|
||||
|
||||
/** --Variables--
|
||||
* Variables are pointers to real ingame variables which allow for
|
||||
* changing while ingame. After changing they keep their new value
|
||||
* and can be used for debugging, gameplay, etc. It accepts:
|
||||
* - no arguments; just print out current value
|
||||
* - '= <new value>' to assign a new value to the variable
|
||||
* - '++' to increase value by one
|
||||
* - '--' to decrease value by one
|
||||
*/
|
||||
struct IConsoleVar;
|
||||
typedef struct IConsoleVar {
|
||||
char *name; // name of the variable
|
||||
struct IConsoleVar *next; // next variable in list
|
||||
typedef struct _iconsole_cmd {
|
||||
// -------------- //
|
||||
_iconsole_cmd_addr addr;
|
||||
char* name;
|
||||
// -------------- //
|
||||
iconsole_cmd_hook hook_access;
|
||||
iconsole_cmd_hook hook_before_exec;
|
||||
iconsole_cmd_hook hook_after_exec;
|
||||
// -------------- //
|
||||
void* _next;
|
||||
} _iconsole_cmd;
|
||||
|
||||
void *addr; // the address where the variable is pointing at
|
||||
uint32 size; // size of the variable, used for strings
|
||||
char *help; // the optional help string shown when requesting information
|
||||
IConsoleVarTypes type; // type of variable (for correct assignment/output)
|
||||
IConsoleCmdProc *proc; // some variables need really special handling, use a callback function for that
|
||||
IConsoleHooks hook; // any special trigger action that needs executing
|
||||
} IConsoleVar;
|
||||
void IConsoleAliasRegister(const char* name, const char* cmdline);
|
||||
|
||||
/** --Aliases--
|
||||
* Aliases are like shortcuts for complex functions, variable assignments,
|
||||
* etc. You can use a simple alias to rename a longer command (eg 'lv' for
|
||||
* 'list_vars' for example), or concatenate more commands into one
|
||||
* (eg. 'ng' for 'load %A; unpause; debug_level 5'). Aliases can parse the arguments
|
||||
* given to them in the command line.
|
||||
* - "%A - %Z" substitute arguments 1 t/m 26
|
||||
* - "%+" lists all parameters keeping them seperated
|
||||
* - "%!" also lists all parameters but presenting them to the aliased command as one argument
|
||||
* - ";" allows for combining commands (see example 'ng')
|
||||
*/
|
||||
struct IConsoleAlias;
|
||||
typedef struct IConsoleAlias {
|
||||
char *name; // name of the alias
|
||||
struct IConsoleAlias *next; // next alias in list
|
||||
typedef struct _iconsole_alias {
|
||||
// -------------- //
|
||||
char * cmdline;
|
||||
char* name;
|
||||
void* _next;
|
||||
} _iconsole_alias;
|
||||
|
||||
char *cmdline; // command(s) that is/are being aliased
|
||||
} IConsoleAlias;
|
||||
_iconsole_alias* IConsoleAliasGet(const char* name);
|
||||
|
||||
// ** console parser ** //
|
||||
IConsoleCmd *_iconsole_cmds; // list of registred commands
|
||||
IConsoleVar *_iconsole_vars; // list of registred vars
|
||||
IConsoleAlias *_iconsole_aliases; // list of registred aliases
|
||||
|
||||
// ** console colors/modes ** //
|
||||
VARDEF byte _icolour_def;
|
||||
VARDEF byte _icolour_err;
|
||||
VARDEF byte _icolour_warn;
|
||||
VARDEF byte _icolour_dbg;
|
||||
VARDEF byte _icolour_cmd;
|
||||
VARDEF IConsoleModes _iconsole_mode;
|
||||
_iconsole_cmd* _iconsole_cmds; // list of registred commands
|
||||
_iconsole_var* _iconsole_vars; // list of registred vars
|
||||
_iconsole_alias* _iconsole_aliases; // list of registred aliases
|
||||
|
||||
// ** console colors ** //
|
||||
VARDEF byte _iconsole_color_default;
|
||||
VARDEF byte _iconsole_color_error;
|
||||
VARDEF byte _iconsole_color_warning;
|
||||
VARDEF byte _iconsole_color_debug;
|
||||
VARDEF byte _iconsole_color_commands;
|
||||
VARDEF _iconsole_modes _iconsole_mode;
|
||||
|
||||
// ** ttd.c functions ** //
|
||||
|
||||
void SetDebugString(const char* s);
|
||||
|
||||
// ** console functions ** //
|
||||
|
||||
void IConsoleInit(void);
|
||||
void IConsoleClear(void);
|
||||
void IConsoleFree(void);
|
||||
void IConsoleClearBuffer(void);
|
||||
void IConsoleResize(void);
|
||||
void IConsoleSwitch(void);
|
||||
void IConsoleClose(void);
|
||||
void IConsoleOpen(void);
|
||||
|
||||
// ** console cmd buffer ** //
|
||||
void IConsoleCmdBufferAdd(const char* cmd);
|
||||
void IConsoleCmdBufferNavigate(signed char direction);
|
||||
|
||||
// ** console output ** //
|
||||
void IConsolePrint(uint16 color_code, const char *string);
|
||||
void CDECL IConsolePrintF(uint16 color_code, const char *s, ...);
|
||||
void IConsoleDebug(const char *string);
|
||||
void IConsoleWarning(const char *string);
|
||||
void IConsoleError(const char *string);
|
||||
void IConsolePrint(uint16 color_code, const char* string);
|
||||
void CDECL IConsolePrintF(uint16 color_code, const char* s, ...);
|
||||
void IConsoleDebug(const char* string);
|
||||
void IConsoleError(const char* string);
|
||||
void IConsoleWarning(const char* string);
|
||||
|
||||
// *** Commands *** //
|
||||
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc);
|
||||
void IConsoleAliasRegister(const char *name, const char *cmd);
|
||||
IConsoleCmd *IConsoleCmdGet(const char *name);
|
||||
IConsoleAlias *IConsoleAliasGet(const char *name);
|
||||
|
||||
void IConsoleCmdRegister(const char* name, _iconsole_cmd_addr addr);
|
||||
_iconsole_cmd* IConsoleCmdGet(const char* name);
|
||||
|
||||
// *** Variables *** //
|
||||
void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help);
|
||||
void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help);
|
||||
IConsoleVar* IConsoleVarGet(const char *name);
|
||||
void IConsoleVarPrintGetValue(const IConsoleVar *var);
|
||||
void IConsoleVarPrintSetValue(const IConsoleVar *var);
|
||||
|
||||
void IConsoleVarRegister(const char* name, void* addr, _iconsole_var_types type);
|
||||
void IConsoleVarMemRegister(const char* name, _iconsole_var_types type);
|
||||
void IConsoleVarInsert(_iconsole_var* item_new, const char* name);
|
||||
_iconsole_var* IConsoleVarGet(const char* name);
|
||||
_iconsole_var* IConsoleVarAlloc(_iconsole_var_types type);
|
||||
void IConsoleVarFree(_iconsole_var* var);
|
||||
void IConsoleVarSetString(_iconsole_var* var, const char* string);
|
||||
void IConsoleVarSetValue(_iconsole_var* var, int value);
|
||||
void IConsoleVarDump(const _iconsole_var* var, const char* dump_desc);
|
||||
|
||||
// *** Parser *** //
|
||||
void IConsoleCmdExec(const char *cmdstr);
|
||||
void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[]);
|
||||
|
||||
// ** console std lib (register ingame commands/aliases/variables) ** //
|
||||
void IConsoleCmdExec(const char* cmdstr);
|
||||
|
||||
// ** console std lib ** //
|
||||
void IConsoleStdLibRegister(void);
|
||||
|
||||
// ** Hooking code ** //
|
||||
void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
|
||||
void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
|
||||
void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc);
|
||||
// ** hook code ** //
|
||||
void IConsoleVarHook(const char* name, _iconsole_hook_types type, iconsole_var_hook proc);
|
||||
void IConsoleCmdHook(const char* name, _iconsole_hook_types type, iconsole_cmd_hook proc);
|
||||
bool IConsoleVarHookHandle(_iconsole_var* hook_var, _iconsole_hook_types type);
|
||||
bool IConsoleCmdHookHandle(_iconsole_cmd* hook_cmd, _iconsole_hook_types type);
|
||||
|
||||
// ** Supporting functions **//
|
||||
bool GetArgumentInteger(uint32 *value, const char *arg);
|
||||
#endif /* CONSOLE_H */
|
||||
|
||||
+666
-1161
File diff suppressed because it is too large
Load Diff
-100
@@ -1,100 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "currency.h"
|
||||
#include "news.h"
|
||||
#include "variables.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
// exchange rate prefix
|
||||
// | separator | postfix
|
||||
// | | Euro year | |
|
||||
// | | | | |
|
||||
CurrencySpec _currency_specs[] = {
|
||||
{ 1, ',', CF_NOEURO, "\xA3", "" }, // british pounds
|
||||
{ 2, ',', CF_NOEURO, "$", "" }, // us dollars
|
||||
{ 2, ',', CF_ISEURO, "¤", "" }, // Euro
|
||||
{ 200, ',', CF_NOEURO, "\xA5", "" }, // yen
|
||||
{ 19, ',', 2002, "", " S." }, // austrian schilling
|
||||
{ 57, ',', 2002, "BEF ", "" }, // belgian franc
|
||||
{ 2, ',', CF_NOEURO, "CHF ", "" }, // swiss franc
|
||||
{ 50, ',', CF_NOEURO, "", " Kc" }, // czech koruna // TODO: Should use the "c" with an upside down "^"
|
||||
{ 4, '.', 2002, "DM ", "" }, // deutsche mark
|
||||
{ 10, '.', CF_NOEURO, "", " kr" }, // danish krone
|
||||
{ 200, '.', 2002, "Pts ", "" }, // spanish pesetas
|
||||
{ 8, ',', 2002, "", " mk" }, // finnish markka
|
||||
{ 10, '.', 2002, "FF ", "" }, // french francs
|
||||
{ 480, ',', 2002, "", "Dr." }, // greek drachma
|
||||
{ 376, ',', 2002, "", " Ft" }, // hungarian forint
|
||||
{ 130, '.', CF_NOEURO, "", " Kr" }, // icelandic krona
|
||||
{ 2730, ',', 2002, "", " L." }, // italian lira
|
||||
{ 3, ',', 2002, "NLG ", "" }, // dutch gulden
|
||||
{ 11, '.', CF_NOEURO, "", " Kr" }, // norwegian krone
|
||||
{ 6, ' ', CF_NOEURO, "", " zl" }, // polish zloty
|
||||
{ 6, '.', CF_NOEURO, "", " Lei" }, // romanian Lei
|
||||
{ 5, ' ', CF_NOEURO, "", " p" }, // russian rouble
|
||||
{ 13, '.', CF_NOEURO, "", " Kr" }, // swedish krona
|
||||
{ 1, ' ', CF_NOEURO, "", "" }, // custom currency
|
||||
};
|
||||
|
||||
const StringID _currency_string_list[] = {
|
||||
STR_CURR_GBP,
|
||||
STR_CURR_USD,
|
||||
STR_CURR_EUR,
|
||||
STR_CURR_YEN,
|
||||
STR_CURR_ATS,
|
||||
STR_CURR_BEF,
|
||||
STR_CURR_CHF,
|
||||
STR_CURR_CZK,
|
||||
STR_CURR_DEM,
|
||||
STR_CURR_DKK,
|
||||
STR_CURR_ESP,
|
||||
STR_CURR_FIM,
|
||||
STR_CURR_FRF,
|
||||
STR_CURR_GRD,
|
||||
STR_CURR_HUF,
|
||||
STR_CURR_ISK,
|
||||
STR_CURR_ITL,
|
||||
STR_CURR_NLG,
|
||||
STR_CURR_NOK,
|
||||
STR_CURR_PLN,
|
||||
STR_CURR_ROL,
|
||||
STR_CURR_RUR,
|
||||
STR_CURR_SEK,
|
||||
STR_CURR_CUSTOM,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
// NOTE: Make sure both lists are in the same order
|
||||
// + 1 string list terminator
|
||||
assert_compile(lengthof(_currency_specs) + 1 == lengthof(_currency_string_list));
|
||||
|
||||
|
||||
// get a mask of the allowed currencies depending on the year
|
||||
uint GetMaskOfAllowedCurrencies(void)
|
||||
{
|
||||
uint mask = 0;
|
||||
uint i;
|
||||
|
||||
for (i = 0; i != lengthof(_currency_specs); i++) {
|
||||
uint16 to_euro = _currency_specs[i].to_euro;
|
||||
|
||||
if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= to_euro - MAX_YEAR_BEGIN_REAL) continue;
|
||||
if (to_euro == CF_ISEURO && _cur_year < 2000 - MAX_YEAR_BEGIN_REAL) continue;
|
||||
mask |= (1 << i);
|
||||
}
|
||||
mask |= (1 << 23); // always allow custom currency
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
void CheckSwitchToEuro(void)
|
||||
{
|
||||
if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
|
||||
_currency_specs[_opt.currency].to_euro != CF_ISEURO &&
|
||||
MAX_YEAR_BEGIN_REAL + _cur_year >= _currency_specs[_opt.currency].to_euro) {
|
||||
_opt.currency = 2; // this is the index of euro above.
|
||||
AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0);
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef CURRENCY_H
|
||||
#define CURRENCY_H
|
||||
|
||||
enum {
|
||||
CF_NOEURO = 0,
|
||||
CF_ISEURO = 1,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint16 rate;
|
||||
char separator;
|
||||
uint16 to_euro;
|
||||
char prefix[16];
|
||||
char suffix[16];
|
||||
} CurrencySpec;
|
||||
|
||||
extern CurrencySpec _currency_specs[];
|
||||
extern const StringID _currency_string_list[];
|
||||
|
||||
// XXX small hack, but makes the rest of the code a bit nicer to read
|
||||
#define _custom_currency (_currency_specs[23])
|
||||
#define _currency ((const CurrencySpec*)&_currency_specs[_opt_ptr->currency])
|
||||
|
||||
uint GetMaskOfAllowedCurrencies(void);
|
||||
void CheckSwitchToEuro(void);
|
||||
|
||||
#endif /* CURRENCY_H */
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,126 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "openttd.h"
|
||||
#include "console.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "string.h"
|
||||
|
||||
int _debug_ai_level;
|
||||
int _debug_driver_level;
|
||||
int _debug_grf_level;
|
||||
int _debug_map_level;
|
||||
int _debug_misc_level;
|
||||
int _debug_ms_level;
|
||||
int _debug_net_level;
|
||||
int _debug_spritecache_level;
|
||||
int _debug_oldloader_level;
|
||||
int _debug_ntp_level;
|
||||
int _debug_npf_level;
|
||||
|
||||
|
||||
void CDECL debug(const char *s, ...)
|
||||
{
|
||||
va_list va;
|
||||
char buf[1024];
|
||||
|
||||
va_start(va, s);
|
||||
vsnprintf(buf, lengthof(buf), s, va);
|
||||
va_end(va);
|
||||
fprintf(stderr, "dbg: %s\n", buf);
|
||||
IConsoleDebug(buf);
|
||||
}
|
||||
|
||||
typedef struct DebugLevel {
|
||||
const char *name;
|
||||
int *level;
|
||||
} DebugLevel;
|
||||
|
||||
#define DEBUG_LEVEL(x) { #x, &_debug_##x##_level }
|
||||
static const DebugLevel debug_level[] = {
|
||||
DEBUG_LEVEL(ai),
|
||||
DEBUG_LEVEL(driver),
|
||||
DEBUG_LEVEL(grf),
|
||||
DEBUG_LEVEL(map),
|
||||
DEBUG_LEVEL(misc),
|
||||
DEBUG_LEVEL(ms),
|
||||
DEBUG_LEVEL(net),
|
||||
DEBUG_LEVEL(spritecache),
|
||||
DEBUG_LEVEL(oldloader),
|
||||
DEBUG_LEVEL(ntp),
|
||||
DEBUG_LEVEL(npf)
|
||||
};
|
||||
#undef DEBUG_LEVEL
|
||||
|
||||
void SetDebugString(const char *s)
|
||||
{
|
||||
int v;
|
||||
char *end;
|
||||
const char *t;
|
||||
|
||||
// global debugging level?
|
||||
if (*s >= '0' && *s <= '9') {
|
||||
const DebugLevel *i;
|
||||
|
||||
v = strtoul(s, &end, 0);
|
||||
s = end;
|
||||
|
||||
for (i = debug_level; i != endof(debug_level); ++i) *i->level = v;
|
||||
}
|
||||
|
||||
// individual levels
|
||||
for (;;) {
|
||||
const DebugLevel *i;
|
||||
int *p;
|
||||
|
||||
// skip delimiters
|
||||
while (*s == ' ' || *s == ',' || *s == '\t') s++;
|
||||
if (*s == '\0') break;
|
||||
|
||||
t = s;
|
||||
while (*s >= 'a' && *s <= 'z') s++;
|
||||
|
||||
// check debugging levels
|
||||
p = NULL;
|
||||
for (i = debug_level; i != endof(debug_level); ++i)
|
||||
if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
|
||||
p = i->level;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*s == '=') s++;
|
||||
v = strtoul(s, &end, 0);
|
||||
s = end;
|
||||
if (p != NULL) {
|
||||
*p = v;
|
||||
} else {
|
||||
ShowInfoF("Unknown debug level '%.*s'", s - t, t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Print out the current debug-level
|
||||
* Just return a string with the values of all the debug categorites
|
||||
* @return string with debug-levels
|
||||
*/
|
||||
const char *GetDebugString(void)
|
||||
{
|
||||
const DebugLevel *i;
|
||||
static char dbgstr[100];
|
||||
char dbgval[20];
|
||||
|
||||
memset(dbgstr, 0, sizeof(dbgstr));
|
||||
i = debug_level;
|
||||
snprintf(dbgstr, sizeof(dbgstr), "%s=%d", i->name, *i->level);
|
||||
|
||||
for (i++; i != endof(debug_level); i++) {
|
||||
snprintf(dbgval, sizeof(dbgval), ", %s=%d", i->name, *i->level);
|
||||
ttd_strlcat(dbgstr, dbgval, sizeof(dbgstr));
|
||||
}
|
||||
|
||||
return dbgstr;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#ifdef NO_DEBUG_MESSAGES
|
||||
#define DEBUG(name, level)
|
||||
#else
|
||||
#define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug
|
||||
|
||||
extern int _debug_ai_level;
|
||||
extern int _debug_driver_level;
|
||||
extern int _debug_grf_level;
|
||||
extern int _debug_map_level;
|
||||
extern int _debug_misc_level;
|
||||
extern int _debug_ms_level;
|
||||
extern int _debug_net_level;
|
||||
extern int _debug_spritecache_level;
|
||||
extern int _debug_oldloader_level;
|
||||
extern int _debug_ntp_level;
|
||||
extern int _debug_npf_level;
|
||||
#endif
|
||||
|
||||
void CDECL debug(const char *s, ...);
|
||||
|
||||
void SetDebugString(const char *s);
|
||||
const char *GetDebugString(void);
|
||||
|
||||
#endif /* DEBUG_H */
|
||||
+231
-21
@@ -1,58 +1,268 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ttd.h"
|
||||
#include "network.h"
|
||||
#include "hal.h"
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
#if defined(UNIX) && !defined(__MORPHOS__)
|
||||
#include "gfx.h"
|
||||
#include "window.h"
|
||||
#include "command.h"
|
||||
#include "console.h"
|
||||
#ifdef WIN32
|
||||
# include <windows.h> /* GetTickCount */
|
||||
# include <conio.h>
|
||||
#endif
|
||||
|
||||
#include "openttd.h"
|
||||
#include "variables.h"
|
||||
#ifdef __OS2__
|
||||
# include <sys/time.h> /* gettimeofday */
|
||||
# include <sys/types.h>
|
||||
# include <unistd.h>
|
||||
# include <conio.h>
|
||||
# define STDIN 0 /* file descriptor for standard input */
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#ifdef UNIX
|
||||
# include <sys/time.h> /* gettimeofday */
|
||||
# include <sys/types.h>
|
||||
# include <unistd.h>
|
||||
# include <signal.h>
|
||||
# define STDIN 0 /* file descriptor for standard input */
|
||||
#endif
|
||||
#ifdef __MORPHOS__
|
||||
/* voids the fork, option will be disabled for morphos build anyway, because MorphOS
|
||||
* doesn't support forking (could only implemented with lots of code changes here).
|
||||
*/
|
||||
int morphos_dummy_fork() { return -1; }
|
||||
#define fork morphos_dummy_fork
|
||||
#endif
|
||||
|
||||
// This file handles all dedicated-server in- and outputs
|
||||
|
||||
static void *_dedicated_video_mem;
|
||||
|
||||
#ifdef UNIX
|
||||
/* We want to fork our dedicated server */
|
||||
void DedicatedFork(void)
|
||||
{
|
||||
/* Fork the program */
|
||||
pid_t pid = fork();
|
||||
switch (pid) {
|
||||
_dedicated_pid = fork();
|
||||
switch (_dedicated_pid) {
|
||||
case -1:
|
||||
perror("Unable to fork");
|
||||
exit(1);
|
||||
|
||||
case 0: { // We're the child
|
||||
FILE* f;
|
||||
case 0:
|
||||
// We're the child
|
||||
|
||||
/* Open the log-file to log all stuff too */
|
||||
f = fopen(_log_file, "a");
|
||||
if (f == NULL) {
|
||||
_log_file_fd = fopen(_log_file, "a");
|
||||
if (!_log_file_fd) {
|
||||
perror("Unable to open logfile");
|
||||
exit(1);
|
||||
}
|
||||
/* Redirect stdout and stderr to log-file */
|
||||
if (dup2(fileno(f), fileno(stdout)) == -1) {
|
||||
perror("Rerouting stdout");
|
||||
if (dup2(fileno(_log_file_fd), fileno(stdout)) == -1) {
|
||||
perror("Re-routing stdout");
|
||||
exit(1);
|
||||
}
|
||||
if (dup2(fileno(f), fileno(stderr)) == -1) {
|
||||
perror("Rerouting stderr");
|
||||
if (dup2(fileno(_log_file_fd), fileno(stderr)) == -1) {
|
||||
perror("Re-routing stderr");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// We're the parent
|
||||
printf("Loading dedicated server...\n");
|
||||
printf(" - Forked to background with pid %d\n", pid);
|
||||
printf(" - Forked to background with pid %d\n", _dedicated_pid);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Signal handlers */
|
||||
static void DedicatedSignalHandler(int sig)
|
||||
{
|
||||
_exit_game = true;
|
||||
signal(sig, DedicatedSignalHandler);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *DedicatedVideoStart(char **parm) {
|
||||
_screen.width = _screen.pitch = _cur_resolution[0];
|
||||
_screen.height = _cur_resolution[1];
|
||||
_dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]);
|
||||
|
||||
_debug_net_level = 6;
|
||||
_debug_misc_level = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
// For win32 we need to allocate an console (debug mode does the same)
|
||||
CreateConsole();
|
||||
SetConsoleTitle("OpenTTD Dedicated Server");
|
||||
#endif
|
||||
|
||||
DEBUG(misc,0)("Loading dedicated server...");
|
||||
return NULL;
|
||||
}
|
||||
static void DedicatedVideoStop() { free(_dedicated_video_mem); }
|
||||
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {}
|
||||
static bool DedicatedVideoChangeRes(int w, int h) { return false; }
|
||||
|
||||
#ifdef UNIX
|
||||
|
||||
static bool InputWaiting()
|
||||
{
|
||||
struct timeval tv;
|
||||
fd_set readfds;
|
||||
byte ret;
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1;
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(STDIN, &readfds);
|
||||
|
||||
/* don't care about writefds and exceptfds: */
|
||||
ret = select(STDIN + 1, &readfds, NULL, NULL, &tv);
|
||||
|
||||
if (ret > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
static bool InputWaiting()
|
||||
{
|
||||
return kbhit();
|
||||
}
|
||||
#endif
|
||||
|
||||
static void DedicatedHandleKeyInput()
|
||||
{
|
||||
#ifdef WIN32
|
||||
char input;
|
||||
#endif
|
||||
static char input_line[200] = "";
|
||||
|
||||
#if defined(UNIX) || defined(__OS2__)
|
||||
if (InputWaiting()) {
|
||||
if (_exit_game)
|
||||
return;
|
||||
|
||||
fgets(input_line, 200, stdin);
|
||||
// Forget about the final \n (or \r)
|
||||
strtok(input_line, "\r\n");
|
||||
IConsoleCmdExec(input_line);
|
||||
}
|
||||
#else
|
||||
if (InputWaiting()) {
|
||||
input = getch();
|
||||
printf("%c", input);
|
||||
if (input != '\r')
|
||||
snprintf(input_line, 200, "%s%c", input_line, input);
|
||||
else {
|
||||
printf("\n");
|
||||
IConsoleCmdExec(input_line);
|
||||
input_line[0] = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int DedicatedVideoMainLoop()
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct timeval tim;
|
||||
#endif
|
||||
uint32 next_tick;
|
||||
uint32 cur_ticks;
|
||||
|
||||
#ifdef WIN32
|
||||
next_tick = GetTickCount() + 30;
|
||||
#else
|
||||
gettimeofday(&tim, NULL);
|
||||
next_tick = (tim.tv_usec / 1000) + 30 + (tim.tv_sec * 1000);
|
||||
#endif
|
||||
|
||||
/* Signal handlers */
|
||||
#ifdef UNIX
|
||||
signal(SIGTERM, DedicatedSignalHandler);
|
||||
signal(SIGINT, DedicatedSignalHandler);
|
||||
signal(SIGQUIT, DedicatedSignalHandler);
|
||||
#endif
|
||||
|
||||
// Load the dedicated server stuff
|
||||
_is_network_server = true;
|
||||
_network_dedicated = true;
|
||||
_switch_mode = SM_NONE;
|
||||
_network_playas = OWNER_SPECTATOR;
|
||||
_local_player = OWNER_SPECTATOR;
|
||||
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME);
|
||||
// Done loading, start game!
|
||||
|
||||
if (!_networking) {
|
||||
DEBUG(net, 1)("Dedicated server could not be launced. Aborting..");
|
||||
return ML_QUIT;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
InteractiveRandom(); // randomness
|
||||
|
||||
if (_exit_game) return ML_QUIT;
|
||||
|
||||
if (!_dedicated_forks)
|
||||
DedicatedHandleKeyInput();
|
||||
|
||||
#ifdef WIN32
|
||||
cur_ticks = GetTickCount();
|
||||
#else
|
||||
gettimeofday(&tim, NULL);
|
||||
cur_ticks = (tim.tv_usec / 1000) + (tim.tv_sec * 1000);
|
||||
#endif
|
||||
|
||||
if (cur_ticks >= next_tick) {
|
||||
next_tick += 30;
|
||||
|
||||
GameLoop();
|
||||
_screen.dst_ptr = _dedicated_video_mem;
|
||||
UpdateWindows();
|
||||
}
|
||||
CSleep(1);
|
||||
}
|
||||
|
||||
return ML_QUIT;
|
||||
}
|
||||
|
||||
|
||||
const HalVideoDriver _dedicated_video_driver = {
|
||||
DedicatedVideoStart,
|
||||
DedicatedVideoStop,
|
||||
DedicatedVideoMakeDirty,
|
||||
DedicatedVideoMainLoop,
|
||||
DedicatedVideoChangeRes,
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
static void *_dedicated_video_mem;
|
||||
|
||||
static const char *DedicatedVideoStart(char **parm) {
|
||||
DEBUG(misc,0)("OpenTTD compiled without network-support, quiting...");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void DedicatedFork(void) {}
|
||||
static void DedicatedVideoStop() { free(_dedicated_video_mem); }
|
||||
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {}
|
||||
static bool DedicatedVideoChangeRes(int w, int h) { return false; }
|
||||
static int DedicatedVideoMainLoop() { return ML_QUIT; }
|
||||
|
||||
const HalVideoDriver _dedicated_video_driver = {
|
||||
DedicatedVideoStart,
|
||||
DedicatedVideoStop,
|
||||
DedicatedVideoMakeDirty,
|
||||
DedicatedVideoMainLoop,
|
||||
DedicatedVideoChangeRes,
|
||||
};
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "depot.h"
|
||||
#include "functions.h"
|
||||
#include "tile.h"
|
||||
#include "map.h"
|
||||
#include "table/strings.h"
|
||||
#include "saveload.h"
|
||||
#include "order.h"
|
||||
|
||||
enum {
|
||||
/* Max depots: 64000 (8 * 8000) */
|
||||
DEPOT_POOL_BLOCK_SIZE_BITS = 3, /* In bits, so (1 << 3) == 8 */
|
||||
DEPOT_POOL_MAX_BLOCKS = 8000,
|
||||
};
|
||||
|
||||
/**
|
||||
* Called if a new block is added to the depot-pool
|
||||
*/
|
||||
static void DepotPoolNewBlock(uint start_item)
|
||||
{
|
||||
Depot *depot;
|
||||
|
||||
FOR_ALL_DEPOTS_FROM(depot, start_item)
|
||||
depot->index = start_item++;
|
||||
}
|
||||
|
||||
/* Initialize the town-pool */
|
||||
MemoryPool _depot_pool = { "Depots", DEPOT_POOL_MAX_BLOCKS, DEPOT_POOL_BLOCK_SIZE_BITS, sizeof(Depot), &DepotPoolNewBlock, 0, 0, NULL };
|
||||
|
||||
|
||||
/**
|
||||
* Gets a depot from a tile
|
||||
*
|
||||
* @return Returns the depot if the tile had a depot, else it returns NULL
|
||||
*/
|
||||
Depot *GetDepotByTile(TileIndex tile)
|
||||
{
|
||||
Depot *depot;
|
||||
|
||||
FOR_ALL_DEPOTS(depot) {
|
||||
if (depot->xy == tile)
|
||||
return depot;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a new depot
|
||||
*/
|
||||
Depot *AllocateDepot(void)
|
||||
{
|
||||
Depot *depot;
|
||||
|
||||
FOR_ALL_DEPOTS(depot) {
|
||||
if (!IsValidDepot(depot)) {
|
||||
uint index = depot->index;
|
||||
|
||||
memset(depot, 0, sizeof(Depot));
|
||||
depot->index = index;
|
||||
|
||||
return depot;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we can add a block to the pool */
|
||||
if (AddBlockToPool(&_depot_pool))
|
||||
return AllocateDepot();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a depot
|
||||
*/
|
||||
void DoDeleteDepot(TileIndex tile)
|
||||
{
|
||||
Order order;
|
||||
Depot *depot;
|
||||
|
||||
/* Get the depot */
|
||||
depot = GetDepotByTile(tile);
|
||||
|
||||
/* Clear the tile */
|
||||
DoClearSquare(tile);
|
||||
|
||||
/* Clear the depot */
|
||||
depot->xy = 0;
|
||||
|
||||
/* Clear the depot from all order-lists */
|
||||
order.type = OT_GOTO_DEPOT;
|
||||
order.station = depot->index;
|
||||
DeleteDestinationFromVehicleOrder(order);
|
||||
|
||||
/* Delete the depot-window */
|
||||
DeleteWindowById(WC_VEHICLE_DEPOT, tile);
|
||||
}
|
||||
|
||||
void InitializeDepot(void)
|
||||
{
|
||||
CleanPool(&_depot_pool);
|
||||
AddBlockToPool(&_depot_pool);
|
||||
}
|
||||
|
||||
|
||||
static const SaveLoad _depot_desc[] = {
|
||||
SLE_CONDVAR(Depot, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
|
||||
SLE_CONDVAR(Depot, xy, SLE_UINT32, 6, 255),
|
||||
SLE_VAR(Depot,town_index, SLE_UINT16),
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
static void Save_DEPT(void)
|
||||
{
|
||||
Depot *depot;
|
||||
|
||||
FOR_ALL_DEPOTS(depot) {
|
||||
if (IsValidDepot(depot)) {
|
||||
SlSetArrayIndex(depot->index);
|
||||
SlObject(depot, _depot_desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Load_DEPT(void)
|
||||
{
|
||||
int index;
|
||||
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
Depot *depot;
|
||||
|
||||
if (!AddBlockIfNeeded(&_depot_pool, index))
|
||||
error("Depots: failed loading savegame: too many depots");
|
||||
|
||||
depot = GetDepot(index);
|
||||
SlObject(depot, _depot_desc);
|
||||
}
|
||||
}
|
||||
|
||||
const ChunkHandler _depot_chunk_handlers[] = {
|
||||
{ 'DEPT', Save_DEPT, Load_DEPT, CH_ARRAY | CH_LAST},
|
||||
};
|
||||
@@ -1,148 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef DEPOT_H
|
||||
#define DEPOT_H
|
||||
|
||||
/** @file depot.h Header files for depots (not hangars)
|
||||
* @see depot.c */
|
||||
|
||||
#include "pool.h"
|
||||
#include "tile.h"
|
||||
#include "variables.h"
|
||||
|
||||
struct Depot {
|
||||
TileIndex xy;
|
||||
uint16 town_index;
|
||||
uint16 index;
|
||||
};
|
||||
|
||||
extern MemoryPool _depot_pool;
|
||||
|
||||
/**
|
||||
* Get the pointer to the depot with index 'index'
|
||||
*/
|
||||
static inline Depot *GetDepot(uint index)
|
||||
{
|
||||
return (Depot*)GetItemFromPool(&_depot_pool, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current size of the DepotPool
|
||||
*/
|
||||
static inline uint16 GetDepotPoolSize(void)
|
||||
{
|
||||
return _depot_pool.total_items;
|
||||
}
|
||||
|
||||
static inline bool IsDepotIndex(uint index)
|
||||
{
|
||||
return index < GetDepotPoolSize();
|
||||
}
|
||||
|
||||
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1 < GetDepotPoolSize()) ? GetDepot(d->index + 1) : NULL)
|
||||
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
|
||||
|
||||
#define MIN_SERVINT_PERCENT 5
|
||||
#define MAX_SERVINT_PERCENT 90
|
||||
#define MIN_SERVINT_DAYS 30
|
||||
#define MAX_SERVINT_DAYS 800
|
||||
|
||||
/** Get the service interval domain.
|
||||
* Get the new proposed service interval for the vehicle is indeed, clamped
|
||||
* within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
|
||||
* @param index proposed service interval
|
||||
*/
|
||||
static inline uint16 GetServiceIntervalClamped(uint index)
|
||||
{
|
||||
return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
|
||||
}
|
||||
|
||||
VARDEF TileIndex _last_built_train_depot_tile;
|
||||
VARDEF TileIndex _last_built_road_depot_tile;
|
||||
VARDEF TileIndex _last_built_aircraft_depot_tile;
|
||||
VARDEF TileIndex _last_built_ship_depot_tile;
|
||||
|
||||
/**
|
||||
* Check if a depot really exists.
|
||||
*/
|
||||
static inline bool IsValidDepot(const Depot* depot)
|
||||
{
|
||||
return depot->xy != 0; /* XXX: Replace by INVALID_TILE someday */
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a tile is a depot of the given type.
|
||||
*/
|
||||
static inline bool IsTileDepotType(TileIndex tile, TransportType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case TRANSPORT_RAIL:
|
||||
return IsTileType(tile, MP_RAILWAY) && (_m[tile].m5 & 0xFC) == 0xC0;
|
||||
|
||||
case TRANSPORT_ROAD:
|
||||
return IsTileType(tile, MP_STREET) && (_m[tile].m5 & 0xF0) == 0x20;
|
||||
|
||||
case TRANSPORT_WATER:
|
||||
return IsTileType(tile, MP_WATER) && (_m[tile].m5 & ~3) == 0x80;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction the exit of the depot on the given tile is facing.
|
||||
*/
|
||||
static inline DiagDirection GetDepotDirection(TileIndex tile, TransportType type)
|
||||
{
|
||||
assert(IsTileDepotType(tile, type));
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TRANSPORT_RAIL:
|
||||
case TRANSPORT_ROAD:
|
||||
/* Rail and road store a diagonal direction in bits 0 and 1 */
|
||||
return (DiagDirection)GB(_m[tile].m5, 0, 2);
|
||||
case TRANSPORT_WATER:
|
||||
/* Water is stubborn, it stores the directions in a different order. */
|
||||
switch (GB(_m[tile].m5, 0, 2)) {
|
||||
case 0: return DIAGDIR_NE;
|
||||
case 1: return DIAGDIR_SW;
|
||||
case 2: return DIAGDIR_NW;
|
||||
case 3: return DIAGDIR_SE;
|
||||
}
|
||||
default:
|
||||
return INVALID_DIAGDIR; /* Not reached */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Find out if the slope of the tile is suitable to build a depot of given direction
|
||||
@param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise
|
||||
@param tileh The slope of the tile in question
|
||||
@return true if the construction is possible
|
||||
|
||||
|
||||
This is checked by the ugly 0x4C >> direction magic, which does the following:
|
||||
0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
|
||||
So: for direction (only the significant bits are shown)<p>
|
||||
00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
|
||||
01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
|
||||
02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
|
||||
03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
|
||||
So ((0x4C >> p2) & tileh) determines whether the depot can be built on the current tileh
|
||||
*/
|
||||
static inline bool CanBuildDepotByTileh(uint32 direction, uint tileh)
|
||||
{
|
||||
return (0x4C >> direction) & tileh;
|
||||
}
|
||||
|
||||
|
||||
Depot *GetDepotByTile(TileIndex tile);
|
||||
void InitializeDepot(void);
|
||||
Depot *AllocateDepot(void);
|
||||
void DoDeleteDepot(TileIndex tile);
|
||||
|
||||
#endif /* DEPOT_H */
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef DIRECTION_H
|
||||
#define DIRECTION_H
|
||||
|
||||
|
||||
/* the 2 axis */
|
||||
typedef enum Axis {
|
||||
AXIS_X = 0,
|
||||
AXIS_Y = 1,
|
||||
AXIS_END
|
||||
} Axis;
|
||||
|
||||
|
||||
static inline Axis DiagDirToAxis(uint d)
|
||||
{
|
||||
return (Axis)(d & 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Converts an Axis to a DiagDirection
|
||||
* Points always in the positive direction, i.e. S[EW]
|
||||
*/
|
||||
static inline uint AxisToDiagDir(Axis a)
|
||||
{
|
||||
return (uint)(2 - a);
|
||||
}
|
||||
|
||||
#endif
|
||||
+195
-200
@@ -1,48 +1,37 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "tile.h"
|
||||
#include "vehicle.h"
|
||||
#include "command.h"
|
||||
#include "news.h"
|
||||
#include "gfx.h"
|
||||
#include "station.h"
|
||||
#include "waypoint.h"
|
||||
#include "town.h"
|
||||
#include "industry.h"
|
||||
#include "player.h"
|
||||
#include "airport_movement.h"
|
||||
#include "sound.h"
|
||||
#include "variables.h"
|
||||
#include "table/sprites.h"
|
||||
|
||||
static void DisasterClearSquare(TileIndex tile)
|
||||
static void DisasterClearSquare(uint tile)
|
||||
{
|
||||
if (!EnsureNoVehicle(tile)) return;
|
||||
int type;
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
if (IS_HUMAN_PLAYER(GetTileOwner(tile)) && !IsRailWaypoint(tile)) DoClearSquare(tile);
|
||||
break;
|
||||
if (!EnsureNoVehicle(tile))
|
||||
return;
|
||||
|
||||
case MP_HOUSE: {
|
||||
PlayerID p = _current_player;
|
||||
_current_player = OWNER_NONE;
|
||||
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
_current_player = p;
|
||||
break;
|
||||
}
|
||||
type = _map_type_and_height[tile] >> 4;
|
||||
|
||||
case MP_TREES:
|
||||
case MP_CLEAR:
|
||||
if (type == MP_RAILWAY) {
|
||||
if (IS_HUMAN_PLAYER(_map_owner[tile]))
|
||||
DoClearSquare(tile);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
} else if (type == MP_HOUSE) {
|
||||
byte p = _current_player;
|
||||
_current_player = OWNER_NONE;
|
||||
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
_current_player = p;
|
||||
} else if (type == MP_TREES || type == MP_CLEAR) {
|
||||
DoClearSquare(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +69,7 @@ static void InitializeDisasterVehicle(Vehicle *v, int x, int y, byte z, byte dir
|
||||
v->x_pos = x;
|
||||
v->y_pos = y;
|
||||
v->z_pos = z;
|
||||
v->tile = TileVirtXY(x, y);
|
||||
v->tile = TILE_FROM_XY(x,y);
|
||||
v->direction = direction;
|
||||
v->subtype = subtype;
|
||||
v->x_offs = -1;
|
||||
@@ -115,7 +104,7 @@ static void SetDisasterVehiclePos(Vehicle *v, int x, int y, byte z)
|
||||
v->x_pos = x;
|
||||
v->y_pos = y;
|
||||
v->z_pos = z;
|
||||
v->tile = TileVirtXY(x, y);
|
||||
v->tile = TILE_FROM_XY(x,y);
|
||||
|
||||
DisasterVehicleUpdateImage(v);
|
||||
VehiclePositionChanged(v);
|
||||
@@ -151,7 +140,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
Station *st;
|
||||
int x,y;
|
||||
byte z;
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
|
||||
++v->tick_counter;
|
||||
|
||||
@@ -170,26 +159,26 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
}
|
||||
|
||||
if ((v->tick_counter&7)==0) {
|
||||
CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE);
|
||||
CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE_3);
|
||||
}
|
||||
} else if (v->current_order.station == 0) {
|
||||
tile = v->tile; /**/
|
||||
|
||||
if (IsValidTile(tile) &&
|
||||
IsTileType(tile, MP_STATION) &&
|
||||
IS_BYTE_INSIDE(_m[tile].m5, 8, 0x43) &&
|
||||
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
|
||||
if (IS_TILETYPE(tile, MP_STATION) &&
|
||||
IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
|
||||
IS_HUMAN_PLAYER(_map_owner[tile])) {
|
||||
|
||||
v->current_order.station = 1;
|
||||
v->age = 0;
|
||||
|
||||
SetDParam(0, _m[tile].m2);
|
||||
SetDParam(0, _map2[tile]);
|
||||
AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT,
|
||||
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
|
||||
v->index,
|
||||
0);
|
||||
}
|
||||
}
|
||||
if (v->y_pos >= ((int)MapSizeY() + 9) * 16 - 1)
|
||||
if (v->y_pos >= (TILES_Y+9) * 16 - 1)
|
||||
DeleteDisasterVeh(v);
|
||||
return;
|
||||
}
|
||||
@@ -200,11 +189,11 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
|
||||
tile = v->tile; /**/
|
||||
|
||||
if (IsValidTile(tile) &&
|
||||
IsTileType(tile, MP_STATION) &&
|
||||
IS_BYTE_INSIDE(_m[tile].m5, 8, 0x43) &&
|
||||
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
|
||||
st = GetStation(_m[tile].m2);
|
||||
if (IS_TILETYPE(tile, MP_STATION) &&
|
||||
IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
|
||||
IS_HUMAN_PLAYER(_map_owner[tile])) {
|
||||
|
||||
st = DEREF_STATION(_map2[tile]);
|
||||
CLRBITS(st->airport_flags, RUNWAY_IN_block);
|
||||
}
|
||||
|
||||
@@ -221,20 +210,20 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
SetDisasterVehiclePos(v, x, y, z);
|
||||
|
||||
if (++v->age == 1) {
|
||||
CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
|
||||
CreateEffectVehicleRel(v, 0, 7, 8, EV_CRASHED_SMOKE);
|
||||
SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||
v->u.disaster.image_override = SPR_BLIMP_CRASHING;
|
||||
v->u.disaster.image_override = 0xF42;
|
||||
} else if (v->age == 70) {
|
||||
v->u.disaster.image_override = SPR_BLIMP_CRASHED;
|
||||
v->u.disaster.image_override = 0xF43;
|
||||
} else if (v->age <= 300) {
|
||||
if (!(v->tick_counter&7)) {
|
||||
uint32 r = Random();
|
||||
|
||||
CreateEffectVehicleRel(v,
|
||||
GB(r, 0, 4) - 7,
|
||||
GB(r, 4, 4) - 7,
|
||||
GB(r, 8, 3) + 5,
|
||||
EV_EXPLOSION_SMALL);
|
||||
-7 + (r&0xF),
|
||||
-7 + (r>>4&0xF),
|
||||
5 + (r>>8&0x7),
|
||||
EV_DEMOLISH);
|
||||
}
|
||||
} else if (v->age == 350) {
|
||||
v->current_order.station = 3;
|
||||
@@ -242,12 +231,11 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
}
|
||||
|
||||
tile = v->tile;/**/
|
||||
if (IsValidTile(tile) &&
|
||||
IsTileType(tile, MP_STATION) &&
|
||||
IS_BYTE_INSIDE(_m[tile].m5, 8, 0x43) &&
|
||||
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
|
||||
if (IS_TILETYPE(tile, MP_STATION) &&
|
||||
IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
|
||||
IS_HUMAN_PLAYER(_map_owner[tile])) {
|
||||
|
||||
st = GetStation(_m[tile].m2);
|
||||
st = DEREF_STATION(_map2[tile]);
|
||||
SETBITS(st->airport_flags, RUNWAY_IN_block);
|
||||
}
|
||||
}
|
||||
@@ -261,20 +249,20 @@ static void DisasterTick_UFO(Vehicle *v)
|
||||
uint dist;
|
||||
byte z;
|
||||
|
||||
v->u.disaster.image_override = (++v->tick_counter & 8) ? SPR_UFO_SMALL_SCOUT_DARKER : SPR_UFO_SMALL_SCOUT;
|
||||
v->u.disaster.image_override = (++v->tick_counter & 8) ? 0xF45 : 0xF44;
|
||||
|
||||
if (v->current_order.station == 0) {
|
||||
// fly around randomly
|
||||
int x = TileX(v->dest_tile) * 16;
|
||||
int y = TileY(v->dest_tile) * 16;
|
||||
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
|
||||
int x = GET_TILE_X(v->dest_tile)*16;
|
||||
int y = GET_TILE_Y(v->dest_tile)*16;
|
||||
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
|
||||
v->direction = GetDirectionTowards(v, x, y);
|
||||
GetNewVehiclePos(v, &gp);
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
return;
|
||||
}
|
||||
if (++v->age < 6) {
|
||||
v->dest_tile = RandomTile();
|
||||
v->dest_tile = TILE_MASK(Random());
|
||||
return;
|
||||
}
|
||||
v->current_order.station = 1;
|
||||
@@ -290,7 +278,7 @@ static void DisasterTick_UFO(Vehicle *v)
|
||||
DeleteDisasterVeh(v);
|
||||
} else {
|
||||
// target a vehicle
|
||||
u = GetVehicle(v->dest_tile);
|
||||
u = &_vehicles[v->dest_tile];
|
||||
if (u->type != VEH_Road) {
|
||||
DeleteDisasterVeh(v);
|
||||
return;
|
||||
@@ -325,7 +313,7 @@ static void DisasterTick_UFO(Vehicle *v)
|
||||
|
||||
// destroy?
|
||||
if (v->age > 50) {
|
||||
CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
|
||||
CreateEffectVehicleRel(v, 0, 7, 8, EV_CRASHED_SMOKE);
|
||||
SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||
DeleteDisasterVeh(v);
|
||||
}
|
||||
@@ -334,11 +322,12 @@ static void DisasterTick_UFO(Vehicle *v)
|
||||
|
||||
static void DestructIndustry(Industry *i)
|
||||
{
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
byte index = i - _industries;
|
||||
|
||||
for (tile = 0; tile != MapSize(); tile++) {
|
||||
if (IsTileType(tile, MP_INDUSTRY) && _m[tile].m2 == i->index) {
|
||||
_m[tile].m1 = 0;
|
||||
for(tile=0; tile != TILES_X*TILES_Y; tile++) {
|
||||
if (IS_TILETYPE(tile, MP_INDUSTRY) && _map2[tile] == index) {
|
||||
_map_owner[tile] = 0;
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
}
|
||||
@@ -351,7 +340,7 @@ static void DisasterTick_2(Vehicle *v)
|
||||
|
||||
v->tick_counter++;
|
||||
v->u.disaster.image_override =
|
||||
(v->current_order.station == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0;
|
||||
(v->current_order.station == 1 && v->tick_counter&4) ? 0xF4F : 0;
|
||||
|
||||
GetNewVehiclePos(v, &gp);
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
@@ -363,16 +352,16 @@ static void DisasterTick_2(Vehicle *v)
|
||||
|
||||
if (v->current_order.station == 2) {
|
||||
if (!(v->tick_counter&3)) {
|
||||
Industry *i = GetIndustry(v->dest_tile);
|
||||
int x = TileX(i->xy) * 16;
|
||||
int y = TileY(i->xy) * 16;
|
||||
Industry *i = DEREF_INDUSTRY(v->dest_tile);
|
||||
int x = GET_TILE_X(i->xy)*16;
|
||||
int y = GET_TILE_Y(i->xy)*16;
|
||||
uint32 r = Random();
|
||||
|
||||
CreateEffectVehicleAbove(
|
||||
GB(r, 0, 6) + x,
|
||||
GB(r, 6, 6) + y,
|
||||
GB(r, 12, 4),
|
||||
EV_EXPLOSION_SMALL);
|
||||
x + (r & 0x3F),
|
||||
y + (r >> 6 & 0x3F),
|
||||
(r >> 12 & 0xF),
|
||||
EV_DEMOLISH);
|
||||
|
||||
if (++v->age >= 55)
|
||||
v->current_order.station = 3;
|
||||
@@ -384,7 +373,7 @@ static void DisasterTick_2(Vehicle *v)
|
||||
v->current_order.station = 2;
|
||||
v->age = 0;
|
||||
|
||||
i = GetIndustry(v->dest_tile);
|
||||
i = DEREF_INDUSTRY(v->dest_tile);
|
||||
DestructIndustry(i);
|
||||
|
||||
SetDParam(0, i->town->index);
|
||||
@@ -393,22 +382,22 @@ static void DisasterTick_2(Vehicle *v)
|
||||
}
|
||||
} else if (v->current_order.station == 0) {
|
||||
int x,y;
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
int ind;
|
||||
|
||||
x = v->x_pos - 15*16;
|
||||
y = v->y_pos;
|
||||
|
||||
if ( (uint)x > MapMaxX() * 16-1)
|
||||
if ( (uint)x > (TILES_X-1) * 16-1)
|
||||
return;
|
||||
|
||||
tile = TileVirtXY(x, y);
|
||||
if (!IsTileType(tile, MP_INDUSTRY))
|
||||
tile = TILE_FROM_XY(x,y);
|
||||
if (!IS_TILETYPE(tile, MP_INDUSTRY))
|
||||
return;
|
||||
|
||||
v->dest_tile = ind = _m[tile].m2;
|
||||
v->dest_tile = ind = _map2[tile];
|
||||
|
||||
if (GetIndustry(ind)->type == IT_OIL_REFINERY) {
|
||||
if (DEREF_INDUSTRY(ind)->type == IT_OIL_REFINERY) {
|
||||
v->current_order.station = 1;
|
||||
v->age = 0;
|
||||
}
|
||||
@@ -422,28 +411,28 @@ static void DisasterTick_3(Vehicle *v)
|
||||
|
||||
v->tick_counter++;
|
||||
v->u.disaster.image_override =
|
||||
(v->current_order.station == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0;
|
||||
(v->current_order.station == 1 && v->tick_counter&4) ? 0xF53 : 0;
|
||||
|
||||
GetNewVehiclePos(v, &gp);
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
|
||||
if (gp.x > (int)MapSizeX() * 16 + 9*16 - 1) {
|
||||
if (gp.x > TILES_X * 16 + 9*16 - 1) {
|
||||
DeleteDisasterVeh(v);
|
||||
return;
|
||||
}
|
||||
|
||||
if (v->current_order.station == 2) {
|
||||
if (!(v->tick_counter&3)) {
|
||||
Industry *i = GetIndustry(v->dest_tile);
|
||||
int x = TileX(i->xy) * 16;
|
||||
int y = TileY(i->xy) * 16;
|
||||
Industry *i = DEREF_INDUSTRY(v->dest_tile);
|
||||
int x = GET_TILE_X(i->xy)*16;
|
||||
int y = GET_TILE_Y(i->xy)*16;
|
||||
uint32 r = Random();
|
||||
|
||||
CreateEffectVehicleAbove(
|
||||
GB(r, 0, 6) + x,
|
||||
GB(r, 6, 6) + y,
|
||||
GB(r, 12, 4),
|
||||
EV_EXPLOSION_SMALL);
|
||||
x + (r & 0x3F),
|
||||
y + (r >> 6 & 0x3F),
|
||||
(r >> 12 & 0xF),
|
||||
EV_DEMOLISH);
|
||||
|
||||
if (++v->age >= 55)
|
||||
v->current_order.station = 3;
|
||||
@@ -455,7 +444,7 @@ static void DisasterTick_3(Vehicle *v)
|
||||
v->current_order.station = 2;
|
||||
v->age = 0;
|
||||
|
||||
i = GetIndustry(v->dest_tile);
|
||||
i = DEREF_INDUSTRY(v->dest_tile);
|
||||
DestructIndustry(i);
|
||||
|
||||
SetDParam(0, i->town->index);
|
||||
@@ -464,22 +453,22 @@ static void DisasterTick_3(Vehicle *v)
|
||||
}
|
||||
} else if (v->current_order.station == 0) {
|
||||
int x,y;
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
int ind;
|
||||
|
||||
x = v->x_pos - 15*16;
|
||||
y = v->y_pos;
|
||||
|
||||
if ( (uint)x > MapMaxX() * 16-1)
|
||||
if ( (uint)x > (TILES_X-1) * 16-1)
|
||||
return;
|
||||
|
||||
tile = TileVirtXY(x, y);
|
||||
if (!IsTileType(tile, MP_INDUSTRY))
|
||||
tile = TILE_FROM_XY(x,y);
|
||||
if (!IS_TILETYPE(tile, MP_INDUSTRY))
|
||||
return;
|
||||
|
||||
v->dest_tile = ind = _m[tile].m2;
|
||||
v->dest_tile = ind = _map2[tile];
|
||||
|
||||
if (GetIndustry(ind)->type == IT_FACTORY) {
|
||||
if (DEREF_INDUSTRY(ind)->type == IT_FACTORY) {
|
||||
v->current_order.station = 1;
|
||||
v->age = 0;
|
||||
}
|
||||
@@ -492,7 +481,8 @@ static void DisasterTick_3b(Vehicle *v)
|
||||
if (++v->tick_counter & 1)
|
||||
return;
|
||||
|
||||
if (++v->cur_image > SPR_ROTOR_MOVING_3) v->cur_image = SPR_ROTOR_MOVING_1;
|
||||
if (++v->cur_image == 0xF40 + 1)
|
||||
v->cur_image = 0xF3E;
|
||||
|
||||
VehiclePositionChanged(v);
|
||||
BeginVehicleMove(v);
|
||||
@@ -507,14 +497,13 @@ static void DisasterTick_4(Vehicle *v)
|
||||
byte z;
|
||||
Vehicle *u,*w;
|
||||
Town *t;
|
||||
TileIndex tile;
|
||||
TileIndex tile_org;
|
||||
uint tile,tile_org;
|
||||
|
||||
v->tick_counter++;
|
||||
|
||||
if (v->current_order.station == 1) {
|
||||
int x = TileX(v->dest_tile) * 16 + 8;
|
||||
int y = TileY(v->dest_tile) * 16 + 8;
|
||||
int x = GET_TILE_X(v->dest_tile)*16 + 8;
|
||||
int y = GET_TILE_Y(v->dest_tile)*16 + 8;
|
||||
if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) {
|
||||
v->direction = GetDirectionTowards(v, x, y);
|
||||
|
||||
@@ -565,9 +554,9 @@ static void DisasterTick_4(Vehicle *v)
|
||||
w->vehstatus |= VS_DISASTER;
|
||||
} else if (v->current_order.station < 1) {
|
||||
|
||||
int x = TileX(v->dest_tile) * 16;
|
||||
int y = TileY(v->dest_tile) * 16;
|
||||
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
|
||||
int x = GET_TILE_X(v->dest_tile)*16;
|
||||
int y = GET_TILE_Y(v->dest_tile)*16;
|
||||
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
|
||||
v->direction = GetDirectionTowards(v, x, y);
|
||||
GetNewVehiclePos(v, &gp);
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
@@ -575,16 +564,16 @@ static void DisasterTick_4(Vehicle *v)
|
||||
}
|
||||
|
||||
if (++v->age < 6) {
|
||||
v->dest_tile = RandomTile();
|
||||
v->dest_tile = TILE_MASK(Random());
|
||||
return;
|
||||
}
|
||||
v->current_order.station = 1;
|
||||
|
||||
tile_org = tile = RandomTile();
|
||||
tile_org = tile = TILE_MASK(Random());
|
||||
do {
|
||||
if (IsTileType(tile, MP_RAILWAY) &&
|
||||
(_m[tile].m5 & ~3) != 0xC0 && IS_HUMAN_PLAYER(GetTileOwner(tile)))
|
||||
break;
|
||||
if (IS_TILETYPE(tile, MP_RAILWAY) &&
|
||||
(_map5[tile]&~3)!=0xC0 && IS_HUMAN_PLAYER(_map_owner[tile]))
|
||||
break;
|
||||
tile = TILE_MASK(tile+1);
|
||||
} while (tile != tile_org);
|
||||
v->dest_tile = tile;
|
||||
@@ -605,18 +594,18 @@ static void DisasterTick_4b(Vehicle *v)
|
||||
GetNewVehiclePos(v, &gp);
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
|
||||
if (gp.x > (int)MapSizeX() * 16 + 9*16 - 1) {
|
||||
if (gp.x > TILES_X * 16 + 9*16 - 1) {
|
||||
DeleteDisasterVeh(v);
|
||||
return;
|
||||
}
|
||||
|
||||
if (v->current_order.station == 0) {
|
||||
u = GetVehicle(v->u.disaster.unk2);
|
||||
u = &_vehicles[v->u.disaster.unk2];
|
||||
if (abs(v->x_pos - u->x_pos) > 16)
|
||||
return;
|
||||
v->current_order.station = 1;
|
||||
|
||||
CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
|
||||
CreateEffectVehicleRel(u, 0, 7, 8, EV_CRASHED_SMOKE);
|
||||
SndPlayVehicleFx(SND_12_EXPLOSION, u);
|
||||
|
||||
DeleteDisasterVeh(u);
|
||||
@@ -624,16 +613,16 @@ static void DisasterTick_4b(Vehicle *v)
|
||||
for(i=0; i!=80; i++) {
|
||||
uint32 r = Random();
|
||||
CreateEffectVehicleAbove(
|
||||
GB(r, 0, 6) + v->x_pos - 32,
|
||||
GB(r, 5, 6) + v->y_pos - 32,
|
||||
v->x_pos-32+(r&0x3F),
|
||||
v->y_pos-32+(r>>5&0x3F),
|
||||
0,
|
||||
EV_EXPLOSION_SMALL);
|
||||
EV_DEMOLISH);
|
||||
}
|
||||
|
||||
BEGIN_TILE_LOOP(tile, 6, 6, v->tile - TileDiffXY(3, 3))
|
||||
BEGIN_TILE_LOOP(tile,6,6,v->tile - TILE_XY(3,3))
|
||||
tile = TILE_MASK(tile);
|
||||
DisasterClearSquare(tile);
|
||||
END_TILE_LOOP(tile, 6, 6, v->tile - TileDiffXY(3, 3))
|
||||
END_TILE_LOOP(tile,6,6,v->tile - TILE_XY(3,3))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,7 +631,7 @@ static void DisasterTick_5_and_6(Vehicle *v)
|
||||
{
|
||||
uint32 r;
|
||||
GetNewVehiclePosResult gp;
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
|
||||
v->tick_counter++;
|
||||
|
||||
@@ -657,7 +646,7 @@ static void DisasterTick_5_and_6(Vehicle *v)
|
||||
if (!(v->tick_counter&1))
|
||||
return;
|
||||
|
||||
tile = v->tile + TileOffsByDir(v->direction >> 1);
|
||||
tile = v->tile + _tileoffs_by_dir[v->direction >> 1];
|
||||
if (IsValidTile(tile) &&
|
||||
(r=GetTileTrackStatus(tile,TRANSPORT_WATER),(byte)(r+(r >> 8)) == 0x3F) &&
|
||||
!CHANCE16(1,90)) {
|
||||
@@ -666,7 +655,7 @@ static void DisasterTick_5_and_6(Vehicle *v)
|
||||
return;
|
||||
}
|
||||
|
||||
v->direction = (v->direction + (GB(Random(), 0, 1) ? 2 : -2)) & 7;
|
||||
v->direction = (v->direction + ((Random()&1)?2:-2))&7;
|
||||
}
|
||||
|
||||
|
||||
@@ -690,16 +679,20 @@ void DisasterVehicle_Tick(Vehicle *v)
|
||||
_disastervehicle_tick_procs[v->subtype](v);
|
||||
}
|
||||
|
||||
void HandleClickOnDisasterVeh(Vehicle *v)
|
||||
{
|
||||
// not used
|
||||
}
|
||||
|
||||
void OnNewDay_DisasterVehicle(Vehicle *v)
|
||||
{
|
||||
// not used
|
||||
}
|
||||
|
||||
typedef void DisasterInitProc(void);
|
||||
typedef void DisasterInitProc();
|
||||
|
||||
// Zeppeliner which crashes on a small airport
|
||||
static void Disaster0_Init(void)
|
||||
static void Disaster0_Init()
|
||||
{
|
||||
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
|
||||
Station *st;
|
||||
@@ -708,15 +701,16 @@ static void Disaster0_Init(void)
|
||||
if (v == NULL)
|
||||
return;
|
||||
|
||||
/* Pick a random place, unless we find
|
||||
a small airport */
|
||||
x = TileX(Random()) * 16 + 8;
|
||||
|
||||
FOR_ALL_STATIONS(st) {
|
||||
for(st=_stations;;) {
|
||||
if (st->xy && st->airport_tile != 0 &&
|
||||
st->airport_type <= 1 &&
|
||||
IS_HUMAN_PLAYER(st->owner)) {
|
||||
x = (TileX(st->xy) + 2) * 16;
|
||||
x = (GET_TILE_X(st->xy) + 2) * 16;
|
||||
break;
|
||||
}
|
||||
|
||||
if (++st == endof(_stations)) {
|
||||
x = (GET_TILE_X(Random())) * 16 + 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -727,12 +721,12 @@ static void Disaster0_Init(void)
|
||||
u = ForceAllocateSpecialVehicle();
|
||||
if (u != NULL) {
|
||||
v->next = u;
|
||||
InitializeDisasterVehicle(u, x, 0, 0, 3, 1);
|
||||
InitializeDisasterVehicle(u,x,0,0,3,1);
|
||||
u->vehstatus |= VS_DISASTER;
|
||||
}
|
||||
}
|
||||
|
||||
static void Disaster1_Init(void)
|
||||
static void Disaster1_Init()
|
||||
{
|
||||
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
|
||||
int x;
|
||||
@@ -740,10 +734,10 @@ static void Disaster1_Init(void)
|
||||
if (v == NULL)
|
||||
return;
|
||||
|
||||
x = TileX(Random()) * 16 + 8;
|
||||
x = (GET_TILE_X(Random())) * 16 + 8;
|
||||
|
||||
InitializeDisasterVehicle(v, x, 0, 135, 3, 2);
|
||||
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
|
||||
v->dest_tile = TILE_XY(TILES_X/2,TILES_Y/2);
|
||||
v->age = 0;
|
||||
|
||||
// Allocate shadow too?
|
||||
@@ -755,15 +749,13 @@ static void Disaster1_Init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void Disaster2_Init(void)
|
||||
static void Disaster2_Init()
|
||||
{
|
||||
Industry *i, *found;
|
||||
Vehicle *v,*u;
|
||||
int x,y;
|
||||
|
||||
found = NULL;
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
for(found=NULL,i=_industries; i != endof(_industries); i++) {
|
||||
if (i->xy != 0 &&
|
||||
i->type == IT_OIL_REFINERY &&
|
||||
(found==NULL || CHANCE16(1,2))) {
|
||||
@@ -778,8 +770,8 @@ static void Disaster2_Init(void)
|
||||
if (v == NULL)
|
||||
return;
|
||||
|
||||
x = (MapSizeX() + 9) * 16 - 1;
|
||||
y = TileY(found->xy) * 16 + 37;
|
||||
x = (TILES_X+9) * 16 - 1;
|
||||
y = GET_TILE_Y(found->xy)*16 + 37;
|
||||
|
||||
InitializeDisasterVehicle(v,x,y, 135,1,4);
|
||||
|
||||
@@ -791,15 +783,13 @@ static void Disaster2_Init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void Disaster3_Init(void)
|
||||
static void Disaster3_Init()
|
||||
{
|
||||
Industry *i, *found;
|
||||
Vehicle *v,*u,*w;
|
||||
int x,y;
|
||||
|
||||
found = NULL;
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
for(found=NULL,i=_industries; i != endof(_industries); i++) {
|
||||
if (i->xy != 0 &&
|
||||
i->type == IT_FACTORY &&
|
||||
(found==NULL || CHANCE16(1,2))) {
|
||||
@@ -815,7 +805,7 @@ static void Disaster3_Init(void)
|
||||
return;
|
||||
|
||||
x = -16 * 16;
|
||||
y = TileY(found->xy) * 16 + 37;
|
||||
y = GET_TILE_Y(found->xy)*16 + 37;
|
||||
|
||||
InitializeDisasterVehicle(v,x,y, 135,5,6);
|
||||
|
||||
@@ -833,18 +823,19 @@ static void Disaster3_Init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void Disaster4_Init(void)
|
||||
static void Disaster4_Init()
|
||||
{
|
||||
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
|
||||
int x,y;
|
||||
|
||||
if (v == NULL) return;
|
||||
if (v == NULL)
|
||||
return;
|
||||
|
||||
x = TileX(Random()) * 16 + 8;
|
||||
x = (GET_TILE_X(Random())) * 16 + 8;
|
||||
|
||||
y = MapMaxX() * 16 - 1;
|
||||
y = (TILES_X-1)*16-1;
|
||||
InitializeDisasterVehicle(v, x, y, 135, 7, 9);
|
||||
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
|
||||
v->dest_tile = TILE_XY(TILES_X/2,TILES_Y/2);
|
||||
v->age = 0;
|
||||
|
||||
// Allocate shadow too?
|
||||
@@ -857,73 +848,74 @@ static void Disaster4_Init(void)
|
||||
}
|
||||
|
||||
// Submarine type 1
|
||||
static void Disaster5_Init(void)
|
||||
static void Disaster5_Init()
|
||||
{
|
||||
Vehicle *v = ForceAllocateSpecialVehicle();
|
||||
int x,y;
|
||||
byte dir;
|
||||
uint32 r;
|
||||
|
||||
if (v == NULL) return;
|
||||
if (v == NULL)
|
||||
return;
|
||||
|
||||
r = Random();
|
||||
x = TileX(r) * 16 + 8;
|
||||
x = (GET_TILE_X(r)) * 16 + 8;
|
||||
|
||||
y = 8;
|
||||
dir = 3;
|
||||
if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; }
|
||||
if (r & 0x80000000) { y = (TILES_X-1) * 16 - 8 - 1; dir = 7; }
|
||||
InitializeDisasterVehicle(v, x, y, 0, dir,13);
|
||||
v->age = 0;
|
||||
}
|
||||
|
||||
// Submarine type 2
|
||||
static void Disaster6_Init(void)
|
||||
static void Disaster6_Init()
|
||||
{
|
||||
Vehicle *v = ForceAllocateSpecialVehicle();
|
||||
int x,y;
|
||||
byte dir;
|
||||
uint32 r;
|
||||
|
||||
if (v == NULL) return;
|
||||
if (v == NULL)
|
||||
return;
|
||||
|
||||
r = Random();
|
||||
x = TileX(r) * 16 + 8;
|
||||
x = (GET_TILE_X(r)) * 16 + 8;
|
||||
|
||||
y = 8;
|
||||
dir = 3;
|
||||
if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; }
|
||||
if (r & 0x80000000) { y = (TILES_X-1) * 16 - 8 - 1; dir = 7; }
|
||||
InitializeDisasterVehicle(v, x, y, 0, dir,14);
|
||||
v->age = 0;
|
||||
}
|
||||
|
||||
static void Disaster7_Init(void)
|
||||
static void Disaster7_Init()
|
||||
{
|
||||
int index = GB(Random(), 0, 4);
|
||||
Industry *i;
|
||||
uint m;
|
||||
int maxloop = 15;
|
||||
int index = Random() & 0xF;
|
||||
|
||||
for (m = 0; m < 15; m++) {
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
if (i->xy != 0 && i->type == IT_COAL_MINE && --index < 0) {
|
||||
do {
|
||||
for(i=_industries; i != endof(_industries); i++) {
|
||||
if (i->xy != 0 && i->type == IT_COAL_MINE && --index < 0) {
|
||||
|
||||
SetDParam(0, i->town->index);
|
||||
AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
|
||||
NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy + TileDiffXY(1, 1), 0);
|
||||
NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy + TILE_XY(1,1), 0);
|
||||
|
||||
{
|
||||
TileIndex tile = i->xy;
|
||||
TileIndexDiff step = TileOffsByDir(GB(Random(), 0, 2));
|
||||
uint n;
|
||||
|
||||
for (n = 0; n < 30; n++) {
|
||||
uint tile = i->xy;
|
||||
int step = _tileoffs_by_dir[Random() & 3];
|
||||
int count = 30;
|
||||
do {
|
||||
DisasterClearSquare(tile);
|
||||
tile = TILE_MASK(tile + step);
|
||||
}
|
||||
} while (--count);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (--maxloop != 0);
|
||||
}
|
||||
|
||||
static DisasterInitProc * const _disaster_initprocs[] = {
|
||||
@@ -937,56 +929,59 @@ static DisasterInitProc * const _disaster_initprocs[] = {
|
||||
Disaster7_Init,
|
||||
};
|
||||
|
||||
#define MK(a, b) { (a) - MAX_YEAR_BEGIN_REAL, (b) - MAX_YEAR_BEGIN_REAL }
|
||||
static const struct {
|
||||
byte min;
|
||||
byte max;
|
||||
} _dis_years[] = {
|
||||
MK(1930, 1955),
|
||||
MK(1940, 1970),
|
||||
MK(1960, 1990),
|
||||
MK(1970, 2000),
|
||||
MK(2000, 2100),
|
||||
MK(1940, 1965),
|
||||
MK(1975, 2010),
|
||||
MK(1950, 1985)
|
||||
typedef struct {
|
||||
byte min,max;
|
||||
} DisasterYears;
|
||||
|
||||
#define MK(a,b) {a-20,b-20}
|
||||
static const DisasterYears _dis_years[8] = {
|
||||
MK(30,55),
|
||||
MK(40,70),
|
||||
MK(60,90),
|
||||
MK(70,100),
|
||||
MK(100,200),
|
||||
MK(40,65),
|
||||
MK(75,110),
|
||||
MK(50,85),
|
||||
};
|
||||
#undef MK
|
||||
|
||||
|
||||
static void DoDisaster(void)
|
||||
static void DoDisaster()
|
||||
{
|
||||
byte buf[lengthof(_dis_years)];
|
||||
byte buf[8];
|
||||
byte year = _cur_year;
|
||||
uint i;
|
||||
uint j;
|
||||
int i,j;
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i != lengthof(_dis_years); i++) {
|
||||
if (year >= _dis_years[i].min && year < _dis_years[i].max) buf[j++] = i;
|
||||
for(i=j=0; i!=lengthof(_dis_years); i++) {
|
||||
if (year >= _dis_years[i].min &&
|
||||
year < _dis_years[i].max)
|
||||
buf[j++] = i;
|
||||
}
|
||||
|
||||
if (j == 0) return;
|
||||
if (j == 0)
|
||||
return;
|
||||
|
||||
_disaster_initprocs[buf[RandomRange(j)]]();
|
||||
_disaster_initprocs[buf[(uint16)Random() * j >> 16]]();
|
||||
}
|
||||
|
||||
|
||||
static void ResetDisasterDelay(void)
|
||||
static void ResetDisasterDelay()
|
||||
{
|
||||
_disaster_delay = GB(Random(), 0, 9) + 730;
|
||||
_disaster_delay = (int)(Random() & 0x1FF) + 730;
|
||||
}
|
||||
|
||||
void DisasterDailyLoop(void)
|
||||
void DisasterDailyLoop()
|
||||
{
|
||||
if (--_disaster_delay != 0) return;
|
||||
if (--_disaster_delay != 0)
|
||||
return;
|
||||
|
||||
ResetDisasterDelay();
|
||||
|
||||
if (_opt.diff.disasters != 0) DoDisaster();
|
||||
if (_opt.diff.disasters != 0)
|
||||
DoDisaster();
|
||||
}
|
||||
|
||||
void StartupDisasters(void)
|
||||
{
|
||||
void StartupDisasters() {
|
||||
ResetDisasterDelay();
|
||||
}
|
||||
|
||||
|
||||
+89
-116
@@ -1,10 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "table/sprites.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "window.h"
|
||||
#include "station.h"
|
||||
@@ -13,14 +9,13 @@
|
||||
#include "gfx.h"
|
||||
#include "sound.h"
|
||||
#include "command.h"
|
||||
#include "variables.h"
|
||||
|
||||
static void ShowBuildDockStationPicker(void);
|
||||
static void ShowBuildDocksDepotPicker(void);
|
||||
static void ShowBuildDockStationPicker();
|
||||
static void ShowBuildDocksDepotPicker();
|
||||
|
||||
static byte _ship_depot_direction;
|
||||
|
||||
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
void CcBuildDocks(bool success, uint tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (success) {
|
||||
SndPlayTileFx(SND_02_SPLAT, tile);
|
||||
@@ -28,38 +23,38 @@ void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
}
|
||||
}
|
||||
|
||||
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
void CcBuildCanal(bool success, uint tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (success) SndPlayTileFx(SND_02_SPLAT, tile);
|
||||
}
|
||||
|
||||
|
||||
static void PlaceDocks_Dock(TileIndex tile)
|
||||
static void PlaceDocks_Dock(uint tile)
|
||||
{
|
||||
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_AUTO | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
|
||||
}
|
||||
|
||||
static void PlaceDocks_Depot(TileIndex tile)
|
||||
static void PlaceDocks_Depot(uint tile)
|
||||
{
|
||||
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_AUTO | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT));
|
||||
}
|
||||
|
||||
static void PlaceDocks_Buoy(TileIndex tile)
|
||||
static void PlaceDocks_Buoy(uint tile)
|
||||
{
|
||||
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_AUTO | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE));
|
||||
}
|
||||
|
||||
static void PlaceDocks_DemolishArea(TileIndex tile)
|
||||
static void PlaceDocks_DemolishArea(uint tile)
|
||||
{
|
||||
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
|
||||
VpStartPlaceSizing(tile, VPM_X_AND_Y);
|
||||
}
|
||||
|
||||
static void PlaceDocks_BuildCanal(TileIndex tile)
|
||||
static void PlaceDocks_BuildCanal(uint tile)
|
||||
{
|
||||
VpStartPlaceSizing(tile, VPM_X_OR_Y);
|
||||
}
|
||||
|
||||
static void PlaceDocks_BuildLock(TileIndex tile)
|
||||
static void PlaceDocks_BuildLock(uint tile)
|
||||
{
|
||||
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_LOCKS));
|
||||
}
|
||||
@@ -67,12 +62,12 @@ static void PlaceDocks_BuildLock(TileIndex tile)
|
||||
|
||||
static void BuildDocksClick_Canal(Window *w)
|
||||
{
|
||||
HandlePlacePushButton(w, 3, SPR_CURSOR_CANAL, 1, PlaceDocks_BuildCanal);
|
||||
HandlePlacePushButton(w, 3, SPR_OPENTTD_BASE + 11, 1, PlaceDocks_BuildCanal);
|
||||
}
|
||||
|
||||
static void BuildDocksClick_Lock(Window *w)
|
||||
{
|
||||
HandlePlacePushButton(w, 4, SPR_CURSOR_LOCK, 1, PlaceDocks_BuildLock);
|
||||
HandlePlacePushButton(w, 4, SPR_OPENTTD_BASE + 64, 1, PlaceDocks_BuildLock);
|
||||
}
|
||||
|
||||
static void BuildDocksClick_Demolish(Window *w)
|
||||
@@ -82,18 +77,18 @@ static void BuildDocksClick_Demolish(Window *w)
|
||||
|
||||
static void BuildDocksClick_Depot(Window *w)
|
||||
{
|
||||
if (HandlePlacePushButton(w, 7, SPR_CURSOR_SHIP_DEPOT, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
|
||||
if (HandlePlacePushButton(w, 7, 0x2D1, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
|
||||
}
|
||||
|
||||
static void BuildDocksClick_Dock(Window *w)
|
||||
{
|
||||
|
||||
if (HandlePlacePushButton(w, 8, SPR_CURSOR_DOCK, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker();
|
||||
if (HandlePlacePushButton(w, 8, 0xE54, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker();
|
||||
}
|
||||
|
||||
static void BuildDocksClick_Buoy(Window *w)
|
||||
{
|
||||
HandlePlacePushButton(w, 9, SPR_CURSOR_BOUY, 1, PlaceDocks_Buoy);
|
||||
HandlePlacePushButton(w, 9, 0x2BE, 1, PlaceDocks_Buoy);
|
||||
}
|
||||
|
||||
static void BuildDocksClick_Landscaping(Window *w)
|
||||
@@ -105,7 +100,7 @@ typedef void OnButtonClick(Window *w);
|
||||
static OnButtonClick * const _build_docks_button_proc[] = {
|
||||
BuildDocksClick_Canal,
|
||||
BuildDocksClick_Lock,
|
||||
NULL,
|
||||
0,
|
||||
BuildDocksClick_Demolish,
|
||||
BuildDocksClick_Depot,
|
||||
BuildDocksClick_Dock,
|
||||
@@ -120,22 +115,9 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
|
||||
DrawWindowWidgets(w);
|
||||
break;
|
||||
|
||||
case WE_CLICK:
|
||||
case WE_CLICK: {
|
||||
if (e->click.widget - 3 >= 0 && e->click.widget != 5) _build_docks_button_proc[e->click.widget - 3](w);
|
||||
break;
|
||||
|
||||
case WE_KEYPRESS:
|
||||
switch (e->keypress.keycode) {
|
||||
case '1': BuildDocksClick_Canal(w); break;
|
||||
case '2': BuildDocksClick_Lock(w); break;
|
||||
case '3': BuildDocksClick_Demolish(w); break;
|
||||
case '4': BuildDocksClick_Depot(w); break;
|
||||
case '5': BuildDocksClick_Dock(w); break;
|
||||
case '6': BuildDocksClick_Buoy(w); break;
|
||||
case 'l': BuildDocksClick_Landscaping(w); break;
|
||||
default: return;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
|
||||
case WE_PLACE_OBJ:
|
||||
_place_proc(e->place.tile);
|
||||
@@ -148,11 +130,10 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
case WE_PLACE_MOUSEUP:
|
||||
if (e->click.pt.x != -1) {
|
||||
if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
|
||||
GUIPlaceProcDragXY(e);
|
||||
} else if (e->place.userdata == VPM_X_OR_Y) {
|
||||
if (e->place.userdata == VPM_X_AND_Y)
|
||||
DoCommandP(e->place.tile, e->place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
||||
else if(e->place.userdata == VPM_X_OR_Y)
|
||||
DoCommandP(e->place.tile, e->place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -161,46 +142,41 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
|
||||
SetWindowDirty(w);
|
||||
|
||||
w = FindWindowById(WC_BUILD_STATION, 0);
|
||||
if (w != NULL) WP(w,def_d).close = true;
|
||||
if (w != NULL) WP(w,def_d).close=true;
|
||||
|
||||
w = FindWindowById(WC_BUILD_DEPOT, 0);
|
||||
if (w != NULL) WP(w,def_d).close = true;
|
||||
if (w != NULL) WP(w,def_d).close=true;
|
||||
break;
|
||||
|
||||
case WE_PLACE_PRESIZE: {
|
||||
TileIndex tile_from;
|
||||
TileIndex tile_to;
|
||||
uint tile_from, tile_to;
|
||||
|
||||
tile_from = tile_to = e->place.tile;
|
||||
switch (GetTileSlope(tile_from, NULL)) {
|
||||
case 3: tile_to += TileDiffXY(-1, 0); break;
|
||||
case 6: tile_to += TileDiffXY( 0, -1); break;
|
||||
case 9: tile_to += TileDiffXY( 0, 1); break;
|
||||
case 12: tile_to += TileDiffXY( 1, 0); break;
|
||||
switch(GetTileSlope(tile_from, NULL)) {
|
||||
case 3: tile_to += TILE_XY(-1,0); break;
|
||||
case 6: tile_to += TILE_XY(0,-1); break;
|
||||
case 9: tile_to += TILE_XY(0,1); break;
|
||||
case 12:tile_to += TILE_XY(1,0); break;
|
||||
}
|
||||
VpSetPresizeRange(tile_from, tile_to);
|
||||
} break;
|
||||
|
||||
case WE_DESTROY:
|
||||
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const Widget _build_docks_toolb_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 145, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, 7, 146, 157, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_PANEL, 7, 0, 21, 14, 35, SPR_OPENTTD_BASE+65, STR_BUILD_CANALS_TIP},
|
||||
{ WWT_PANEL, 7, 22, 43, 14, 35, SPR_CANALS_BASE+69, STR_BUILD_LOCKS_TIP},
|
||||
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 44, 47, 14, 35, 0x0, STR_NULL},
|
||||
{ WWT_PANEL, 7, 44, 47, 14, 35, 0x0, STR_NULL},
|
||||
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 48, 69, 14, 35, 703, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 70, 91, 14, 35, 748, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 92, 113, 14, 35, 746, STR_981D_BUILD_SHIP_DOCK},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 693, STR_9834_POSITION_BUOY_WHICH_CAN},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
||||
{ WWT_PANEL, 7, 48, 69, 14, 35, 703, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
||||
{ WWT_PANEL, 7, 70, 91, 14, 35, 748, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING},
|
||||
{ WWT_PANEL, 7, 92, 113, 14, 35, 746, STR_981D_BUILD_SHIP_DOCK},
|
||||
{ WWT_PANEL, 7, 114, 135, 14, 35, 693, STR_9834_POSITION_BUOY_WHICH_CAN},
|
||||
{ WWT_PANEL, 7, 136, 157, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -212,49 +188,49 @@ static const WindowDesc _build_docks_toolbar_desc = {
|
||||
BuildDocksToolbWndProc
|
||||
};
|
||||
|
||||
void ShowBuildDocksToolbar(void)
|
||||
void ShowBuildDocksToolbar()
|
||||
{
|
||||
if (_current_player == OWNER_SPECTATOR) return;
|
||||
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
|
||||
AllocateWindowDesc(&_build_docks_toolbar_desc);
|
||||
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();
|
||||
}
|
||||
|
||||
static void BuildDockStationWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
int rad;
|
||||
int rad;
|
||||
|
||||
if (WP(w,def_d).close) return;
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
if (WP(w,def_d).close)
|
||||
return;
|
||||
w->click_state = (1<<3) << _station_show_coverage;
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
rad = (_patches.modified_catchment) ? CA_DOCK : 4;
|
||||
|
||||
if (_station_show_coverage) {
|
||||
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
if (_patches.modified_catchment) {
|
||||
rad = CA_DOCK;
|
||||
} else {
|
||||
SetTileSelectBigSize(0, 0, 0, 0);
|
||||
rad = 4;
|
||||
}
|
||||
|
||||
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
else SetTileSelectBigSize(0, 0, 0, 0);
|
||||
|
||||
DrawStringCentered(74, 17, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
|
||||
DrawStationCoverageAreaText(4, 50, (uint)-1, rad);
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->click.widget) {
|
||||
case 3:
|
||||
case 4:
|
||||
_station_show_coverage = e->click.widget - 3;
|
||||
SndPlayFx(SND_15_BEEP);
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
case WE_CLICK: {
|
||||
switch(e->click.widget) {
|
||||
case 0:
|
||||
ResetObjectToPlace();
|
||||
break;
|
||||
case 3: case 4:
|
||||
_station_show_coverage = e->click.widget - 3;
|
||||
SndPlayFx(SND_15_BEEP);
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
|
||||
case WE_MOUSELOOP:
|
||||
case WE_MOUSELOOP: {
|
||||
if (WP(w,def_d).close) {
|
||||
DeleteWindow(w);
|
||||
return;
|
||||
@@ -262,19 +238,16 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
CheckRedrawStationCoverage(w);
|
||||
break;
|
||||
|
||||
case WE_DESTROY:
|
||||
if (!WP(w,def_d).close) ResetObjectToPlace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const Widget _build_dock_station_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 74, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 147, 14, 74, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 14, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
||||
{ WWT_CLOSEBOX, 14, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -286,12 +259,12 @@ static const WindowDesc _build_dock_station_desc = {
|
||||
BuildDockStationWndProc
|
||||
};
|
||||
|
||||
static void ShowBuildDockStationPicker(void)
|
||||
static void ShowBuildDockStationPicker()
|
||||
{
|
||||
AllocateWindowDesc(&_build_dock_station_desc);
|
||||
}
|
||||
|
||||
static void UpdateDocksDirection(void)
|
||||
static void UpdateDocksDirection()
|
||||
{
|
||||
if (_ship_depot_direction != 0) {
|
||||
SetTileSelectSize(1, 2);
|
||||
@@ -302,7 +275,7 @@ static void UpdateDocksDirection(void)
|
||||
|
||||
static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
w->click_state = (1<<3) << _ship_depot_direction;
|
||||
DrawWindowWidgets(w);
|
||||
@@ -314,7 +287,10 @@ static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
|
||||
return;
|
||||
|
||||
case WE_CLICK: {
|
||||
switch (e->click.widget) {
|
||||
switch(e->click.widget) {
|
||||
case 0:
|
||||
ResetObjectToPlace();
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
_ship_depot_direction = e->click.widget - 3;
|
||||
@@ -326,21 +302,18 @@ static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
|
||||
} break;
|
||||
|
||||
case WE_MOUSELOOP:
|
||||
if (WP(w,def_d).close) DeleteWindow(w);
|
||||
break;
|
||||
|
||||
case WE_DESTROY:
|
||||
if (!WP(w,def_d).close) ResetObjectToPlace();
|
||||
if (WP(w,def_d).close)
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const Widget _build_docks_depot_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 85, 0x0, STR_NULL},
|
||||
{ WWT_PANEL, RESIZE_NONE, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
|
||||
{ WWT_PANEL, RESIZE_NONE, 14, 103, 200, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 203, 14, 85, 0x0, STR_NULL},
|
||||
{ WWT_PANEL, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
|
||||
{ WWT_PANEL, 14, 103, 200, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -353,14 +326,14 @@ static const WindowDesc _build_docks_depot_desc = {
|
||||
};
|
||||
|
||||
|
||||
static void ShowBuildDocksDepotPicker(void)
|
||||
static void ShowBuildDocksDepotPicker()
|
||||
{
|
||||
AllocateWindowDesc(&_build_docks_depot_desc);
|
||||
UpdateDocksDirection();
|
||||
}
|
||||
|
||||
|
||||
void InitializeDockGui(void)
|
||||
void InitializeDockGui()
|
||||
{
|
||||
_ship_depot_direction = 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ On BeOS, run ./configure and then use jam. There are a variaty of options you ca
|
||||
On Windows, insert your "Transport Tycoon Deluxe for Windows 95" disk. You can use a DOS version, but your graphics will be purple. NB: Even if your version of Transport Tycoon Deluxe ran on Windows 95, it may still be the DOS version. Then run the OpenTTD installer.
|
||||
|
||||
On UNIX platforms; decompress your OpenTTD archive, or otherwise run the installer. You should be left with an OpenTTD directory on your system. In this directory, make a subdirectory called 'data', and into this place the sample.cat file and all the .grf files from the install CD of 'Transport Tycoon Deluxe for Windows 95".
|
||||
(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
|
||||
(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
|
||||
|
||||
If you want MIDI music, copy the 'gm' folder from the original game directory/CD to the OpenTTD folder.
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
To install OpenTTD, you should drag the game to any location you want and in that folder, you should create a folder called "data". It should contain:
|
||||
sample.cat
|
||||
trg1r.grf
|
||||
trgcr.grf
|
||||
trghr.grf
|
||||
trgir.grf
|
||||
trgtr.grf
|
||||
|
||||
(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
|
||||
|
||||
You should also use the data folder to add any custom grf files if you like
|
||||
|
||||
if you want music, you can add a GM folder and add all .gm files from TTD inside it
|
||||
|
||||
If you want to use the scenarios, you can copy the scenario folder as well. If you already have one, just copy the content so you don't overwrite old ones that have been removed.
|
||||
|
||||
In the end, you should have a folder containing:
|
||||
OpenTTD (the actual game)
|
||||
data (containing the grf files)
|
||||
GM (optional for music)
|
||||
scenario (optional pregenerated maps)
|
||||
|
||||
The game adds some items by itself when it runs, like a save folder and a setting file
|
||||
@@ -0,0 +1,24 @@
|
||||
It's gone
|
||||
|
||||
The main goal with the package system was to make it as simple as possible to update. The problem was that some files inside the data folder should be updated and not others. Now the data files have been moved inside OpenTTD itself and to make it even easier, the same goes for the lang dir. There will no longer be an issue where people have different versions of grf files, language files and OpenTTD.
|
||||
|
||||
To install simply copy OpenTTD into the folder you want
|
||||
If it is your current folder with outdated grf files, you should remove
|
||||
canalsw.grf
|
||||
openttd.grf
|
||||
opntitle.dat
|
||||
signalsw.grf
|
||||
trkfoundw.grf
|
||||
|
||||
THE TTD GRF FILES ARE STILL NEEDED!
|
||||
They need to be inside a folder called "data" in the same folder as OpenTTD. Create it if you have none. It should contain:
|
||||
sample.cat
|
||||
trg1r.grf
|
||||
trgcr.grf
|
||||
trghr.grf
|
||||
trgir.grf
|
||||
trgtr.grf
|
||||
|
||||
(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
|
||||
|
||||
You should also use the data folder to add any custom grf files if you like
|
||||
@@ -1,10 +0,0 @@
|
||||
There are currently two different downloads for OSX, one is named osx, while the other one is named osx-jaguar
|
||||
|
||||
The reason for this is that Apple added more functionality to 10.3 and to make use of that, it will no longer run on OSX 10.2 (codenamed Jaguar). To make the game useable on Jaguar, then a special download is available, but it will miss the bugfixes/features, that relies on newer functionality.
|
||||
|
||||
The general download is a universal binary and should work great on all macs using 10.3.9 or newer, no matter what processor it got. You should at all time avoid the Jaguar Build if possible.
|
||||
|
||||
Technically the universal binary is a triple binary because it contains code for 3 CPUs and the CPUs in question are PPC (G3+G4), G5 and Intel. The Jaguar build is only optimised for PPC and other (newer) CPUs will not benefit so much from their advanced features. This is another reason to avoid the Jaguar build. It's generally slower on modern CPUs.
|
||||
|
||||
Current list of missing features in the Jaguar build:
|
||||
-Can't save screenshots or savegames if certain chars are in the filename. This mainly applies to European chars and hits German hard as the month Mär (Mar) can't be saved
|
||||
@@ -0,0 +1,36 @@
|
||||
Since you are reading this, OpenTTD have crashed. This file tells you how
|
||||
to fix the most common problems or make to make a bug report, that the
|
||||
developers can use to track down the problem
|
||||
|
||||
If it is an assert, OpenTTD will open the console for you, if it is truly a crash, you have to do it yourself. The Console is located at /Applications/Utilities/Console.
|
||||
The problem is near the button of the page
|
||||
|
||||
The problems are as follows:
|
||||
NOTE: build from source means to download the source and compile
|
||||
yourself. If you get one of the build from source error with the version
|
||||
that is downloaded on a dmg file, you should make a bug report
|
||||
|
||||
--Didn't find a needed file:
|
||||
you just give it the file it asks for. It even tells you what
|
||||
folder it wants it in
|
||||
most common version of this problem is "Error: Cannot open file
|
||||
'data/sample.cat'"
|
||||
if you get that one, that means that you haven't got all the
|
||||
needed files from the WINDOWS version of TTD
|
||||
or if you build from source,
|
||||
|
||||
--Error: No available language packs
|
||||
you need at least one .lng file in your lang folder. This applies
|
||||
only to people who build from source
|
||||
|
||||
--spritecache.c:237: failed assertion `b'
|
||||
you got an outdated grf file. Update from the data folder in the
|
||||
source. This applies only to people, who build from source
|
||||
|
||||
--assertion error that are not triggered by one of the errors listed in
|
||||
this file:
|
||||
you most likely found a bug. Write down the assertion and try to
|
||||
see if you can reproduce it. If you can, make a
|
||||
savegame from just before it happens (autosaves are useful here)
|
||||
and post a bugreport with it on sourceforge
|
||||
Write what you did to trigger the bug and what assertion it made
|
||||
@@ -39,7 +39,7 @@ Copy the following files from Transport Tycoon Deluxe to openttd/data/
|
||||
trgir.grf
|
||||
trgtr.grf
|
||||
|
||||
(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
|
||||
(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
|
||||
|
||||
|
||||
4.) Compiling and running:
|
||||
|
||||
+48
-133
@@ -1,133 +1,48 @@
|
||||
OpenTTD: OS/2 version
|
||||
=====================
|
||||
|
||||
OpenTTD has been ported to work on OS/2 4.x or later (including
|
||||
eComStation). The game should work as well as it does on Windows
|
||||
or other platforms: the main issues you may encounter are graphics
|
||||
card problems, but that is really the fault of SDL.
|
||||
|
||||
=========================
|
||||
USING OPENTTD FOR OS/2
|
||||
=========================
|
||||
|
||||
LIBRARIES REQUIRED FOR END USERS
|
||||
--------------------------------
|
||||
|
||||
SDL.DLL (SDL 1.2.7) and FSLib.dll are required to use this program:
|
||||
these can be downloaded from the Files section at
|
||||
http://sourceforge.net/projects/openttd/ - see "os2-useful-v1.1.zip".
|
||||
Version 20051222 of SDL or later is required. This can be found at
|
||||
http://sdl.netlabs.org/.
|
||||
|
||||
Please note that earlier SDL releases will probably NOT work with
|
||||
OpenTTD. If you experience problems with OpenTTD, please check
|
||||
your SDL and FSLib.dll versions (both must match).
|
||||
|
||||
Note that to actually play the game, I have found in my own
|
||||
experience that a version of the Scitech Display Drivers or its later
|
||||
incarnation (see www.scitech.com) are necessary for it to work. If
|
||||
you have trouble with your native drivers, try the Scitech drivers
|
||||
and see if they help the problem.
|
||||
|
||||
KNOWN ISSUES
|
||||
------------
|
||||
|
||||
- If an error occurs during loading, the OS/2 error message window
|
||||
is not always displayed.
|
||||
|
||||
A NOTE ABOUT MUSIC
|
||||
------------------
|
||||
|
||||
OpenTTD includes a music driver which uses the MCI MIDI system. Unfortunately,
|
||||
due to the lack of proper MIDI hardware myself, I have been unable to test it,
|
||||
but during testing, I found that when MIDI was enabled, I got no sound
|
||||
effects. I therefore decided to DISABLE music by default.
|
||||
|
||||
To enable music, start OpenTTD with the command line:
|
||||
|
||||
openttd -m os2
|
||||
|
||||
If I hear enough responses that both music and sound work together (it might
|
||||
just be my system), I'll have the defaults changed.
|
||||
|
||||
A NOTE ABOUT DEDICATED MULTIPLAYER SERVERS
|
||||
------------------------------------------
|
||||
|
||||
To start a dedicated multiplayer server, you should run the dedicated.cmd
|
||||
file. This enables OpenTTD to open up a VIO console window to display
|
||||
its output and gather any necessary input. Running "openttd -D"
|
||||
directly will result in the console not being displayed. You may
|
||||
still pass any other parameters ('-D' is already passed) to
|
||||
dedicated.cmd.
|
||||
|
||||
=========================
|
||||
BUILDING THE OS/2 VERSION
|
||||
=========================
|
||||
|
||||
Compiler
|
||||
--------
|
||||
|
||||
Open Watcom 1.3 was used to build OpenTTD (earlier versions will
|
||||
NOT work). See http://www.openwatcom.org/ to download it. It may
|
||||
also be possible to build OpenTTD with GCC: I attempted this
|
||||
before using Open Watcom, but found the tools available for OS/2
|
||||
at the time to be a bit more tricky to get working.
|
||||
|
||||
Due to complexities in my set-up, I actually used the Win32 version
|
||||
of Open Watcom to initially compile OpenTTD for OS/2. There should
|
||||
be no reason of course why the OS/2 version cannot be used, and I
|
||||
have subsequently built OpenTTD successfully this way.
|
||||
|
||||
Libraries Required
|
||||
------------------
|
||||
|
||||
The following libraries are required. To build zlib and libpng, I
|
||||
simply added the required files (watch out for sample programs, etc)
|
||||
to an IDE project file and built a library. Do not use the makefiles
|
||||
provided, they are not designed for Watcom (apart from SDL):
|
||||
|
||||
- zlib
|
||||
http://www.zlib.org/ - contains a makefile for OS/2, but is out
|
||||
of date and uses EMX, ignore this
|
||||
|
||||
- libpng
|
||||
http://www.libpng.org/ - contains an EMX/gcc makefile, ignore this
|
||||
|
||||
- SDL for OS/2
|
||||
ftp://ftp.netlabs.org/pub/sdl/sdl-1.2.7-src-20051222.zip used for
|
||||
0.4.7
|
||||
|
||||
If you do not wish to build the libraries yourself, pre-built versions
|
||||
can be downloaded from the Files section at
|
||||
http://sourceforge.net/projects/openttd/ - see "os2-useful-v1.1.zip".
|
||||
|
||||
A Note About Subversion Revision Numbers
|
||||
----------------------------------------
|
||||
|
||||
The project file uses a bit of a hack to find out the SVN revision number and
|
||||
create an appropriate rev.c file. You'll need the SVN tools in your path
|
||||
(specifically, "svnversion"). If "svnversion" can't be found, a generic rev.c
|
||||
with the revision set to "norev000" will be created. To specifically force a
|
||||
version number, set the environment variable "RELEASE" to the number (eg, "0.3.6")
|
||||
-before- starting the Open Watcom IDE (which must be launched from the same shell
|
||||
session). Also, beware, as you WILL cause incompatibilities if you try to
|
||||
play a multiplayer game with a different version.
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
To compile, open the os/os2/openttd.wpj file in the IDE and first build
|
||||
the strgen.exe target. This will build the .lng file generator, and will
|
||||
also attempt to build all the language files (plus the table\strings.h
|
||||
file which is required for openttd.exe to be built). Once strgen.exe and
|
||||
the language files are built successfully, you can build the openttd.exe
|
||||
target.
|
||||
|
||||
Contact Information
|
||||
-------------------
|
||||
|
||||
If you have any questions regarding OS/2 issues, please contact me
|
||||
(owen@owenrudge.net) and I'll try to help you out. For general OpenTTD
|
||||
issues, see the Contacting section of readme.txt.
|
||||
|
||||
- Owen Rudge
|
||||
OpenTTD: OS/2 version ** CURRENTLY INCOMPLETE **
|
||||
=====================
|
||||
|
||||
OpenTTD has been ported to work on OS/2 4.x or later (including eComStation). At the moment, it does not work properly, but it
|
||||
can compile and work to an extent.
|
||||
|
||||
Compiler
|
||||
--------
|
||||
|
||||
Open Watcom 1.3 was used to build OpenTTD (earlier versions will NOT work). See http://www.openwatcom.org/ to download it.
|
||||
It may also be possible to build OpenTTD under OS/2: I attempted this before using Open Watcom, but found the tools available
|
||||
for OS/2 at the time to be a bit more tricky to get working.
|
||||
|
||||
Due to complexities in my set-up, I actually used the Win32 version of Open Watcom to initially compile OpenTTD for OS/2. There
|
||||
should be no reason of course why the OS/2 version cannot be used.
|
||||
|
||||
Libraries Required
|
||||
------------------
|
||||
|
||||
The following libraries are required. To build zlib and libpng, I simply added the required files (watch out for sample
|
||||
programs, etc) to an IDE project file and built a library:
|
||||
|
||||
- zlib
|
||||
http://www.zlib.org/ - contains a makefile for OS/2, but is out of date and uses EMX
|
||||
|
||||
- libpng
|
||||
http://www.libpng.org/ - contains an EMX/gcc makefile
|
||||
|
||||
- SDL for OS/2
|
||||
I used ftp://ftp.netlabs.org/pub/sdl/SDL-1.2.7-src-20040908a.zip - take SDL.dll and SDL.lib from the src/ directory.
|
||||
|
||||
Note that to use the compiled program, you also need FSLib.dll (from src/ in the SDL zip) and a version of the Scitech
|
||||
Display Drivers or its later incarnation (see www.scitech.com).
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
To compile, open the os/os2/openttd.wpj file in the IDE and build the openttd.exe target.
|
||||
|
||||
TODO: compilation of language files properly
|
||||
|
||||
|
||||
** THESE DOCS ARE INCOMPLETE FOR THE MOMENT, WILL BE COMPLETED SOON **
|
||||
|
||||
If you have any questions, please contact me (owen@owenrudge.net) and I'll try to help you out
|
||||
|
||||
- Owen Rudge, 18th December 2004
|
||||
|
||||
|
||||
+89
-104
@@ -1,104 +1,89 @@
|
||||
Compiling OpenTTD using Microsoft Visual C++ 6.0
|
||||
|
||||
|
||||
Step 1: Ingredients
|
||||
|
||||
Download the following files:
|
||||
|
||||
* Openttd-useful.zip (http://sourceforge.net/project/showfiles.php?group_id=103924&package_id=114307&release_id=228633)
|
||||
* DirectX 8.1 SDK (http://neuron.tuke.sk/~mizanin/eng/Dx81sdk-include-lib.rar) (or alternatively the latest DirectX SDK from Microsoft)
|
||||
* The February 2003 Microsoft Platform SDK (http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm) (newer SDK's do not work with MSVC6)
|
||||
* afxres.h (http://www-d0.fnal.gov/d0dist/dist/packages/d0ve/devel/windows/AFXRES.H) (maybe you not need this)
|
||||
|
||||
...and of course the newest source from svn://svn.openttd.org/trunk
|
||||
|
||||
You have to have a SVN-client to download the source:
|
||||
|
||||
* Command line version (Subversion 1.2.3 Win32 binaries) (http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91)
|
||||
* GUI TortoiseSVN (http://tortoisesvn.tigris.org/download.html)
|
||||
|
||||
Step 2: Includes and Libraries
|
||||
|
||||
Put the newly downloaded files in the VC lib and include directories (Where "C:\Program Files\Microsoft Visual Studio\VC98" is your local location of VC)
|
||||
|
||||
|
||||
* zconf.h [useful.zip]
|
||||
* zlib.h [useful.zip]
|
||||
* png.h [useful.zip]
|
||||
* pngconf.h [useful.zip]
|
||||
* afxres.h
|
||||
|
||||
in
|
||||
|
||||
C:\Program Files\Microsoft Visual Studio\VC98\Include
|
||||
|
||||
and
|
||||
|
||||
* zlibstat.lib [useful.zip]
|
||||
* libpng.lib [useful.zip]
|
||||
|
||||
in
|
||||
|
||||
C:\Program Files\Microsoft Visual Studio\VC98\Lib
|
||||
|
||||
|
||||
Step 3: DirectX SDK
|
||||
|
||||
(This should work with the latest DirectX SDK as well.)
|
||||
|
||||
There are 2 folder in the compressed file: Include and Lib
|
||||
|
||||
Copy all files from Include folder to
|
||||
|
||||
C:\Program Files\Microsoft Visual Studio\VC98\Include
|
||||
|
||||
and all files from Lib folder to
|
||||
|
||||
C:\Program Files\Microsoft Visual Studio\VC98\Lib
|
||||
|
||||
|
||||
|
||||
You can also make custom directories, which is recommended so you don't overwrite VS6 files, for libraries (.lib) and includes/header files (.h) and add it to the VC paths via:
|
||||
|
||||
Tools -> Options -> Directories -> show directories for:
|
||||
|
||||
a) include files (the include dir: C:\Program Files\Microsoft Visual Studio\VC98\DirectX 8.1 SDK\include )
|
||||
|
||||
b) library files (the lib dir, C:\Program Files\Microsoft Visual Studio\VC98\DirectX 8.1 SDK\lib )
|
||||
|
||||
NOTE: make sure that the directory for the DirectX SDK is the first one in the list, above all others, otherwise compilation will most likely fail!!
|
||||
|
||||
Step 4: TTD Graphics files
|
||||
|
||||
Copy the following files from Transport Tycoon Deluxe to the data folder
|
||||
|
||||
* sample.cat
|
||||
* trg1r.grf
|
||||
* trgcr.grf
|
||||
* trghr.grf
|
||||
* trgir.grf
|
||||
* trgtr.grf
|
||||
|
||||
|
||||
Step 5: Compiling
|
||||
|
||||
Open trunk/openttd.dsw
|
||||
|
||||
Build menu > Set active configuration > Select: "openttd - Win32 Release"
|
||||
|
||||
Compile...
|
||||
|
||||
|
||||
Now it should work, it worked for me :)
|
||||
|
||||
From r1319 you can compile branch/map in Debug mode (by Bociusz)
|
||||
|
||||
For compiling branch/cargo-packets you have to add cargo.c and .h to this tree's openttd.dsp
|
||||
|
||||
If it's not working, and you checked that you using the newest SVN (!) report to Bociusz on IRC (irc://irc.freenode.net/openttd)
|
||||
|
||||
Go ahead and make that patch! Happy Hacking! :)
|
||||
|
||||
Originally written by Dribbel
|
||||
|
||||
Project file updating by Bociusz
|
||||
Compilung OpenTTD using MS VC6.0
|
||||
|
||||
|
||||
Step 1
|
||||
------------------
|
||||
Downloaded:
|
||||
Useful.zip http://sourceforge.net/project/showfiles.php?group_id=103924&package_id=114307&release_id=228633
|
||||
SDL.zip http://www.libsdl.org/release/SDL-1.2.7-win32.zip
|
||||
DirectX7.0 SDK http://www.tt-forums.net/download.php?id=15989
|
||||
(or alternatively the latest DirectX SDK from Microsoft)
|
||||
afxres.h http://www-d0.fnal.gov/d0dist/dist/packages/d0ve/devel/windows/AFXRES.H
|
||||
|
||||
|
||||
Step 2
|
||||
------------------
|
||||
Put the newly downloaded files in the VC lib and include directories
|
||||
(Where D:\program files\ is your local location of VC)
|
||||
|
||||
|
||||
* zconf.h [useful.zip]
|
||||
* zlib.h [useful.zip]
|
||||
* afxres.h
|
||||
in
|
||||
D:\Program Files\Microsoft Visual Studio\VC98\Include
|
||||
|
||||
* zlibstat.lib [usefull.zip]
|
||||
* SDL.lib [SDL.zip
|
||||
* libpng.lib [usefull.zip]
|
||||
in
|
||||
D:\Program Files\Microsoft Visual Studio\VC98\Lib
|
||||
|
||||
You can also make custum directories, for libraries (.lib) and includes/header files (.h) and
|
||||
add it to the VC paths via:
|
||||
Tools -> Options -> Directories -> show directories for:
|
||||
a) include files (the include dir: D:\Program Files\Microsoft Visual Studio\VC98\DirectX 7 SDK\include )
|
||||
b) library files (the lib dir, D:\Program Files\Microsoft Visual Studio\VC98\DirectX 7 SDK\lib )
|
||||
|
||||
|
||||
Step 3: DirextX SDK
|
||||
------------------
|
||||
(This should work with the latest DirectX SDK as well.)
|
||||
The installation with DirectX 7 was odd, so you'd better use the version available via the forum, see also
|
||||
the download link on top.
|
||||
|
||||
Copy the DirectX 7 SDK files, leaving the directory stucture intact, to the directory:
|
||||
D:\Program Files\Microsoft Visual Studio\VC98\
|
||||
thus resulting in
|
||||
D:\Program Files\Microsoft Visual Studio\VC98\DirectX 7 SDK\include and
|
||||
D:\Program Files\Microsoft Visual Studio\VC98\DirectX 7 SDK\lib
|
||||
|
||||
Step 3.1
|
||||
|
||||
Add these two folders to the search path of VC.
|
||||
In VC6.0: Tools -> Options -> Directories -> show directories for:
|
||||
a) include files (the include dir: D:\Program Files\Microsoft Visual Studio\VC98\DirectX 7 SDK\include )
|
||||
b) libraru files (the lib dir, D:\Program Files\Microsoft Visual Studio\VC98\DirectX 7 SDK\lib )
|
||||
|
||||
|
||||
Step 4
|
||||
-----------------
|
||||
Copy the following files from Transport Tycoon Deluxe to the data folder
|
||||
sample.cat
|
||||
trg1r.grf
|
||||
trgcr.grf
|
||||
trghr.grf
|
||||
trgir.grf
|
||||
trgtr.grf
|
||||
|
||||
(Alternatively you can use the TTD GRF files from the DOS version: TRG1.GRF, TRGC.GRF, TRGH.GRF, TRGI.GRF, TRGT.GRF. Those filenames have to be uppercase to be detected correctly. A few minor graphical glitches with the DOS graphics remain. E.g. the autorail button in the rail toolbar doesn't look as nice as with the Windows graphics.)
|
||||
|
||||
Step 5
|
||||
-----------------
|
||||
Compile ...
|
||||
|
||||
|
||||
Step 6
|
||||
-----------------
|
||||
|
||||
Now it should work, it worked for me :)
|
||||
|
||||
Go ahead and make that patch!
|
||||
|
||||
Happy Hacking!
|
||||
|
||||
|
||||
|
||||
------------------
|
||||
written by Dribbel
|
||||
|
||||
|
||||
+19
-19
@@ -1,20 +1,20 @@
|
||||
Notes about DirectMusic driver for Win32
|
||||
----------------------------------------
|
||||
|
||||
If compiling under MinGW32, you require the DirectX 7.0 files for MinGW32, available from
|
||||
http://alleg.sourceforge.net/files/dx70_mgw.zip.
|
||||
|
||||
If compiling under MSVC 6.0, you require the equivalent for MSVC, available from
|
||||
http://alleg.sourceforge.net/files/dx70_min.zip. MSVC 7.0/7.1 include header files that
|
||||
are recent enough.
|
||||
|
||||
If you do not want to compile the DirectMusic driver, undefine WIN32_ENABLE_DIRECTMUSIC_SUPPORT
|
||||
in stdafx.h.
|
||||
|
||||
Bugs, etc
|
||||
---------
|
||||
|
||||
- The volume control doesn't work properly. I'll fix this soon.
|
||||
|
||||
Owen Rudge
|
||||
Notes about DirectMusic driver for Win32
|
||||
----------------------------------------
|
||||
|
||||
If compiling under MinGW32, you require the DirectX 7.0 files for MinGW32, available from
|
||||
http://alleg.sourceforge.net/files/dx70_mgw.zip.
|
||||
|
||||
If compiling under MSVC 6.0, you require the equivalent for MSVC, available from
|
||||
http://alleg.sourceforge.net/files/dx70_min.zip. MSVC 7.0/7.1 include header files that
|
||||
are recent enough.
|
||||
|
||||
If you do not want to compile the DirectMusic driver, undefine WIN32_ENABLE_DIRECTMUSIC_SUPPORT
|
||||
in stdafx.h.
|
||||
|
||||
Bugs, etc
|
||||
---------
|
||||
|
||||
- The volume control doesn't work properly. I'll fix this soon.
|
||||
|
||||
Owen Rudge
|
||||
14th March 2004
|
||||
+114
-125
@@ -2,29 +2,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta name="Author" content="Marcin Grzegorczyk">
|
||||
<meta name="Description" content="Structure of OpenTTD (OTTD) landscape arrays">
|
||||
<meta name="Description" content="Structure of Transport Tycoon Deluxe (TTD) savegame files">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>OpenTTD Landscape Internals</title>
|
||||
<title>Transport Tycoon Deluxe savegame internals</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3><a name="Landscape">Landscape</a></h3>
|
||||
<p>
|
||||
Five attributes hold the information about a tile.
|
||||
These attributes are referred to as
|
||||
"<span style="font-weight: bold;">type_height</span>",
|
||||
"<span style="font-weight: bold;">m1</span>",
|
||||
"<span style="font-weight: bold;">m2</span>",
|
||||
"<span style="font-weight: bold;">m3</span>",
|
||||
"<span style="font-weight: bold;">m4</span>" and
|
||||
"<span style="font-weight: bold;">m5</span>".
|
||||
The most important value is the class of a tile, stored in the upper 4 bits of the type_height array.
|
||||
The lower 4 bits are used to encode the height and slope data.
|
||||
For a graphical represenation of the tile-layout have a look at <a href="landscape_grid.html">Landscape grid</a> page.
|
||||
Five arrays are used to encode the information of the contents of each tile. These arrays are referred to as <a href="#_landscape1">map_owner</a>, <a href="#_landscape2">map2</a>, <a href="#_landscape3">map3_lo</a>, <a href="#_landscape4">type_and_height</a> and <a href="#_landscape5">map5</a>. The known encodings are listed in the table below. The most important value is the class of a tile, stored in the upper 4 bits of the type_and_height array.
|
||||
</p>
|
||||
<p>
|
||||
OTTD's class-specific periodic tile processing routine is called once every +256 ticks for each tile.
|
||||
<a name="OwnershipInfo">Owner values</a> <tt>00</tt> through <tt>07</tt> are companies (they're indices into the <a href="#_CompanyArray">array of companies</a>), <tt>10</tt> is no owner, <tt>11</tt> appears to be reserved for water, <tt>80</tt> and above are towns (in this case the low 7 bits contain an index into the <a href="#_TownArray">town array</a>).
|
||||
</p>
|
||||
<p>
|
||||
TTD's class-specific periodic tile processing routine is called once every +256 ticks for each tile.
|
||||
</p>
|
||||
|
||||
<table border=1 cellpadding=3>
|
||||
@@ -32,7 +25,7 @@ OTTD's class-specific periodic tile processing routine is called once every +256
|
||||
|
||||
<tr><td valign=top nowrap><a name="Class0"><tt> 0 </tt></a></td><td>
|
||||
<ul>
|
||||
<li>m5 bits 4..0: tile type:
|
||||
<li>map5 bits 4..0: tile type:
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>00</tt> </td><td align=left>bare land</td></tr>
|
||||
<tr><td nowrap valign=top><tt>01</tt> </td><td align=left>1/3 grass</td></tr>
|
||||
@@ -40,7 +33,7 @@ OTTD's class-specific periodic tile processing routine is called once every +256
|
||||
<tr><td nowrap valign=top><tt>03</tt> </td><td align=left>full grass</td></tr>
|
||||
<tr><td nowrap valign=top><tt>07</tt> </td><td align=left>rough land</td></tr>
|
||||
<tr><td nowrap valign=top><tt>0B</tt> </td><td align=left>rocks</td></tr>
|
||||
<tr><td nowrap valign=top><tt>0F</tt> </td><td align=left>fields; type of fields in m3 bits 3..0 (legal values: 0 through 9)</td></tr>
|
||||
<tr><td nowrap valign=top><tt>0F</tt> </td><td align=left>fields; type of fields in map3_lo bits 3..0 (legal values: 0 through 9)</td></tr>
|
||||
<tr><td nowrap valign=top><tt>10</tt> </td><td align=left>1/4 snow</td></tr>
|
||||
<tr><td nowrap valign=top><tt>11</tt> </td><td align=left>2/4 snow</td></tr>
|
||||
<tr><td nowrap valign=top><tt>12</tt> </td><td align=left>3/4 snow</td></tr>
|
||||
@@ -49,20 +42,20 @@ OTTD's class-specific periodic tile processing routine is called once every +256
|
||||
<tr><td nowrap valign=top><tt>17</tt> </td><td align=left>full desert</td></tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m5 bits 7..5: update counter, incremented on every periodic processing for tile types other than <tt>03</tt>, <tt>07</tt>, <tt>0B</tt> and <tt>10</tt> and above, on wraparound the tile is updated (for fields, the type of fields in m3 is increased, for other types the tile type in m5 is increased)
|
||||
<li>map5 bits 7..6: update counter, incremented on every periodic processing for tile types other than <tt>03</tt>, <tt>07</tt>, <tt>0B</tt> and <tt>10</tt> and above, on wraparound the tile is updated (for fields, the type of fields in map3_lo is increased, for other types the tile type in map5 is increased)
|
||||
<br>(for snow and desert, these bits are not used, tile is updated on every periodic processing)
|
||||
</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the tile (normally <tt>10</tt>)
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the tile (normally <tt>10</tt>)
|
||||
</li>
|
||||
<li>m4 bits 7..5: type of hedge on the SW border of the tile (1 through 6, or 0=none); bits 4..2: same for the SE border
|
||||
<li>map3_hi bits 7..5: type of hedge on the SW border of the tile (1 through 6, or 0=none); bits 4..2: same for the SE border
|
||||
</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign=top nowrap><a name="Class1"><tt> 1 </tt></a></td><td>
|
||||
m5 bit 7 clear: railway track
|
||||
map5 bit 7 clear: railway track
|
||||
<ul>
|
||||
<li>m5 bits 0..5: track layout: bit set = track present:
|
||||
<li>map5 bits 0..5: track layout: bit set = track present:
|
||||
<table>
|
||||
<tr><td nowrap valign=top>bit 0: </td><td align=left>in the X direction</td></tr>
|
||||
<tr><td nowrap valign=top>bit 1: </td><td align=left>in the Y direction</td></tr>
|
||||
@@ -71,9 +64,9 @@ m5 bit 7 clear: railway track
|
||||
<tr><td nowrap valign=top>bit 4: </td><td align=left>in the west corner (direction N-S)</td></tr>
|
||||
<tr><td nowrap valign=top>bit 5: </td><td align=left>in the east corner (direction N-S)</td></tr>
|
||||
</table></li>
|
||||
<li>m5 bit 6 set = with signals:
|
||||
<li>map5 bit 6 set = with signals:
|
||||
<ul>
|
||||
<li>m3 bits 7..4: bit set = signal present:
|
||||
<li>map3_lo bits 7..4: bit set = signal present:
|
||||
<ul>
|
||||
<li>For track in the X direction:
|
||||
<table>
|
||||
@@ -100,8 +93,8 @@ m5 bit 7 clear: railway track
|
||||
<tr><td nowrap valign=top>bit 7: </td><td align=left>signal in the N direction on the track in the W corner</td></tr>
|
||||
</table></li>
|
||||
</ul></li>
|
||||
<li>m2 bits 7..4: bit clear = signal shows red; same bits as in m3</li>
|
||||
<li>OpenTTD bits in m4:
|
||||
<li>map2 bits 7..4: bit clear = signal shows red; same bits as in map3_lo</li>
|
||||
<li>OpenTTD bits in map3_hi:
|
||||
<table>
|
||||
<tr><td nowrap valign=top>bits 1..0: </td><td align=left>type of signal:</td></tr>
|
||||
<tr><td nowrap valign=top><tt>00</tt>: </td><td align=left>normal signals</td></tr>
|
||||
@@ -111,9 +104,9 @@ m5 bit 7 clear: railway track
|
||||
<tr><td nowrap valign=top>bit 2: </td><td align=left>set = semaphore signals, clear = light signals</td></tr>
|
||||
</table></li>
|
||||
</ul></li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the track
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the track
|
||||
</li>
|
||||
<li>m2 bits 0..3:
|
||||
<li>map2 bits 0..3:
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>0</tt> </td><td align=left>on bare land</td></tr>
|
||||
<tr><td nowrap valign=top><tt>1</tt> </td><td align=left>on grass, no fences</td></tr>
|
||||
@@ -129,64 +122,60 @@ m5 bit 7 clear: railway track
|
||||
<tr><td nowrap valign=top><tt>B</tt> </td><td align=left>fence on the N side (track in the S corner)</td></tr>
|
||||
<tr><td nowrap valign=top><tt>C</tt> </td><td align=left>on snow or desert</td></tr>
|
||||
</table></li>
|
||||
<li>m3 bits 0..3 = <a name="TrackType">track type</a>: <tt>0</tt> - conventional railway, <tt>1</tt> - monorail, <tt>2</tt> - maglev
|
||||
<li>map3_lo bits 0..3 = <a name="TrackType">track type</a>: <tt>0</tt> - conventional railway, <tt>1</tt> - monorail, <tt>2</tt> - maglev
|
||||
</li>
|
||||
</ul>
|
||||
m5 bits 7 and 6 set: railway depot / checkpoints
|
||||
map5 bits 7 and 6 set: railway depot / checkpoints
|
||||
<ul>
|
||||
<li>m5 value C0..C3: railway depot
|
||||
<br>m5 bits 1..0 - direction: exit towards: <tt>00</tt> = NE, <tt>01</tt> = SE, <tt>02</tt> = SW, <tt>03</tt> = NW</li>
|
||||
<li>m5 value C4..C5: checkpoint
|
||||
<li>map5 value C0..C3: railway depot
|
||||
<br>map5 bits 1..0 - direction: exit towards: <tt>00</tt> = NE, <tt>01</tt> = SE, <tt>02</tt> = SW, <tt>03</tt> = NW</li>
|
||||
<li>map5 value C4..C5: checkpoint
|
||||
<br>bit 0: clear = in X direction, set = in Y direction
|
||||
<br>
|
||||
<br>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the depot / checkpoint</li>
|
||||
<li>m2: For waypoints, index into the array of waypoints.</li>
|
||||
<li>m3 bits 0..3 = <a href="#TrackType">track type</a></li>
|
||||
<li>m3 bit 4 = use custom sprite (valid only for the checkpoint)</li>
|
||||
<li>m4 bits 0..3 = ground type, as per m2 bits 0..3 for railway tiles.</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the depot / checkpoint</li>
|
||||
<li>map3_lo bits 0..3 = <a href="#TrackType">track type</a></li>
|
||||
<li>map3_lo bit 4 = use custom sprite (valid only for the checkpoint)</li>
|
||||
<li>map3_hi = custom station id</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign=top nowrap><a name="Class2"><tt> 2 </tt></a></td><td>
|
||||
m5 bits 7..4 clear: road
|
||||
map5 bits 7..4 clear: road
|
||||
<ul>
|
||||
<li>m5 bits 3..0: road layout: bit set = road piece present:
|
||||
<li>map5 bits 3..0: road layout: bit set = road piece present:
|
||||
<table>
|
||||
<tr><td nowrap valign=top>bit 0: </td><td align=left>NW piece</td></tr>
|
||||
<tr><td nowrap valign=top>bit 1: </td><td align=left>SW piece</td></tr>
|
||||
<tr><td nowrap valign=top>bit 2: </td><td align=left>SE piece</td></tr>
|
||||
<tr><td nowrap valign=top>bit 3: </td><td align=left>NE piece</td></tr>
|
||||
</table></li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the road</li>
|
||||
<li>m2: Index into the array of towns, 0 for non-town roads</li>
|
||||
<li>m4 bits 0..3: counter for the roadworks</li>
|
||||
<li>m4 bits 4..6: <tt>0</tt> - on bare land, <tt>1</tt> - on grass, <tt>2</tt> - paved, <tt>3</tt> - with streetlights, <tt>5</tt> - tree-lined, <tt>6</tt> - on grass with road works, <tt>7</tt> - paved with road works</li>
|
||||
<li>m4 bit 7 set = on snow or desert</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the road</li>
|
||||
<li>map2 bits 0..2: <tt>0</tt> - on bare land, <tt>1</tt> - on grass, <tt>2</tt> - paved, <tt>3</tt> - with streetlights, <tt>5</tt> - tree-lined, <tt>6</tt> - on grass with road works, <tt>7</tt> - paved with road works</li>
|
||||
<li>map3_hi bit 7 set = on snow or desert</li>
|
||||
</ul>
|
||||
m5 bit 4 set, bits 7..5 clear: level crossing
|
||||
map5 bit 4 set, bits 7..5 clear: level crossing
|
||||
<ul>
|
||||
<li>m5 bit 3: clear - road in the X direction, set - road in the Y direction (railway track always perpendicular)</li>
|
||||
<li>m5 bit 2: set if crossing lights are on</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the railway track</li>
|
||||
<li>m2: Index into the array of towns, 0 for non-town roads</li>
|
||||
<li>m3 bits 0..7: <a href="#OwnershipInfo">owner</a> of the road</li>
|
||||
<li>m4 bits 3..0: <a href="#TrackType">track type</a></li>
|
||||
<li>m4 bits 4..6: <tt>0</tt> - on bare land, <tt>1</tt> - on grass, <tt>2</tt> or higher - paved</li>
|
||||
<li>m4 bit 7 set = on snow or desert</li>
|
||||
<li>map5 bit 3: clear - road in the X direction, set - road in the Y direction (railway track always perpendicular)</li>
|
||||
<li>map5 bit 2: set if crossing lights are on</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the railway track</li>
|
||||
<li>map2 bits 0..2: <tt>0</tt> - on bare land, <tt>1</tt> - on grass, <tt>2</tt> or higher - paved</li>
|
||||
<li>map3_lo bits 0..7: <a href="#OwnershipInfo">owner</a> of the road</li>
|
||||
<li>map3_hi bits 3..0: <a href="#TrackType">track type</a></li>
|
||||
<li>map3_hi bit 7 set = on snow or desert</li>
|
||||
</ul>
|
||||
m5 bit 5 set: road depot
|
||||
map5 bit 5 set: road depot
|
||||
<ul>
|
||||
<li>m5 bits 3..0 - direction: exit towards: <tt>0</tt> = NE, <tt>1</tt> = SE, <tt>2</tt> = SW, <tt>3</tt> = NW</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the depot</li>
|
||||
<li>m4 bit 7 set = on snow or desert (not displayed, but set internally)</li>
|
||||
<li>map5 bits 3..0 - direction: exit towards: <tt>0</tt> = NE, <tt>1</tt> = SE, <tt>2</tt> = SW, <tt>3</tt> = NW</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the depot</li>
|
||||
<li>map3_hi bit 7 set = on snow or desert (not displayed, but set internally)</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign=top nowrap><a name="Class3"><tt> 3 </tt></a></td><td>
|
||||
Town building
|
||||
<ul>
|
||||
<li>m2: Index into the array of towns</li>
|
||||
<li>m4: <a name="HouseTypes">town building type</a>:
|
||||
<li>map2: <a name="HouseTypes">town building type</a>:
|
||||
<p><small>Note: In the climate list, 'sub-arctic' means below the <a href="#_snowline">snow line</a>, and 'snow' means above the snow line in the sub-arctic climate.</small></p>
|
||||
<table>
|
||||
<tr><th align=left>Type </th><th align=left>Size </th><th align=left>Climates </th><th align=left>Description</th></tr>
|
||||
@@ -276,13 +265,13 @@ Town building
|
||||
<tr><td nowrap valign=top><tt>6D</tt> </td><td>1×1</td><td>toyland</td><td align=left>piggy-bank</td></tr>
|
||||
<tr><td colspan=2></td></tr> <!-- spacer -- -- (and I don't mean a walk) -->
|
||||
</table></li>
|
||||
<li>m3 bits 7..6: stage of construction (<tt>3</tt> = completed)</li>
|
||||
<li>m5 bits 2..0: construction counter, for buildings under construction incremented on every periodic tile processing, on wraparound the stage of construction in m3 is increased</li>
|
||||
<li>map3_lo bits 7..6: stage of construction (<tt>3</tt> = completed)</li>
|
||||
<li>map5 bits 2..0: construction counter, for buildings under construction incremented on every periodic tile processing, on wraparound the stage of construction in map3_lo is increased</li>
|
||||
<li>for large office blocks (types <tt>04</tt> and <tt>05</tt>):
|
||||
<ul>
|
||||
<li>m1 bits 6..0: position of the lift</li>
|
||||
<li>m1 bit 7: if set the lift is moving</li>
|
||||
<li>m5 bit 7: if set then m5 bits 5..0 hold the destination floor of the lift, which could be 0..6, except 1, so the building has 6 effective floors. This due to the fact that the first floor is 2 'normal' floors high. One 'normal' floor has a height of 6 lift positions.</li>
|
||||
<li>map_owner bits 6..0: position of the lift</li>
|
||||
<li>map_owner bit 7: if set the lift is moving</li>
|
||||
<li>map5 bit 7: if set then map5 bits 5..0 hold the final position of the lift divided by 6 (valid values 0..6 except 1)</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
@@ -290,9 +279,9 @@ Town building
|
||||
<tr><td valign=top nowrap><a name="Class4"><tt> 4 </tt></a></td><td>
|
||||
Trees
|
||||
<ul>
|
||||
<li>m5 bits 7..6: number of trees minus one</li>
|
||||
<li>m5 bits 2..0: growth status: <tt>0</tt>..<tt>2</tt> - one of trees is growing, <tt>3</tt> - all trees are fully grown, <tt>4</tt>..<tt>6</tt> - one of trees is withering</li>
|
||||
<li>m3 bits 7..0: type of trees:
|
||||
<li>map5 bits 7..6: number of trees minus one</li>
|
||||
<li>map5 bits 2..0: growth status: <tt>0</tt>..<tt>2</tt> - one of trees is growing, <tt>3</tt> - all trees are fully grown, <tt>4</tt>..<tt>6</tt> - one of trees is withering</li>
|
||||
<li>map3_lo bits 7..0: type of trees:
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>00</tt>..<tt>0B</tt> </td><td align=left>temperate climate trees</td></tr>
|
||||
<tr><td nowrap valign=top><tt>0C</tt>..<tt>13</tt> </td><td align=left>sub-arctic climate trees</td></tr>
|
||||
@@ -303,24 +292,24 @@ Trees
|
||||
</table>
|
||||
(note: the actually displayed set of trees depends on both type and number of trees)
|
||||
</li>
|
||||
<li>m4 bits 7..5: type of hedge on the SW border of the tile (1 through 6, or 0=none)</li>
|
||||
<li>m4 bits 4..2: type of hedge on the SE border of the tile (1 through 6, or 0=none)</li>
|
||||
<li>m2 bits 5..4:
|
||||
<li>map3_hi bits 7..5: type of hedge on the SW border of the tile (1 through 6, or 0=none)</li>
|
||||
<li>map3_hi bits 4..2: type of hedge on the SE border of the tile (1 through 6, or 0=none)</li>
|
||||
<li>map2 bits 5..4:
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>0</tt> </td><td align=left>on grass</td></tr>
|
||||
<tr><td nowrap valign=top><tt>1</tt> </td><td align=left>on rough land</td></tr>
|
||||
<tr><td nowrap valign=top><tt>2</tt> </td><td align=left>on snow or desert; m2 bits 7..6 - amount of snow or desert (for desert always set to 3 in TTD)
|
||||
<tr><td nowrap valign=top><tt>2</tt> </td><td align=left>on snow or desert; map2 bits 7..6 - amount of snow or desert (for desert always set to 3 in TTD)
|
||||
</td></tr>
|
||||
</table></li>
|
||||
<li>m2 bits 3..0: update counter, incremented on every periodic processing, on wraparound the growth status is updated (or, if it's <tt>3</tt>, a random action is taken)</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> (normally <tt>10</tt>)</li>
|
||||
<li>map2 bits 3..0: update counter, incremented on every periodic processing, on wraparound the growth status is updated (or, if it's <tt>3</tt>, a random action is taken)</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> (normally <tt>10</tt>)</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign=top nowrap><a name="Class5"><tt> 5 </tt></a></td><td>
|
||||
Station tile
|
||||
<ul>
|
||||
<li>m5: tile type:
|
||||
<li>map5: tile type:
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>00</tt>..<tt>07</tt> </td><td align=left>railway station
|
||||
<br><tt>00</tt>..<tt>01</tt> - open platform, <tt>02</tt>..<tt>03</tt> - open platform with station building, <tt>04</tt>....<tt>07</tt> - roofed platform
|
||||
@@ -378,17 +367,17 @@ exit towards: <tt>47</tt> - NE, <tt>48</tt> - SE, <tt>49</tt> - SW, <tt>4A</tt>
|
||||
<tr><td colspan=2></td></tr> <!-- spacer -->
|
||||
</table>
|
||||
</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the station</li>
|
||||
<li>m2: index into the <a href="#_StationArray">array of stations</a></li>
|
||||
<li>m3 bits 0..3: <a href="#TrackType">track type</a> for railway stations, must be 0 for all the other stations</li>
|
||||
<li>m3 bit 4 = use custom sprite (valid only railway stations FOR NOW)</li>
|
||||
<li>m4 = custom station id</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the station</li>
|
||||
<li>map2: index into the <a href="#_StationArray">array of stations</a></li>
|
||||
<li>map3_lo bits 0..3: <a href="#TrackType">track type</a> for railway stations, must be 0 for all the other stations</li>
|
||||
<li>map3_lo bit 4 = use custom sprite (valid only railway stations FOR NOW)</li>
|
||||
<li>map3_hi = custom station id</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign=top nowrap><a name="Class6"><tt> 6 </tt></a></td><td>
|
||||
<ul>
|
||||
<li>m5: tile type:
|
||||
<li>map5: tile type:
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>00</tt> </td><td align=left>water</td></tr>
|
||||
<tr><td nowrap valign=top><tt>01</tt> </td><td align=left>coast or riverbank</td></tr>
|
||||
@@ -419,7 +408,7 @@ exit towards: <tt>47</tt> - NE, <tt>48</tt> - SE, <tt>49</tt> - SW, <tt>4A</tt>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table></li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> (for water and coasts normally <tt>11</tt>)</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> (for water and coasts normally <tt>11</tt>)</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
@@ -433,19 +422,19 @@ Tiles of this class form an invisible, one tile wide border at the south (bottom
|
||||
<tr><td valign=top nowrap><a name="Class8"><tt> 8 </tt></a></td><td>
|
||||
Industry tile
|
||||
<ul>
|
||||
<li>m5: type:
|
||||
<li>map5: type:
|
||||
<br><small>(note: this is not the same as the <a href="#industry.type">industry type</a> stored in the <a href="#_IndustryArray">array of industries</a>)</small>
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>00</tt>..<tt>06</tt> </td><td align=left>coal mine
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>00</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>01</tt> </td><td align=left>wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>01</tt> </td><td align=left>wheel tower when animated; animation state in map_owner bits 5..0; map_owner bit 6 set = sound already generated</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td nowrap valign=top><tt>07</tt>..<tt>0A</tt> </td><td align=left>power station
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>08</tt> </td><td align=left>chimney</td></tr>
|
||||
<tr><td nowrap valign=top><tt>0A</tt> </td><td align=left>transformer; animation progress in m1 bits 5..2 (valid range <tt>0</tt>..<tt>7</tt>)</td></tr>
|
||||
<tr><td nowrap valign=top><tt>0A</tt> </td><td align=left>transformer; animation progress in map_owner bits 5..2 (valid range <tt>0</tt>..<tt>7</tt>)</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td nowrap valign=top><tt>0B</tt>..<tt>0F</tt> </td><td align=left>sawmill</td></tr>
|
||||
@@ -459,7 +448,7 @@ Industry tile
|
||||
<tr><td nowrap valign=top><tt>1D</tt>..<tt>20</tt> </td><td align=left>oil wells
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>1D</tt> </td><td align=left>not animated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>1E</tt>..<tt>20</tt> </td><td align=left>various stages of animation; progress of animation in m1 bits 1..0</td></tr>
|
||||
<tr><td nowrap valign=top><tt>1E</tt>..<tt>20</tt> </td><td align=left>various stages of animation; progress of animation in map_owner bits 1..0</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td nowrap valign=top><tt>21</tt>..<tt>26</tt> </td><td align=left>farm</td></tr>
|
||||
@@ -468,7 +457,7 @@ Industry tile
|
||||
<tr><td nowrap valign=top><tt>2F</tt>..<tt>33</tt> </td><td align=left>copper ore mine
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>2F</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>30</tt> </td><td align=left>wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>30</tt> </td><td align=left>wheel tower when animated; animation state in map_owner bits 5..0; map_owner bit 6 set = sound already generated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>31</tt> </td><td align=left>chimney</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
@@ -479,7 +468,7 @@ Industry tile
|
||||
<tr><td nowrap valign=top><tt>48</tt>..<tt>58</tt> </td><td align=left>gold mine
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>4F</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>58</tt> </td><td align=left>wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated</td></tr>
|
||||
<tr><td nowrap valign=top><tt>58</tt> </td><td align=left>wheel tower when animated; animation state in map_owner bits 5..0; map_owner bit 6 set = sound already generated</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td nowrap valign=top><tt>59</tt>..<tt>5A</tt> </td><td align=left>bank (sub-arctic or sub-tropical climate)</td></tr>
|
||||
@@ -506,9 +495,9 @@ Industry tile
|
||||
<tr><td nowrap valign=top><tt>8A</tt>..<tt>8D</tt> </td><td align=left>toy shop</td></tr>
|
||||
<tr><td nowrap valign=top><tt>8E</tt>..<tt>93</tt> </td><td align=left>toy factory
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>8F</tt> </td><td align=left>animated part; animation state in m3 (valid range <tt>00</tt>..<tt>31</tt>)<br>
|
||||
tile animation is started (m4 zeroed) on the periodic processing if <a href="#industry.didtransform">field <tt>2C</tt></a> in the corresponding industry array entry is nonzero<br>
|
||||
while the animation is in progress (see the <a href="#_AnimatedTilesList">array at <tt>04328</tt></a>) m4 holds the number of animation cycles that have already taken place; when this number reaches 8 the animation is stopped</td></tr>
|
||||
<tr><td nowrap valign=top><tt>8F</tt> </td><td align=left>animated part; animation state in map3_lo (valid range <tt>00</tt>..<tt>31</tt>)<br>
|
||||
tile animation is started (map3_hi zeroed) on the periodic processing if <a href="#industry.didtransform">field <tt>2C</tt></a> in the corresponding industry array entry is nonzero<br>
|
||||
while the animation is in progress (see the <a href="#_AnimatedTilesList">array at <tt>04328</tt></a>) map3_hi holds the number of animation cycles that have already taken place; when this number reaches 8 the animation is stopped</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td nowrap valign=top><tt>94</tt>..<tt>9B</tt> </td><td align=left>plastic fountains (various stages of cyclic animation)</td></tr>
|
||||
@@ -516,69 +505,69 @@ while the animation is in progress (see the <a href="#_AnimatedTilesList">array
|
||||
<tr><td nowrap valign=top><tt>A0</tt>..<tt>A3</tt> </td><td align=left>bubble generator
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>A1</tt> </td><td align=left>generators</td></tr>
|
||||
<tr><td nowrap valign=top><tt>A2</tt> </td><td align=left>bubble capture facility; animation state in m3 (valid range <tt>00</tt>..<tt>27</tt>)</td></tr>
|
||||
<tr><td nowrap valign=top><tt>A2</tt> </td><td align=left>bubble capture facility; animation state in map3_lo (valid range <tt>00</tt>..<tt>27</tt>)</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td nowrap valign=top><tt>A4</tt>..<tt>A6</tt> </td><td align=left>toffee quarry
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>A5</tt> </td><td align=left>animated part; animation state in m3 (valid range <tt>00</tt>..<tt>45</tt>)</td></tr>
|
||||
<tr><td nowrap valign=top><tt>A5</tt> </td><td align=left>animated part; animation state in map3_lo (valid range <tt>00</tt>..<tt>45</tt>)</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td nowrap valign=top><tt>A7</tt>..<tt>AE</tt> </td><td align=left>sugar mine
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>AE</tt> </td><td align=left>animated part; animation state in m3 (valid range <tt>00</tt>..<tt>5F</tt>)</td></tr>
|
||||
<tr><td nowrap valign=top><tt>AE</tt> </td><td align=left>animated part; animation state in map3_lo (valid range <tt>00</tt>..<tt>5F</tt>)</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td colspan=2></td></tr> <!-- spacer -->
|
||||
</table></li>
|
||||
<li>m2: index into the <a href="#_IndustryArray">array of industries</a>
|
||||
<li>map2: index into the <a href="#_IndustryArray">array of industries</a>
|
||||
</li>
|
||||
<li>m1 bit 7: clear = under construction
|
||||
<li>map_owner bit 7: clear = under construction
|
||||
<ul>
|
||||
<li>m1 bits 4..2: construction counter, for buildings under construction incremented on every periodic tile processing
|
||||
<li>map_owner bits 4..2: construction counter, for buildings under construction incremented on every periodic tile processing
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>m1 bits 1..0: stage of construction (<tt>3</tt> = completed), incremented when the construction counter wraps around
|
||||
<li>map_owner bits 1..0: stage of construction (<tt>3</tt> = completed), incremented when the construction counter wraps around
|
||||
<br>the meaning is different for some animated tiles which are never under construction (types <tt>01</tt>, <tt>1E</tt>..<tt>20</tt>, <tt>30</tt>, <tt>58</tt>; see above)
|
||||
</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign=top nowrap><a name="Class9"><tt> 9 </tt></a></td><td>
|
||||
m5 bits 7..4 clear: tunnel entrance/exit
|
||||
map5 bits 7..4 clear: tunnel entrance/exit
|
||||
<ul>
|
||||
<li>m5 bits 3..2: <tt>0</tt> - railway tunnel, <tt>1</tt> - road tunnel</li>
|
||||
<li>m5 bits 1..0 - direction: entrance towards: <tt>0</tt> = NE, <tt>1</tt> = SE, <tt>2</tt> = SW, <tt>3</tt> = NW</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the tunnel</li>
|
||||
<li>m3 bits 3..0 = <a href="#TrackType">track type</a> for railway tunnel, must be 0 for road tunnel</li>
|
||||
<li>m4 bit 7 set = on snow or desert</li>
|
||||
<li>map5 bits 3..2: <tt>0</tt> - railway tunnel, <tt>1</tt> - road tunnel</li>
|
||||
<li>map5 bits 1..0 - direction: entrance towards: <tt>0</tt> = NE, <tt>1</tt> = SE, <tt>2</tt> = SW, <tt>3</tt> = NW</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the tunnel</li>
|
||||
<li>map3_lo bits 3..0 = <a href="#TrackType">track type</a> for railway tunnel, must be 0 for road tunnel</li>
|
||||
<li>map3_hi bit 7 set = on snow or desert</li>
|
||||
</ul>
|
||||
m5 bit 7 set: bridge
|
||||
map5 bit 7 set: bridge
|
||||
<ul><li>
|
||||
m5 bit 6 clear: bridge ending
|
||||
map5 bit 6 clear: bridge ending
|
||||
<ul>
|
||||
<li>m5 bit 5: clear - northern, set - southern ending</li>
|
||||
<li>m3 bits 3..0 = <a href="#TrackType">type of track</a> on the bridge, must be 0 for road bridge</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the bridge</li>
|
||||
<li>map5 bit 5: clear - northern, set - southern ending</li>
|
||||
<li>map3_lo bits 3..0 = <a href="#TrackType">type of track</a> on the bridge, must be 0 for road bridge</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the bridge</li>
|
||||
</ul>
|
||||
m5 bit 6 set: bridge middle part
|
||||
map5 bit 6 set: bridge middle part
|
||||
<ul>
|
||||
<li>m5 bit 5 clear:
|
||||
<li>map5 bit 5 clear:
|
||||
<ul>
|
||||
<li>m5 bits 4..3: land under bridge: <tt>0</tt> - grass, snow or desert, <tt>1</tt> - water</li>
|
||||
<li>map5 bits 4..3: land under bridge: <tt>0</tt> - grass, snow or desert, <tt>1</tt> - water</li>
|
||||
</ul>
|
||||
m5 bit 5 set:
|
||||
map5 bit 5 set:
|
||||
<ul>
|
||||
<li>m5 bits 4..3: transport route under bridge: <tt>0</tt> - railway, <tt>1</tt> - road</li>
|
||||
<li>map5 bits 4..3: transport route under bridge: <tt>0</tt> - railway, <tt>1</tt> - road</li>
|
||||
</ul>
|
||||
<li>m3 bits 7..4 = <a href="#TrackType">type of track</a> on the bridge, must be 0 for road bridge</li>
|
||||
<li>m3 bits 3..0 = <a href="#TrackType">type of track</a> under the bridge, if any</li>
|
||||
<li>m2 bits 3..0: bridge piece (<tt>0</tt>..<tt>5</tt>)
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the land under bridge</li>
|
||||
<li>map3_lo bits 7..4 = <a href="#TrackType">type of track</a> on the bridge, must be 0 for road bridge</li>
|
||||
<li>map3_lo bits 3..0 = <a href="#TrackType">type of track</a> under the bridge, if any</li>
|
||||
<li>map2 bits 3..0: bridge piece (<tt>0</tt>..<tt>5</tt>)
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the land under bridge</li>
|
||||
</ul></li>
|
||||
<li>m5 bits 2..1: <tt>0</tt> - railway bridge, <tt>1</tt> - road bridge</li>
|
||||
<li>m5 bit 0: clear - bridge in the X direction, set - bridge in the Y direction</li>
|
||||
<li>m2 bits 7..4: <a name="BridgeType">bridge type</a>:
|
||||
<li>map5 bits 2..1: <tt>0</tt> - railway bridge, <tt>1</tt> - road bridge</li>
|
||||
<li>map5 bit 0: clear - bridge in the X direction, set - bridge in the Y direction</li>
|
||||
<li>map2 bits 7..4: <a name="BridgeType">bridge type</a>:
|
||||
<table>
|
||||
<tr><th align=left>Type </th><th align=left>Max. speed (mph) </th><th align=left>Description</th></tr>
|
||||
<tr><td nowrap valign=top><tt>0</tt> </td><td align=center>20</td><td align=left>wooden</td></tr>
|
||||
@@ -593,13 +582,13 @@ m5 bit 5 set:
|
||||
<tr><td nowrap valign=top><tt>9</tt> </td><td align=center>160</td><td align=left>girder, steel</td></tr>
|
||||
<tr><td nowrap valign=top><tt>A</tt> </td><td align=center>200</td><td align=left>tubular, steel</td></tr>
|
||||
</table></li>
|
||||
<li>m4 bit 7 set = on snow or desert</li>
|
||||
<li>map3_hi bit 7 set = on snow or desert</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign=top nowrap><a name="ClassA"><tt> A </tt></a></td><td>
|
||||
<ul>
|
||||
<li>m5: tile type:
|
||||
<li>map5: tile type:
|
||||
<table>
|
||||
<tr><td nowrap valign=top><tt>00</tt> </td><td align=left>transmitter</td></tr>
|
||||
<tr><td nowrap valign=top><tt>01</tt> </td><td align=left>lighthouse</td></tr>
|
||||
@@ -608,18 +597,18 @@ m5 bit 5 set:
|
||||
<tr><td nowrap valign=top><tt>80</tt>..<tt>93</tt> </td><td align=left>company headquarters (5 sets of 4 tiles each, updated quarterly depending on the company performance)</td></tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m1: <a href="#OwnershipInfo">owner</a> of the object (for lighthouses and transmitters normally <tt>10</tt>)</li>
|
||||
<li>map_owner: <a href="#OwnershipInfo">owner</a> of the object (for lighthouses and transmitters normally <tt>10</tt>)</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
||||
<tr><td colspan=2>
|
||||
Classes <tt>B</tt> through <tt>F</tt> are reserved. The presence of a tile in one of the reserved classes will crash OTTD.
|
||||
Classes <tt>B</tt> through <tt>F</tt> are reserved. The presence of a tile in one of the reserved classes will crash TTD.
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<hr>
|
||||
Original Copyright © 2003 by Marcin Grzegorczyk for TTDLX.<br>
|
||||
Copyright © 2003 by Marcin Grzegorczyk.<br>
|
||||
Transport Tycoon and Transport Tycoon Deluxe are Copyright © by Chris Sawyer. All the other trademarks are the property of their respective owners.<br>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -1,251 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
|
||||
<meta name="Description" content="Structure of OpenTTD (OTTD) landscape arrays #2">
|
||||
<title>OpenTTD Landscape Internals - #2</title>
|
||||
<style type="text/css">
|
||||
span.abuse { font-family: "Courier New", Courier, mono; background-color: rgb(255, 58, 31); }
|
||||
span.free { font-family: "Courier New", Courier, mono; background-color: rgb(30, 178, 54); }
|
||||
span.used { font-family: "Courier New", Courier, mono; }
|
||||
td.bits { white-space: nowrap; text-align: center; font-family: "Courier New", Courier, mono; }
|
||||
td.caption { white-space: nowrap; text-align: left; }
|
||||
td li { white-space: nowrap; text-align: left; }
|
||||
th { white-space: nowrap; text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="direction: ltr;">
|
||||
<h3 style="font-weight: bold;">Landscape</h3>
|
||||
<span style="font-weight: bold;"></span>Five attributes hold the information about a tile.
|
||||
This can be seen in the <a href="landscape.html">Landscape</a> document. This page tries to give an overview of used and free bits of
|
||||
the array so you can quickly see what is used and what is not.
|
||||
<ul>
|
||||
<li><span style="font-weight: bold;"><span class="free">O</span></span> - bit is free</li>
|
||||
<li><span style="font-weight: bold;"><span class="used">X</span></span> - bit is used</li>
|
||||
<li><span style="font-weight: bold;"><span class="abuse"> </span></span> - bit of attribute is abused for different purposes</li>
|
||||
</ul>
|
||||
<p>
|
||||
<ul>
|
||||
<li><span style="font-weight: bold;">type_height</span> - 8 bits in size, stores tile height (lower 4 bits) and tile class (upper 4 bits)</li>
|
||||
<li><span style="font-weight: bold;">m1</span> - 8 bits in size, used to identify the owner of that tile (eg piece of rail, bridge, etc.)</li>
|
||||
<li><span style="font-weight: bold;">m2</span> - 16 bits in size, used to identify the index of the given tile (object) in the (object-)array</li>
|
||||
<li><span style="font-weight: bold;">m3</span> - 8 bits in size, is used for general storage</li>
|
||||
<li><span style="font-weight: bold;">m4</span> - 8 bits in size, is used for general storage</li>
|
||||
<li><span style="font-weight: bold;">m5</span> - 8 bits in size, is used for general storage</li>
|
||||
</ul>
|
||||
|
||||
<table align=center border="1" cellpadding="2" cellspacing="2">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th colspan=2>class</th>
|
||||
<th>m1 (8)</th>
|
||||
<th>m2 (16)</th>
|
||||
<th>m3 (8)</th>
|
||||
<th>m4 (8)</th>
|
||||
<th>type_height (8)</th>
|
||||
<th>m5 (8)</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 class="caption">bits</td>
|
||||
<td class="bits">7654 3210</td>
|
||||
<td class="bits">FEDC BA98 7654 3210</td>
|
||||
<td class="bits">7654 3210</td>
|
||||
<td class="bits">7654 3210</td>
|
||||
<td class="bits">7654 3210</td>
|
||||
<td class="bits">7654 3210</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0</td>
|
||||
<td class="caption">ground</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO</span> XXXX</td>
|
||||
<td class="bits">XXXX XX<span class="free">OO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=3>1</td>
|
||||
<td class="caption">rail</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span> XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO O</span>XXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">depot</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO</span> XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO</span> XXXX</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XX<span class="free">OO O</span>XXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">waypoint</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XXXX XXXX XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOO</span>X XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO</span> XXXX</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XX<span class="free">OO O</span>XXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=3>2</td>
|
||||
<td class="caption">road</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">level crossing</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XXXX XX<span class="free">OO</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">road depot</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits">X<span class="free">OOO OOOO</span></td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td class="caption">town</td>
|
||||
<td class="bits"><span class="abuse">XXXX XXXX</span></td>
|
||||
<td class="bits">XXXX XXXX XXXX XXXX</td>
|
||||
<td class="bits">XX<span class="free">OO OOOO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">X<span class="free">O</span>XX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td class="caption">trees</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span> XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XX<span class="free">OO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XX<span class="free">OO O</span>XXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>5</td>
|
||||
<td class="caption">station</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOO</span>X XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td class="caption">water</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=6>8</td>
|
||||
<td class="caption">industry</td>
|
||||
<td class="bits"><span class="abuse">X</span><span class="free">OO</span><span class="abuse">X XXXX</span></td>
|
||||
<td class="bits">XXXX XXXX XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bubble/sugar/toffee</td>
|
||||
<td class="bits"><span class="abuse">X</span><span class="free">OOO OOOO</span></td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>toy factory</td>
|
||||
<td class="bits"><span class="abuse">X</span><span class="free">OOO OOOO</span></td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>gold/copper/coal</td>
|
||||
<td class="bits"><span class="abuse">XX</span><span class="free">OO OO</span><span class="abuse">XX</span></td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>oil wells</td>
|
||||
<td class="bits"><span class="abuse">X</span><span class="free">OOO OO</span><span class="abuse">XX</span></td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>power station</td>
|
||||
<td class="bits"><span class="abuse">X</span><span class="free">O</span><span class="abuse">XX XX</span><span class="free">OO</span></td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
<td class="bits">-inherit-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=2>9</td>
|
||||
<td class="caption">tunnel</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO</span> XXXX</td>
|
||||
<td class="bits">X<span class="free">OOO OOOO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bridge</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span> <span class="abuse">XXXX XXXX</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">X<span class="free">OOO OOOO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>A</td>
|
||||
<td class="caption">various (HQ)</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+48
-66
@@ -1,68 +1,50 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" First parameter, NAME, should be all caps
|
||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.TH OPENTTD 6 "September 16, 2004"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.Dd August 12, 2006
|
||||
.Dt OPENTTD 6
|
||||
.Sh NAME
|
||||
.Nm openttd
|
||||
.Nd An open source clone of the Microprose game "Transport Tycoon Deluxe"
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl Defhi
|
||||
.Op Fl G Ar seed
|
||||
.Op Fl d Ar [level | cat=lvl[, ...]]
|
||||
.Op Fl g Ar [savegame]
|
||||
.Op Fl n Ar [host[#player][:port]]
|
||||
.Op Fl r Ar widthxheight
|
||||
.Op Fl t Ar date
|
||||
.Op Fl m Ar driver
|
||||
.Op Fl s Ar driver
|
||||
.Op Fl v Ar driver
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width ".Fl n Ar host[#player][:port]"
|
||||
.It Fl D
|
||||
Start a dedicated server
|
||||
.It Fl G Ar seed
|
||||
Seed the pseudo random number generator
|
||||
.It Fl d Ar [level]
|
||||
Set debug verbosity for all categories to
|
||||
.Ar level
|
||||
or 1 if omitted
|
||||
.It Fl d Ar cat=level[, ...]
|
||||
Set debug verbosity for a specific category
|
||||
.It Fl e
|
||||
Start in world editor mode
|
||||
.It Fl f
|
||||
Fork into background (dedicated only, see
|
||||
.Fl D )
|
||||
.It Fl g Ar [savegame]
|
||||
Load
|
||||
.Ar savegame
|
||||
at start or start a new game if omitted
|
||||
.It Fl h
|
||||
Display a summary of all options and available drivers
|
||||
.It Fl i
|
||||
Force to use the DOS palette (use this if you see a lot of magenta)
|
||||
.It Fl m Ar driver
|
||||
Set the music driver, see
|
||||
.Fl h
|
||||
.It Fl n
|
||||
Start a network server
|
||||
.It Fl n Ar host[#player][:port]
|
||||
Join a network game, optionally specify player to play as and port to connect to
|
||||
.It Fl r Ar widthxheight
|
||||
Set the resolution
|
||||
.It Fl s Ar driver
|
||||
Set the sound driver, see
|
||||
.Fl h
|
||||
.It Fl t Ar date
|
||||
Set the starting date
|
||||
.It Fl v Ar driver
|
||||
Set the video driver, see
|
||||
.Fl h
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
http://wiki.openttd.org/
|
||||
.Sh HISTORY
|
||||
Transport Tycoon Deluxe was written by Chris Sawyer and published by Microprose.
|
||||
.Nm
|
||||
is a free reimplementation.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
.\" .nh disable hyphenation
|
||||
.\" .hy enable hyphenation
|
||||
.\" .ad l left justify
|
||||
.\" .ad b justify to both left and right margins
|
||||
.\" .nf disable filling
|
||||
.\" .fi enable filling
|
||||
.\" .br insert line break
|
||||
.\" .sp <n> insert n+1 empty lines
|
||||
.\" for manpage-specific macros, see man(7)
|
||||
.SH NAME
|
||||
openttd \- An open source clone of the Microprose game "Transport Tycoon Deluxe"
|
||||
.SH SYNOPSIS
|
||||
.B openttd
|
||||
.RI [ options ]
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
Unfortanetely, there is no real manpage for openttd yet. Hopefully someone
|
||||
will write one soon. For now you should use
|
||||
.B openttd -h
|
||||
for more information, or check our Wiki manual: http://wiki.openttd.org/
|
||||
.PP
|
||||
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
|
||||
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
|
||||
.\" respectively.
|
||||
.\" \fBopenttd\fP is a program that...
|
||||
.SH OPTIONS
|
||||
Wouldn't we like to have something here?
|
||||
.\" below are commented out, to serve as layout examples for when somebody
|
||||
.\" does actually fill this page
|
||||
.\" .TP
|
||||
.\" .B \-h, \-\-help
|
||||
.\" Show summary of options.
|
||||
.\" .TP
|
||||
.\" .B \-v, \-\-version
|
||||
.\" Show version of program.
|
||||
.\" .SH SEE ALSO
|
||||
.\" .BR bar (1),
|
||||
.\" .BR baz (1).
|
||||
.br
|
||||
.SH AUTHOR
|
||||
This manual page was written by Matthijs Kooijman <matthijs@katherina.student.utwente.nl>,
|
||||
for the Debian project (but may be used by others).
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,38 @@
|
||||
0,9,10,2,3,13,9,9,0,10,4,15,6,11,14,1
|
||||
dark blue=0 =0
|
||||
pale_green=1 =9
|
||||
pink=2 =10
|
||||
yellow=3 =2
|
||||
red=4 =3
|
||||
light blue=5 =13
|
||||
green=6 =9
|
||||
dark green=7 =9
|
||||
blue=8 =0
|
||||
cream=9 =10
|
||||
mauve=10 =4
|
||||
purple=11 =15
|
||||
orange=12 =6
|
||||
brown=13 =11
|
||||
grey=14 =14
|
||||
white=15 =1
|
||||
|
||||
|
||||
=blue=0
|
||||
=white=1
|
||||
=yellow=2
|
||||
=red=3
|
||||
=blue=4
|
||||
=grey=5
|
||||
=orange=6
|
||||
=green=7
|
||||
=light yellow=8
|
||||
=light green=9
|
||||
=cream=10
|
||||
=brown=11
|
||||
=white=12
|
||||
=light blue=13
|
||||
=dark grey=14
|
||||
=purple=15
|
||||
=black=16
|
||||
=dark green=17=not good
|
||||
=dark grey=21
|
||||
@@ -1,224 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "driver.h"
|
||||
#include "functions.h"
|
||||
#include "hal.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "music/bemidi.h"
|
||||
#include "music/dmusic.h"
|
||||
#include "music/extmidi.h"
|
||||
#include "music/null_m.h"
|
||||
#include "music/os2_m.h"
|
||||
#include "music/win32_m.h"
|
||||
#include "music/qtmidi.h"
|
||||
|
||||
#include "sound/null_s.h"
|
||||
#include "sound/sdl_s.h"
|
||||
#include "sound/cocoa_s.h"
|
||||
#include "sound/win32_s.h"
|
||||
|
||||
#include "video/dedicated_v.h"
|
||||
#include "video/null_v.h"
|
||||
#include "video/sdl_v.h"
|
||||
#include "video/cocoa_v.h"
|
||||
#include "video/win32_v.h"
|
||||
|
||||
typedef struct DriverDesc {
|
||||
const char* name;
|
||||
const char* longname;
|
||||
const HalCommonDriver* drv;
|
||||
} DriverDesc;
|
||||
|
||||
typedef struct DriverClass {
|
||||
const DriverDesc *descs;
|
||||
const char *name;
|
||||
const HalCommonDriver** drv;
|
||||
} DriverClass;
|
||||
|
||||
|
||||
#define M(x, y, z) { x, y, (const HalCommonDriver *)(void *)z }
|
||||
static const DriverDesc _music_driver_descs[] = {
|
||||
#ifdef __BEOS__
|
||||
M("bemidi", "BeOS MIDI Driver", &_bemidi_music_driver),
|
||||
#endif
|
||||
#ifdef __OS2__
|
||||
M("os2", "OS/2 Music Driver", &_os2_music_driver),
|
||||
#endif
|
||||
#ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT
|
||||
M("dmusic", "DirectMusic MIDI Driver", &_dmusic_midi_driver),
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
M("win32", "Win32 MIDI Driver", &_win32_music_driver),
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(DEDICATED)
|
||||
M("qt", "QuickTime MIDI Driver", &_qtime_music_driver),
|
||||
#endif
|
||||
#ifdef UNIX
|
||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
|
||||
M("extmidi", "External MIDI Driver", &_extmidi_music_driver),
|
||||
#endif
|
||||
#endif
|
||||
M("null", "Null Music Driver", &_null_music_driver),
|
||||
M(NULL, NULL, NULL)
|
||||
};
|
||||
|
||||
static const DriverDesc _sound_driver_descs[] = {
|
||||
#ifdef WIN32
|
||||
M("win32", "Win32 WaveOut Driver", &_win32_sound_driver),
|
||||
#endif
|
||||
#ifdef WITH_SDL
|
||||
M("sdl", "SDL Sound Driver", &_sdl_sound_driver),
|
||||
#endif
|
||||
#ifdef WITH_COCOA
|
||||
M("cocoa", "Cocoa Sound Driver", &_cocoa_sound_driver),
|
||||
#endif
|
||||
M("null", "Null Sound Driver", &_null_sound_driver),
|
||||
M(NULL, NULL, NULL)
|
||||
};
|
||||
|
||||
static const DriverDesc _video_driver_descs[] = {
|
||||
#ifdef WIN32
|
||||
M("win32", "Win32 GDI Video Driver", &_win32_video_driver),
|
||||
#endif
|
||||
#ifdef WITH_SDL
|
||||
M("sdl", "SDL Video Driver", &_sdl_video_driver),
|
||||
#endif
|
||||
#ifdef WITH_COCOA
|
||||
M("cocoa", "Cocoa Video Driver", &_cocoa_video_driver),
|
||||
#endif
|
||||
M("null", "Null Video Driver", &_null_video_driver),
|
||||
#ifdef ENABLE_NETWORK
|
||||
M("dedicated", "Dedicated Video Driver", &_dedicated_video_driver),
|
||||
#endif
|
||||
M(NULL, NULL, NULL)
|
||||
};
|
||||
#undef M
|
||||
|
||||
|
||||
#define M(x, y, z) { x, y, (const HalCommonDriver **)(void *)z }
|
||||
static const DriverClass _driver_classes[] = {
|
||||
M(_video_driver_descs, "video", &_video_driver),
|
||||
M(_sound_driver_descs, "sound", &_sound_driver),
|
||||
M(_music_driver_descs, "music", &_music_driver)
|
||||
};
|
||||
#undef M
|
||||
|
||||
static const DriverDesc* GetDriverByName(const DriverDesc* dd, const char* name)
|
||||
{
|
||||
for (; dd->name != NULL; dd++) {
|
||||
if (strcmp(dd->name, name) == 0) return dd;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LoadDriver(int driver, const char *name)
|
||||
{
|
||||
const DriverClass *dc = &_driver_classes[driver];
|
||||
const DriverDesc *dd;
|
||||
const char *err;
|
||||
|
||||
if (*name == '\0') {
|
||||
for (dd = dc->descs; dd->name != NULL; dd++) {
|
||||
err = dd->drv->start(NULL);
|
||||
if (err == NULL) break;
|
||||
DEBUG(driver, 1) ("Probing %s driver \"%s\" failed with error: %s",
|
||||
dc->name, dd->name, err
|
||||
);
|
||||
}
|
||||
if (dd->name == NULL) {
|
||||
error("Couldn't find any suitable %s driver", dc->name);
|
||||
}
|
||||
|
||||
DEBUG(driver, 1)
|
||||
("Successfully probed %s driver \"%s\"", dc->name, dd->name);
|
||||
|
||||
*dc->drv = dd->drv;
|
||||
} else {
|
||||
char* parm;
|
||||
char buffer[256];
|
||||
const char* parms[32];
|
||||
|
||||
// Extract the driver name and put parameter list in parm
|
||||
ttd_strlcpy(buffer, name, sizeof(buffer));
|
||||
parm = strchr(buffer, ':');
|
||||
parms[0] = NULL;
|
||||
if (parm != NULL) {
|
||||
uint np = 0;
|
||||
// Tokenize the parm.
|
||||
do {
|
||||
*parm++ = '\0';
|
||||
if (np < lengthof(parms) - 1)
|
||||
parms[np++] = parm;
|
||||
while (*parm != '\0' && *parm != ',')
|
||||
parm++;
|
||||
} while (*parm == ',');
|
||||
parms[np] = NULL;
|
||||
}
|
||||
dd = GetDriverByName(dc->descs, buffer);
|
||||
if (dd == NULL)
|
||||
error("No such %s driver: %s\n", dc->name, buffer);
|
||||
|
||||
if (*dc->drv != NULL) (*dc->drv)->stop();
|
||||
*dc->drv = NULL;
|
||||
|
||||
err = dd->drv->start(parms);
|
||||
if (err != NULL) {
|
||||
error("Unable to load driver %s(%s). The error was: %s\n",
|
||||
dd->name, dd->longname, err
|
||||
);
|
||||
}
|
||||
*dc->drv = dd->drv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char* GetDriverParam(const char* const* parm, const char* name)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (parm == NULL) return NULL;
|
||||
|
||||
len = strlen(name);
|
||||
for (; *parm != NULL; parm++) {
|
||||
const char* p = *parm;
|
||||
|
||||
if (strncmp(p, name, len) == 0) {
|
||||
if (p[len] == '=') return p + len + 1;
|
||||
if (p[len] == '\0') return p + len;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool GetDriverParamBool(const char* const* parm, const char* name)
|
||||
{
|
||||
return GetDriverParam(parm, name) != NULL;
|
||||
}
|
||||
|
||||
int GetDriverParamInt(const char* const* parm, const char* name, int def)
|
||||
{
|
||||
const char* p = GetDriverParam(parm, name);
|
||||
return p != NULL ? atoi(p) : def;
|
||||
}
|
||||
|
||||
|
||||
char *GetDriverList(char* p)
|
||||
{
|
||||
const DriverClass* dc;
|
||||
|
||||
for (dc = _driver_classes; dc != endof(_driver_classes); dc++) {
|
||||
const DriverDesc* dd;
|
||||
|
||||
p += sprintf(p, "List of %s drivers:\n", dc->name);
|
||||
for (dd = dc->descs; dd->name != NULL; dd++) {
|
||||
p += sprintf(p, "%10s: %s\n", dd->name, dd->longname);
|
||||
}
|
||||
p += sprintf(p, "\n");
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef DRIVER_H
|
||||
#define DRIVER_H
|
||||
|
||||
void LoadDriver(int driver, const char *name);
|
||||
|
||||
bool GetDriverParamBool(const char* const* parm, const char* name);
|
||||
int GetDriverParamInt(const char* const* parm, const char* name, int def);
|
||||
|
||||
char *GetDriverList(char* p);
|
||||
|
||||
#endif /* DRIVER_H */
|
||||
+15
-21
@@ -1,67 +1,60 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "viewport.h"
|
||||
#include "command.h"
|
||||
#include "table/sprites.h"
|
||||
|
||||
static void DrawTile_Dummy(TileInfo *ti)
|
||||
{
|
||||
DrawGroundSpriteAt(SPR_SHADOW_CELL, ti->x, ti->y, ti->z);
|
||||
DrawGroundSpriteAt(0x3EC, ti->x, ti->y, ti->z);
|
||||
}
|
||||
|
||||
|
||||
static uint GetSlopeZ_Dummy(const TileInfo* ti)
|
||||
{
|
||||
return 0;
|
||||
static uint GetSlopeZ_Dummy(TileInfo *ti) {
|
||||
return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
|
||||
}
|
||||
|
||||
static uint GetSlopeTileh_Dummy(const TileInfo* ti)
|
||||
{
|
||||
return 0;
|
||||
static uint GetSlopeTileh_Dummy(TileInfo *ti) {
|
||||
return ti->tileh;
|
||||
}
|
||||
|
||||
static int32 ClearTile_Dummy(TileIndex tile, byte flags)
|
||||
{
|
||||
static int32 ClearTile_Dummy(uint tile, byte flags) {
|
||||
return_cmd_error(STR_0001_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
|
||||
static void GetAcceptedCargo_Dummy(TileIndex tile, AcceptedCargo ac)
|
||||
static void GetAcceptedCargo_Dummy(uint tile, AcceptedCargo ac)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
static void GetTileDesc_Dummy(TileIndex tile, TileDesc *td)
|
||||
static void GetTileDesc_Dummy(uint tile, TileDesc *td)
|
||||
{
|
||||
td->str = STR_EMPTY;
|
||||
td->owner = OWNER_NONE;
|
||||
}
|
||||
|
||||
static void AnimateTile_Dummy(TileIndex tile)
|
||||
static void AnimateTile_Dummy(uint tile)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
static void TileLoop_Dummy(TileIndex tile)
|
||||
static void TileLoop_Dummy(uint tile)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
static void ClickTile_Dummy(TileIndex tile)
|
||||
static void ClickTile_Dummy(uint tile)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
static void ChangeTileOwner_Dummy(TileIndex tile, PlayerID old_player, PlayerID new_player)
|
||||
static void ChangeTileOwner_Dummy(uint tile, byte old_player, byte new_player)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode)
|
||||
static uint32 GetTileTrackStatus_Dummy(uint tile, TransportType mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -82,3 +75,4 @@ const TileTypeProcs _tile_type_dummy_procs = {
|
||||
NULL, /* vehicle_leave_tile_proc */
|
||||
GetSlopeTileh_Dummy, /* get_slope_tileh_proc */
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef ECONOMY_H
|
||||
#define ECONOMY_H
|
||||
|
||||
void ResetPriceBaseMultipliers(void);
|
||||
void SetPriceBaseMultiplier(uint price, byte factor);
|
||||
|
||||
typedef struct {
|
||||
// Maximum possible loan
|
||||
int32 max_loan;
|
||||
@@ -23,8 +18,8 @@ VARDEF Economy _economy;
|
||||
typedef struct Subsidy {
|
||||
byte cargo_type;
|
||||
byte age;
|
||||
uint16 from;
|
||||
uint16 to;
|
||||
byte from;
|
||||
byte to;
|
||||
} Subsidy;
|
||||
|
||||
|
||||
@@ -52,19 +47,32 @@ typedef struct ScoreInfo {
|
||||
int score; // How much score it will give
|
||||
} ScoreInfo;
|
||||
|
||||
extern const ScoreInfo _score_info[];
|
||||
extern int _score_part[MAX_PLAYERS][NUM_SCORE];
|
||||
static const ScoreInfo score_info[] = {
|
||||
{SCORE_VEHICLES, 120, 100},
|
||||
{SCORE_STATIONS, 80, 100},
|
||||
{SCORE_MIN_PROFIT, 10000, 100},
|
||||
{SCORE_MIN_INCOME, 50000, 50},
|
||||
{SCORE_MAX_INCOME, 100000, 100},
|
||||
{SCORE_DELIVERED, 40000, 400},
|
||||
{SCORE_CARGO, 8, 50},
|
||||
{SCORE_MONEY, 10000000, 50},
|
||||
{SCORE_LOAN, 250000, 50},
|
||||
{SCORE_TOTAL, 0, 0}
|
||||
};
|
||||
|
||||
int _score_part[MAX_PLAYERS][NUM_SCORE];
|
||||
|
||||
int UpdateCompanyRatingAndValue(Player *p, bool update);
|
||||
void UpdatePlayerHouse(Player *p, uint score);
|
||||
|
||||
|
||||
VARDEF Subsidy _subsidies[MAX_PLAYERS];
|
||||
Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode);
|
||||
void DeleteSubsidyWithIndustry(uint16 index);
|
||||
void DeleteSubsidyWithStation(uint16 index);
|
||||
Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode);
|
||||
void DeleteSubsidyWithIndustry(byte index);
|
||||
void DeleteSubsidyWithStation(byte index);
|
||||
void RemoteSubsidyAdd(Subsidy *s_new);
|
||||
|
||||
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type);
|
||||
uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount);
|
||||
uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount);
|
||||
|
||||
#endif /* ECONOMY_H */
|
||||
|
||||
+9
-39
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN
|
||||
@@ -10,43 +8,15 @@
|
||||
// that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes
|
||||
// care of the real writing to the file.
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
unsigned char EndianTest[2] = { 1, 0 };
|
||||
int force_BE = 0, force_LE = 0, force_PREPROCESSOR = 0;
|
||||
int main () {
|
||||
unsigned char EndianTest[2] = { 1, 0 };
|
||||
printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n");
|
||||
if( *(short *) EndianTest == 1 )
|
||||
printf("#define TTD_LITTLE_ENDIAN\n");
|
||||
else
|
||||
printf("#define TTD_BIG_ENDIAN\n");
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "BE") == 0)
|
||||
force_BE = 1;
|
||||
if (argc > 1 && strcmp(argv[1], "LE") == 0)
|
||||
force_LE = 1;
|
||||
if (argc > 1 && strcmp(argv[1], "PREPROCESSOR") == 0)
|
||||
force_PREPROCESSOR = 1;
|
||||
printf("#endif\n");
|
||||
|
||||
printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n");
|
||||
|
||||
if (force_LE == 1) {
|
||||
printf("#define TTD_LITTLE_ENDIAN\n");
|
||||
} else {
|
||||
if (force_BE == 1) {
|
||||
printf("#define TTD_BIG_ENDIAN\n");
|
||||
} else {
|
||||
if (force_PREPROCESSOR == 1) {
|
||||
// adding support for universal binaries on OSX
|
||||
// Universal binaries supports both PPC and x86
|
||||
// If a compiler for OSX gets this setting, it will always pick the correct endian and no test is needed
|
||||
printf("#ifdef __BIG_ENDIAN__\n");
|
||||
printf("#define TTD_BIG_ENDIAN\n");
|
||||
printf("#else\n");
|
||||
printf("#define TTD_LITTLE_ENDIAN\n");
|
||||
printf("#endif\n");
|
||||
} else {
|
||||
if ( *(short *) EndianTest == 1 )
|
||||
printf("#define TTD_LITTLE_ENDIAN\n");
|
||||
else
|
||||
printf("#define TTD_BIG_ENDIAN\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("#endif\n");
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef ENGINE_H
|
||||
#define ENGINE_H
|
||||
|
||||
/** @file engine.h
|
||||
*/
|
||||
|
||||
#include "sprite.h"
|
||||
#include "pool.h"
|
||||
|
||||
typedef struct RailVehicleInfo {
|
||||
byte image_index;
|
||||
@@ -15,20 +9,11 @@ typedef struct RailVehicleInfo {
|
||||
byte base_cost;
|
||||
uint16 max_speed;
|
||||
uint16 power;
|
||||
uint16 weight;
|
||||
byte weight;
|
||||
byte running_cost_base;
|
||||
byte running_cost_class;
|
||||
byte engclass; // 0: steam, 1: diesel, 2: electric
|
||||
byte capacity;
|
||||
byte cargo_type;
|
||||
byte callbackmask; // see CallbackMask enum
|
||||
uint16 pow_wag_power;
|
||||
byte pow_wag_weight;
|
||||
byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value
|
||||
// for when the 'powered wagon' callback fails. But it should really also determine what
|
||||
// kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
|
||||
// Same goes for the callback result, which atm is only used to check if a wagon is powered.
|
||||
byte shorten_factor; // length on main map for this type is 8 - shorten_factor
|
||||
} RailVehicleInfo;
|
||||
|
||||
typedef struct ShipVehicleInfo {
|
||||
@@ -51,7 +36,7 @@ typedef struct AircraftVehicleInfo {
|
||||
byte acceleration;
|
||||
byte max_speed;
|
||||
byte mail_capacity;
|
||||
uint16 passenger_capacity;
|
||||
uint16 passanger_capacity;
|
||||
} AircraftVehicleInfo;
|
||||
|
||||
typedef struct RoadVehicleInfo {
|
||||
@@ -64,17 +49,12 @@ typedef struct RoadVehicleInfo {
|
||||
byte cargo_type;
|
||||
} RoadVehicleInfo;
|
||||
|
||||
/** Information about a vehicle
|
||||
* @see table/engines.h
|
||||
*/
|
||||
typedef struct EngineInfo {
|
||||
uint16 base_intro;
|
||||
byte unk2; ///< Carriages have the highest bit set in this one
|
||||
byte unk2;
|
||||
byte lifelength;
|
||||
byte base_life;
|
||||
byte railtype:4;
|
||||
byte climates:4;
|
||||
uint32 refit_mask;
|
||||
byte railtype_climates;
|
||||
} EngineInfo;
|
||||
|
||||
typedef struct Engine {
|
||||
@@ -90,7 +70,6 @@ typedef struct Engine {
|
||||
byte preview_wait;
|
||||
byte railtype;
|
||||
byte player_avail;
|
||||
byte type; // type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h
|
||||
} Engine;
|
||||
|
||||
|
||||
@@ -99,100 +78,30 @@ enum {
|
||||
RVI_WAGON = 2,
|
||||
};
|
||||
|
||||
|
||||
void StartupEngines();
|
||||
|
||||
|
||||
extern byte _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO];
|
||||
enum {
|
||||
NUM_VEHICLE_TYPES = 6
|
||||
CID_DEFAULT = 29,
|
||||
CID_PURCHASE = 30,
|
||||
NUM_CID = 31,
|
||||
};
|
||||
extern byte _local_cargo_id_ctype[NUM_CID];
|
||||
extern byte _local_cargo_id_landscape[NUM_CID];
|
||||
|
||||
enum {
|
||||
INVALID_ENGINE = 0xFFFF,
|
||||
};
|
||||
extern uint32 _engine_refit_masks[256];
|
||||
|
||||
void AddTypeToEngines(void);
|
||||
void StartupEngines(void);
|
||||
|
||||
enum GlobalCargo {
|
||||
GC_PASSENGERS = 0,
|
||||
GC_COAL = 1,
|
||||
GC_MAIL = 2,
|
||||
GC_OIL = 3,
|
||||
GC_LIVESTOCK = 4,
|
||||
GC_GOODS = 5,
|
||||
GC_GRAIN = 6, // GC_WHEAT / GC_MAIZE
|
||||
GC_WOOD = 7,
|
||||
GC_IRON_ORE = 8,
|
||||
GC_STEEL = 9,
|
||||
GC_VALUABLES = 10, // GC_GOLD / GC_DIAMONDS
|
||||
GC_PAPER = 11,
|
||||
GC_FOOD = 12,
|
||||
GC_FRUIT = 13,
|
||||
GC_COPPER_ORE = 14,
|
||||
GC_WATER = 15,
|
||||
GC_RUBBER = 16,
|
||||
GC_SUGAR = 17,
|
||||
GC_TOYS = 18,
|
||||
GC_BATTERIES = 19,
|
||||
GC_CANDY = 20,
|
||||
GC_TOFFEE = 21,
|
||||
GC_COLA = 22,
|
||||
GC_COTTON_CANDY = 23,
|
||||
GC_BUBBLES = 24,
|
||||
GC_PLASTIC = 25,
|
||||
GC_FIZZY_DRINKS = 26,
|
||||
GC_PAPER_TEMP = 27,
|
||||
GC_UNDEFINED = 28, // undefined; unused slot in arctic climate
|
||||
GC_DEFAULT = 29,
|
||||
GC_PURCHASE = 30,
|
||||
GC_INVALID = 255,
|
||||
NUM_GLOBAL_CID = 31
|
||||
};
|
||||
|
||||
// This enum lists the implemented callbacks
|
||||
// Use as argument for the GetCallBackResult function (see comments there)
|
||||
enum CallbackID {
|
||||
// Powered wagons, if the result is lower as 0x40 then the wagon is powered
|
||||
// TODO: interpret the rest of the result, aka "visual effects"
|
||||
CBID_WAGON_POWER = 0x10,
|
||||
|
||||
// Vehicle length, returns the amount of 1/8's the vehicle is shorter
|
||||
// only for train vehicles
|
||||
CBID_VEH_LENGTH = 0x11,
|
||||
|
||||
// Refit capacity, the passed vehicle needs to have its ->cargo_type set to
|
||||
// the cargo we are refitting to, returns the new cargo capacity
|
||||
CBID_REFIT_CAP = 0x15,
|
||||
|
||||
CBID_ARTIC_ENGINE = 0x16,
|
||||
};
|
||||
|
||||
// bit positions for rvi->callbackmask, indicates which callbacks are used by an engine
|
||||
// (some callbacks are always used, and dont appear here)
|
||||
enum CallbackMask {
|
||||
CBM_WAGON_POWER = 0,
|
||||
CBM_VEH_LENGTH = 1,
|
||||
CBM_REFIT_CAP = 3,
|
||||
CBM_ARTIC_ENGINE = 4,
|
||||
};
|
||||
|
||||
enum {
|
||||
CALLBACK_FAILED = 0xFFFF
|
||||
};
|
||||
|
||||
VARDEF const uint32 _default_refitmasks[NUM_VEHICLE_TYPES];
|
||||
VARDEF const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO];
|
||||
VARDEF const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE];
|
||||
VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID];
|
||||
VARDEF const uint32 cargo_classes[16];
|
||||
|
||||
void SetWagonOverrideSprites(EngineID engine, struct SpriteGroup *group, byte *train_id, int trains);
|
||||
void SetCustomEngineSprites(EngineID engine, byte cargo, struct SpriteGroup *group);
|
||||
extern byte _engine_original_sprites[256];
|
||||
void SetWagonOverrideSprites(byte engine, struct SpriteGroup *group, byte *train_id, int trains);
|
||||
void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group);
|
||||
// loaded is in percents, overriding_engine 0xffff is none
|
||||
int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction);
|
||||
uint16 GetCallBackResult(uint16 callback_info, EngineID engine, const Vehicle *v);
|
||||
bool UsesWagonOverride(const Vehicle *v);
|
||||
int GetCustomEngineSprite(byte engine, Vehicle *v, byte direction);
|
||||
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
|
||||
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
|
||||
|
||||
typedef enum VehicleTrigger {
|
||||
enum VehicleTrigger {
|
||||
VEHICLE_TRIGGER_NEW_CARGO = 1,
|
||||
// Externally triggered only for the first vehicle in chain
|
||||
VEHICLE_TRIGGER_DEPOT = 2,
|
||||
@@ -200,22 +109,28 @@ typedef enum VehicleTrigger {
|
||||
VEHICLE_TRIGGER_EMPTY = 4,
|
||||
// Not triggered externally (called for the whole chain if we got NEW_CARGO)
|
||||
VEHICLE_TRIGGER_ANY_NEW_CARGO = 8,
|
||||
} VehicleTrigger;
|
||||
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
|
||||
};
|
||||
void TriggerVehicle(Vehicle *veh, enum VehicleTrigger trigger);
|
||||
|
||||
void SetCustomEngineName(EngineID engine, const char *name);
|
||||
StringID GetCustomEngineName(EngineID engine);
|
||||
void SetCustomEngineName(int engine, char *name);
|
||||
StringID GetCustomEngineName(int engine);
|
||||
|
||||
|
||||
void DrawTrainEngine(int x, int y, EngineID engine, uint32 image_ormod);
|
||||
void DrawRoadVehEngine(int x, int y, EngineID engine, uint32 image_ormod);
|
||||
void DrawShipEngine(int x, int y, EngineID engine, uint32 image_ormod);
|
||||
void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod);
|
||||
void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod);
|
||||
void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod);
|
||||
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod);
|
||||
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod);
|
||||
|
||||
void LoadCustomEngineNames(void);
|
||||
void DeleteCustomEngineNames(void);
|
||||
void DrawTrainEngineInfo(int engine, int x, int y, int maxw);
|
||||
void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw);
|
||||
void DrawShipEngineInfo(int engine, int x, int y, int maxw);
|
||||
void DrawAircraftEngineInfo(int engine, int x, int y, int maxw);
|
||||
|
||||
void AcceptEnginePreview(Engine *e, int player);
|
||||
|
||||
void LoadCustomEngineNames();
|
||||
void DeleteCustomEngineNames();
|
||||
|
||||
bool IsEngineBuildable(uint engine, byte type);
|
||||
|
||||
enum {
|
||||
NUM_NORMAL_RAIL_ENGINES = 54,
|
||||
@@ -231,137 +146,39 @@ enum {
|
||||
ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES,
|
||||
};
|
||||
VARDEF Engine _engines[TOTAL_NUM_ENGINES];
|
||||
#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++)
|
||||
|
||||
static inline Engine* GetEngine(EngineID i)
|
||||
{
|
||||
assert(i < lengthof(_engines));
|
||||
return &_engines[i];
|
||||
}
|
||||
|
||||
#define DEREF_ENGINE(i) (&_engines[i])
|
||||
VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES];
|
||||
|
||||
static inline bool IsEngineIndex(uint index)
|
||||
{
|
||||
return index < TOTAL_NUM_ENGINES;
|
||||
}
|
||||
|
||||
/* Access Vehicle Data */
|
||||
//#include "table/engines.h"
|
||||
extern const EngineInfo orig_engine_info[TOTAL_NUM_ENGINES];
|
||||
extern const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES];
|
||||
extern const ShipVehicleInfo orig_ship_vehicle_info[NUM_SHIP_ENGINES];
|
||||
extern const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
|
||||
extern const RoadVehicleInfo orig_road_vehicle_info[NUM_ROAD_ENGINES];
|
||||
|
||||
extern EngineInfo _engine_info[TOTAL_NUM_ENGINES];
|
||||
extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
|
||||
extern ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
|
||||
extern AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
|
||||
extern RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES];
|
||||
|
||||
static inline const RailVehicleInfo* RailVehInfo(EngineID e)
|
||||
static inline RailVehicleInfo *RailVehInfo(uint e)
|
||||
{
|
||||
assert(e < lengthof(_rail_vehicle_info));
|
||||
return &_rail_vehicle_info[e];
|
||||
}
|
||||
|
||||
static inline const ShipVehicleInfo* ShipVehInfo(EngineID e)
|
||||
static inline ShipVehicleInfo *ShipVehInfo(uint e)
|
||||
{
|
||||
assert(e >= SHIP_ENGINES_INDEX && e < SHIP_ENGINES_INDEX + lengthof(_ship_vehicle_info));
|
||||
assert(e - SHIP_ENGINES_INDEX < lengthof(_ship_vehicle_info));
|
||||
return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX];
|
||||
}
|
||||
|
||||
static inline const AircraftVehicleInfo* AircraftVehInfo(EngineID e)
|
||||
static inline AircraftVehicleInfo *AircraftVehInfo(uint e)
|
||||
{
|
||||
assert(e >= AIRCRAFT_ENGINES_INDEX && e < AIRCRAFT_ENGINES_INDEX + lengthof(_aircraft_vehicle_info));
|
||||
assert(e - AIRCRAFT_ENGINES_INDEX < lengthof(_aircraft_vehicle_info));
|
||||
return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX];
|
||||
}
|
||||
|
||||
static inline const RoadVehicleInfo* RoadVehInfo(EngineID e)
|
||||
static inline RoadVehicleInfo *RoadVehInfo(uint e)
|
||||
{
|
||||
assert(e >= ROAD_ENGINES_INDEX && e < ROAD_ENGINES_INDEX + lengthof(_road_vehicle_info));
|
||||
assert(e - ROAD_ENGINES_INDEX < lengthof(_road_vehicle_info));
|
||||
return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
|
||||
}
|
||||
|
||||
void UnloadWagonOverrides(void);
|
||||
void UnloadCustomEngineSprites(void);
|
||||
void UnloadCustomEngineNames(void);
|
||||
|
||||
/************************************************************************
|
||||
* Engine Replacement stuff
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* Struct to store engine replacements. DO NOT USE outside of engine.c. Is
|
||||
* placed here so the only exception to this rule, the saveload code, can use
|
||||
* it.
|
||||
*/
|
||||
struct EngineRenew {
|
||||
uint16 index;
|
||||
EngineID from;
|
||||
EngineID to;
|
||||
struct EngineRenew *next;
|
||||
};
|
||||
|
||||
typedef struct EngineRenew EngineRenew;
|
||||
|
||||
/**
|
||||
* Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
|
||||
* placed here so the only exception to this rule, the saveload code, can use
|
||||
* it.
|
||||
*/
|
||||
extern MemoryPool _engine_renew_pool;
|
||||
|
||||
/**
|
||||
* DO NOT USE outside of engine.c. Is
|
||||
* placed here so the only exception to this rule, the saveload code, can use
|
||||
* it.
|
||||
*/
|
||||
static inline EngineRenew *GetEngineRenew(uint16 index)
|
||||
{
|
||||
return (EngineRenew*)GetItemFromPool(&_engine_renew_pool, index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A list to group EngineRenew directives together (such as per-player).
|
||||
*/
|
||||
typedef EngineRenew* EngineRenewList;
|
||||
|
||||
/**
|
||||
* Remove all engine replacement settings for the player.
|
||||
* @param er The renewlist for a given player.
|
||||
* @return The new renewlist for the player.
|
||||
*/
|
||||
void RemoveAllEngineReplacement(EngineRenewList* erl);
|
||||
|
||||
/**
|
||||
* Retrieve the engine replacement in a given renewlist for an original engine type.
|
||||
* @param erl The renewlist to search in.
|
||||
* @param engine Engine type to be replaced.
|
||||
* @return The engine type to replace with, or INVALID_ENGINE if no
|
||||
* replacement is in the list.
|
||||
*/
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine);
|
||||
|
||||
/**
|
||||
* Add an engine replacement to the given renewlist.
|
||||
* @param erl The renewlist to add to.
|
||||
* @param old_engine The original engine type.
|
||||
* @param new_engine The replacement engine type.
|
||||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
int32 AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, uint32 flags);
|
||||
|
||||
/**
|
||||
* Remove an engine replacement from a given renewlist.
|
||||
* @param erl The renewlist from which to remove the replacement
|
||||
* @param engine The original engine type.
|
||||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
int32 RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, uint32 flags);
|
||||
|
||||
#endif /* ENGINE_H */
|
||||
#endif
|
||||
|
||||
+53
-116
@@ -1,10 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "table/sprites.h"
|
||||
#include "functions.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
#include "viewport.h"
|
||||
@@ -12,16 +8,21 @@
|
||||
#include "engine.h"
|
||||
#include "command.h"
|
||||
#include "news.h"
|
||||
#include "variables.h"
|
||||
|
||||
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod);
|
||||
void DrawShipEngineInfo(int engine, int x, int y, int maxw);
|
||||
|
||||
|
||||
static StringID GetEngineCategoryName(EngineID engine)
|
||||
StringID GetEngineCategoryName(byte engine)
|
||||
{
|
||||
if (engine < NUM_TRAIN_ENGINES) {
|
||||
switch (GetEngine(engine)->railtype) {
|
||||
case RAILTYPE_RAIL: return STR_8102_RAILROAD_LOCOMOTIVE;
|
||||
case RAILTYPE_MONO: return STR_8106_MONORAIL_LOCOMOTIVE;
|
||||
case RAILTYPE_MAGLEV: return STR_8107_MAGLEV_LOCOMOTIVE;
|
||||
switch (_engines[engine].railtype) {
|
||||
case 0:
|
||||
return STR_8102_RAILROAD_LOCOMOTIVE;
|
||||
case 1:
|
||||
return STR_8106_MONORAIL_LOCOMOTIVE;
|
||||
case 2:
|
||||
return STR_8107_MAGLEV_LOCOMOTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,27 +36,22 @@ static StringID GetEngineCategoryName(EngineID engine)
|
||||
}
|
||||
|
||||
static const Widget _engine_preview_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_IMGBTN, RESIZE_NONE, 5, 0, 299, 14, 191, 0x0, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 5, 155, 214, 172, 183, STR_00C8_YES, STR_NULL},
|
||||
{ WWT_TEXTBTN, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 5, 11, 299, 0, 13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_IMGBTN, 5, 0, 299, 14, 191, 0x0, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, 5, 85, 144, 172, 183, STR_00C9_NO, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, 5, 155, 214, 172, 183, STR_00C8_YES, STR_NULL},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
typedef void DrawEngineProc(int x, int y, EngineID engine, uint32 image_ormod);
|
||||
typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw);
|
||||
typedef void DrawEngineProc(int x, int y, int engine, uint32 image_ormod);
|
||||
typedef void DrawEngineInfoProc(int x, int y, int engine, int maxw);
|
||||
|
||||
typedef struct DrawEngineInfo {
|
||||
DrawEngineProc *engine_proc;
|
||||
DrawEngineInfoProc *info_proc;
|
||||
} DrawEngineInfo;
|
||||
|
||||
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw);
|
||||
static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw);
|
||||
static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw);
|
||||
static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw);
|
||||
|
||||
static const DrawEngineInfo _draw_engine_list[4] = {
|
||||
{DrawTrainEngine,DrawTrainEngineInfo},
|
||||
{DrawRoadVehEngine,DrawRoadVehEngineInfo},
|
||||
@@ -65,40 +61,39 @@ static const DrawEngineInfo _draw_engine_list[4] = {
|
||||
|
||||
static void EnginePreviewWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
EngineID engine = w->window_number;
|
||||
const DrawEngineInfo* dei;
|
||||
int width;
|
||||
byte eng;
|
||||
int engine;
|
||||
const DrawEngineInfo *dei;
|
||||
int width;
|
||||
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
DrawWindowWidgets(w);
|
||||
engine = w->window_number;
|
||||
|
||||
SetDParam(0, GetEngineCategoryName(engine));
|
||||
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
|
||||
|
||||
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10);
|
||||
|
||||
(dei = _draw_engine_list,engine < NUM_TRAIN_ENGINES) ||
|
||||
(dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) ||
|
||||
(dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) ||
|
||||
eng = (byte)engine;
|
||||
(dei = _draw_engine_list,eng < NUM_TRAIN_ENGINES) ||
|
||||
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) ||
|
||||
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) ||
|
||||
(dei++, true);
|
||||
|
||||
width = w->width;
|
||||
dei->engine_proc(width >> 1, 100, engine, 0);
|
||||
dei->info_proc(engine, width >> 1, 130, width - 52);
|
||||
break;
|
||||
}
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->click.widget) {
|
||||
case 3:
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
switch(e->click.widget) {
|
||||
case 3: DeleteWindow(w); break;
|
||||
case 4:
|
||||
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -113,7 +108,7 @@ static const WindowDesc _engine_preview_desc = {
|
||||
};
|
||||
|
||||
|
||||
void ShowEnginePreviewWindow(EngineID engine)
|
||||
void ShowEnginePreviewWindow(int engine)
|
||||
{
|
||||
Window *w;
|
||||
|
||||
@@ -121,30 +116,9 @@ void ShowEnginePreviewWindow(EngineID engine)
|
||||
w->window_number = engine;
|
||||
}
|
||||
|
||||
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
|
||||
{
|
||||
const RailVehicleInfo *rvi = RailVehInfo(engine);
|
||||
uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0;
|
||||
|
||||
SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5);
|
||||
SetDParam(2, rvi->max_speed * 10 >> 4);
|
||||
SetDParam(3, rvi->power << multihead);
|
||||
SetDParam(1, rvi->weight << multihead);
|
||||
|
||||
SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8 << multihead);
|
||||
|
||||
if (rvi->capacity != 0) {
|
||||
SetDParam(5, _cargoc.names_long[rvi->cargo_type]);
|
||||
SetDParam(6, rvi->capacity << multihead);
|
||||
} else {
|
||||
SetDParam(5, STR_8838_N_A);
|
||||
}
|
||||
DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw);
|
||||
}
|
||||
|
||||
void DrawNewsNewTrainAvail(Window *w)
|
||||
{
|
||||
EngineID engine;
|
||||
int engine;
|
||||
|
||||
DrawNewsBorder(w);
|
||||
|
||||
@@ -158,34 +132,22 @@ void DrawNewsNewTrainAvail(Window *w)
|
||||
DrawStringMultiCenter(w->width >> 1, 57, STR_885A, w->width - 2);
|
||||
|
||||
DrawTrainEngine(w->width >> 1, 88, engine, 0);
|
||||
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE);
|
||||
GfxFillRect(25, 56, w->width - 56, 112, 0x4323);
|
||||
DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52);
|
||||
}
|
||||
|
||||
StringID GetNewsStringNewTrainAvail(const NewsItem *ni)
|
||||
StringID GetNewsStringNewTrainAvail(NewsItem *ni)
|
||||
{
|
||||
EngineID engine = ni->string_id;
|
||||
int engine = ni->string_id;
|
||||
SetDParam(0, STR_8859_NEW_NOW_AVAILABLE);
|
||||
SetDParam(1, GetEngineCategoryName(engine));
|
||||
SetDParam(2, GetCustomEngineName(engine));
|
||||
return STR_02B6;
|
||||
}
|
||||
|
||||
static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
|
||||
{
|
||||
const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
|
||||
SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5);
|
||||
SetDParam(1, avi->max_speed << 3);
|
||||
SetDParam(2, avi->passenger_capacity);
|
||||
SetDParam(3, avi->mail_capacity);
|
||||
SetDParam(4, avi->running_cost * _price.aircraft_running >> 8);
|
||||
|
||||
DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
|
||||
}
|
||||
|
||||
void DrawNewsNewAircraftAvail(Window *w)
|
||||
{
|
||||
EngineID engine;
|
||||
int engine;
|
||||
|
||||
DrawNewsBorder(w);
|
||||
|
||||
@@ -198,35 +160,21 @@ void DrawNewsNewAircraftAvail(Window *w)
|
||||
DrawStringMultiCenter(w->width >> 1, 57, STR_A02D, w->width - 2);
|
||||
|
||||
DrawAircraftEngine(w->width >> 1, 93, engine, 0);
|
||||
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE);
|
||||
GfxFillRect(25, 56, w->width - 56, 110, 0x4323);
|
||||
DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52);
|
||||
}
|
||||
|
||||
StringID GetNewsStringNewAircraftAvail(const NewsItem *ni)
|
||||
StringID GetNewsStringNewAircraftAvail(NewsItem *ni)
|
||||
{
|
||||
EngineID engine = ni->string_id;
|
||||
int engine = ni->string_id;
|
||||
SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE);
|
||||
SetDParam(1, GetCustomEngineName(engine));
|
||||
return STR_02B6;
|
||||
}
|
||||
|
||||
static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)
|
||||
{
|
||||
const RoadVehicleInfo *rvi = RoadVehInfo(engine);
|
||||
|
||||
SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5);
|
||||
SetDParam(1, rvi->max_speed * 10 >> 5);
|
||||
SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8);
|
||||
|
||||
SetDParam(4, rvi->capacity);
|
||||
SetDParam(3, _cargoc.names_long[rvi->cargo_type]);
|
||||
|
||||
DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
|
||||
}
|
||||
|
||||
void DrawNewsNewRoadVehAvail(Window *w)
|
||||
{
|
||||
EngineID engine;
|
||||
int engine;
|
||||
|
||||
DrawNewsBorder(w);
|
||||
|
||||
@@ -238,32 +186,21 @@ void DrawNewsNewRoadVehAvail(Window *w)
|
||||
DrawStringMultiCenter(w->width >> 1, 57, STR_9029, w->width - 2);
|
||||
|
||||
DrawRoadVehEngine(w->width >> 1, 88, engine, 0);
|
||||
GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE);
|
||||
GfxFillRect(25, 56, w->width - 56, 112, 0x4323);
|
||||
DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52);
|
||||
}
|
||||
|
||||
StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni)
|
||||
StringID GetNewsStringNewRoadVehAvail(NewsItem *ni)
|
||||
{
|
||||
EngineID engine = ni->string_id;
|
||||
int engine = ni->string_id;
|
||||
SetDParam(0, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE);
|
||||
SetDParam(1, GetCustomEngineName(engine));
|
||||
return STR_02B6;
|
||||
}
|
||||
|
||||
static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw)
|
||||
{
|
||||
const ShipVehicleInfo *svi = ShipVehInfo(engine);
|
||||
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5);
|
||||
SetDParam(1, svi->max_speed * 10 >> 5);
|
||||
SetDParam(2, _cargoc.names_long[svi->cargo_type]);
|
||||
SetDParam(3, svi->capacity);
|
||||
SetDParam(4, svi->running_cost * _price.ship_running >> 8);
|
||||
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
|
||||
}
|
||||
|
||||
void DrawNewsNewShipAvail(Window *w)
|
||||
{
|
||||
EngineID engine;
|
||||
int engine;
|
||||
|
||||
DrawNewsBorder(w);
|
||||
|
||||
@@ -276,13 +213,13 @@ void DrawNewsNewShipAvail(Window *w)
|
||||
DrawStringMultiCenter(w->width >> 1, 57, STR_982D, w->width - 2);
|
||||
|
||||
DrawShipEngine(w->width >> 1, 93, engine, 0);
|
||||
GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE);
|
||||
GfxFillRect(25, 56, w->width - 56, 110, 0x4323);
|
||||
DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52);
|
||||
}
|
||||
|
||||
StringID GetNewsStringNewShipAvail(const NewsItem *ni)
|
||||
StringID GetNewsStringNewShipAvail(NewsItem *ni)
|
||||
{
|
||||
EngineID engine = ni->string_id;
|
||||
int engine = ni->string_id;
|
||||
SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE);
|
||||
SetDParam(1, GetCustomEngineName(engine));
|
||||
return STR_02B6;
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
#ifndef __BEOS__
|
||||
#ifndef __MORPHOS__
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ttd.h"
|
||||
#include "hal.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef EXTERNAL_PLAYER
|
||||
#define EXTERNAL_PLAYER "timidity"
|
||||
#endif
|
||||
|
||||
static pid_t _pid;
|
||||
|
||||
static void extmidi_kill(void)
|
||||
{
|
||||
if (_pid > 0) {
|
||||
kill(_pid, SIGKILL);
|
||||
while (waitpid(_pid, NULL, WNOHANG) != _pid);
|
||||
}
|
||||
_pid = 0;
|
||||
}
|
||||
|
||||
static char *extmidi_start(char **parm)
|
||||
{
|
||||
_pid = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void extmidi_stop(void)
|
||||
{
|
||||
extmidi_kill();
|
||||
}
|
||||
|
||||
static void extmidi_play_song(const char *filename)
|
||||
{
|
||||
extmidi_kill();
|
||||
|
||||
_pid = fork();
|
||||
if (_pid < 0) {
|
||||
fprintf(stderr, "extmidi: couldn't fork: %s\n", strerror(errno));
|
||||
_pid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pid == 0) {
|
||||
#if defined(MIDI_ARG)
|
||||
execlp(EXTERNAL_PLAYER, "extmidi", MIDI_ARG, filename, NULL);
|
||||
#else
|
||||
execlp(EXTERNAL_PLAYER, "extmidi", filename, NULL);
|
||||
#endif
|
||||
fprintf(stderr, "extmidi: couldn't execl: %s\n", strerror(errno));
|
||||
exit(0);
|
||||
}
|
||||
|
||||
usleep(500);
|
||||
|
||||
if (_pid == waitpid(_pid, NULL, WNOHANG)) {
|
||||
fprintf(stderr, "extmidi: play song failed\n");
|
||||
_pid = 0;
|
||||
|
||||
usleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
static void extmidi_stop_song(void)
|
||||
{
|
||||
extmidi_kill();
|
||||
}
|
||||
|
||||
static bool extmidi_is_playing(void)
|
||||
{
|
||||
if (_pid == 0)
|
||||
return 0;
|
||||
|
||||
if (waitpid(_pid, NULL, WNOHANG) == _pid) {
|
||||
_pid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void extmidi_set_volume(byte vol)
|
||||
{
|
||||
fprintf(stderr, "extmidi: set volume not implemented\n");
|
||||
}
|
||||
|
||||
const HalMusicDriver _extmidi_music_driver = {
|
||||
extmidi_start,
|
||||
extmidi_stop,
|
||||
extmidi_play_song,
|
||||
extmidi_stop_song,
|
||||
extmidi_is_playing,
|
||||
extmidi_set_volume,
|
||||
};
|
||||
|
||||
#endif /* __MORPHOS__ */
|
||||
#endif /* __BEOS__ */
|
||||
@@ -1,12 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "fileio.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "variables.h"
|
||||
#if defined(UNIX) || defined(__OS2__)
|
||||
#include "ttd.h"
|
||||
#if defined(UNIX)
|
||||
#include <ctype.h> // required for tolower()
|
||||
#endif
|
||||
|
||||
@@ -27,7 +21,7 @@ typedef struct {
|
||||
static Fio _fio;
|
||||
|
||||
// Get current position in file
|
||||
uint32 FioGetPos(void)
|
||||
uint32 FioGetPos()
|
||||
{
|
||||
return _fio.pos + (_fio.buffer - _fio.buffer_start) - FIO_BUFFER_SIZE;
|
||||
}
|
||||
@@ -48,7 +42,7 @@ void FioSeekToFile(uint32 pos)
|
||||
FioSeekTo(pos & 0xFFFFFF, SEEK_SET);
|
||||
}
|
||||
|
||||
byte FioReadByte(void)
|
||||
byte FioReadByte()
|
||||
{
|
||||
if (_fio.buffer == _fio.buffer_end) {
|
||||
_fio.pos += FIO_BUFFER_SIZE;
|
||||
@@ -70,13 +64,13 @@ void FioSkipBytes(int n)
|
||||
}
|
||||
|
||||
|
||||
uint16 FioReadWord(void)
|
||||
uint16 FioReadWord()
|
||||
{
|
||||
byte b = FioReadByte();
|
||||
return (FioReadByte() << 8) | b;
|
||||
}
|
||||
|
||||
uint32 FioReadDword(void)
|
||||
uint32 FioReadDword()
|
||||
{
|
||||
uint b = FioReadWord();
|
||||
return (FioReadWord() << 16) | b;
|
||||
@@ -89,87 +83,16 @@ void FioReadBlock(void *ptr, uint size)
|
||||
fread(ptr, 1, size, _fio.cur_fh);
|
||||
}
|
||||
|
||||
static inline void FioCloseFile(int slot)
|
||||
{
|
||||
if (_fio.handles[slot] != NULL) {
|
||||
fclose(_fio.handles[slot]);
|
||||
_fio.handles[slot] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void FioCloseAll(void)
|
||||
void FioCloseAll()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i != lengthof(_fio.handles); i++)
|
||||
FioCloseFile(i);
|
||||
}
|
||||
|
||||
bool FiosCheckFileExists(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[MAX_PATH];
|
||||
|
||||
sprintf(buf, "%s%s", _path.data_dir, filename);
|
||||
|
||||
f = fopen(buf, "rb");
|
||||
#if !defined(WIN32)
|
||||
if (f == NULL) {
|
||||
char *s;
|
||||
// Make lower case and try again
|
||||
for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++)
|
||||
*s = tolower(*s);
|
||||
f = fopen(buf, "rb");
|
||||
|
||||
#if defined SECOND_DATA_DIR
|
||||
// tries in the 2nd data directory
|
||||
if (f == NULL) {
|
||||
sprintf(buf, "%s%s", _path.second_data_dir, filename);
|
||||
for(s=buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
|
||||
*s = tolower(*s);
|
||||
f = fopen(buf, "rb");
|
||||
for(i=0; i!=lengthof(_fio.handles); i++) {
|
||||
if (_fio.handles[i] != NULL) {
|
||||
fclose(_fio.handles[i]);
|
||||
_fio.handles[i] = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (f == NULL)
|
||||
return false;
|
||||
else {
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FILE *FioFOpenFile(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[MAX_PATH];
|
||||
|
||||
sprintf(buf, "%s%s", _path.data_dir, filename);
|
||||
|
||||
f = fopen(buf, "rb");
|
||||
#if !defined(WIN32)
|
||||
if (f == NULL) {
|
||||
char *s;
|
||||
// Make lower case and try again
|
||||
for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++)
|
||||
*s = tolower(*s);
|
||||
f = fopen(buf, "rb");
|
||||
|
||||
#if defined SECOND_DATA_DIR
|
||||
// tries in the 2nd data directory
|
||||
if (f == NULL) {
|
||||
sprintf(buf, "%s%s", _path.second_data_dir, filename);
|
||||
for(s=buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
|
||||
*s = tolower(*s);
|
||||
f = fopen(buf, "rb");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void FioOpenFile(int slot, const char *filename)
|
||||
@@ -187,7 +110,7 @@ void FioOpenFile(int slot, const char *filename)
|
||||
for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++)
|
||||
*s = tolower(*s);
|
||||
f = fopen(buf, "rb");
|
||||
|
||||
|
||||
#if defined SECOND_DATA_DIR
|
||||
// tries in the 2nd data directory
|
||||
if (f == NULL) {
|
||||
@@ -196,10 +119,6 @@ void FioOpenFile(int slot, const char *filename)
|
||||
*s = tolower(*s);
|
||||
f = fopen(buf, "rb");
|
||||
}
|
||||
|
||||
if (f == NULL)
|
||||
sprintf(buf, "%s%s", _path.data_dir, filename); //makes it print the primary datadir path instead of the secundary one
|
||||
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -207,7 +126,8 @@ void FioOpenFile(int slot, const char *filename)
|
||||
if (f == NULL)
|
||||
error("Cannot open file '%s'", buf);
|
||||
|
||||
FioCloseFile(slot); // if file was opened before, close it
|
||||
_fio.handles[slot] = f;
|
||||
FioSeekToFile(slot << 24);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef FILEIO_H
|
||||
#define FILEIO_H
|
||||
|
||||
void FioSeekTo(uint32 pos, int mode);
|
||||
void FioSeekToFile(uint32 pos);
|
||||
uint32 FioGetPos(void);
|
||||
byte FioReadByte(void);
|
||||
uint16 FioReadWord(void);
|
||||
uint32 FioReadDword(void);
|
||||
void FioCloseAll(void);
|
||||
FILE *FioFOpenFile(const char *filename);
|
||||
uint32 FioGetPos();
|
||||
byte FioReadByte();
|
||||
uint16 FioReadWord();
|
||||
uint32 FioReadDword();
|
||||
void FioCloseAll();
|
||||
void FioOpenFile(int slot, const char *filename);
|
||||
void FioReadBlock(void *ptr, uint size);
|
||||
void FioSkipBytes(int n);
|
||||
bool FiosCheckFileExists(const char *filename);
|
||||
|
||||
#endif /* FILEIO_H */
|
||||
|
||||
+132
-105
@@ -1,28 +1,39 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef FUNCTIONS_H
|
||||
#define FUNCTIONS_H
|
||||
|
||||
/* vehicle.c */
|
||||
|
||||
/* window.c */
|
||||
|
||||
|
||||
/* landscape.c */
|
||||
void FindLandscapeHeight(TileInfo *ti, uint x, uint y);
|
||||
void FindLandscapeHeightByTile(TileInfo *ti, TileIndex tile);
|
||||
void FindLandscapeHeightByTile(TileInfo *ti, uint tile);
|
||||
uint GetTileSlope(uint tile, int *h);
|
||||
int GetTileZ(uint tile);
|
||||
|
||||
void DoClearSquare(TileIndex tile);
|
||||
void CDECL ModifyTile(TileIndex tile, uint flags, ...);
|
||||
void RunTileLoop(void);
|
||||
void DoClearSquare(uint tile);
|
||||
void CDECL ModifyTile(uint tile, uint flags, ...);
|
||||
void SetMapExtraBits(uint tile, byte flags);
|
||||
uint GetMapExtraBits(uint tile);
|
||||
void RunTileLoop();
|
||||
|
||||
uint GetPartialZ(int x, int y, int corners);
|
||||
uint GetSlopeZ(int x, int y);
|
||||
uint32 GetTileTrackStatus(TileIndex tile, TransportType mode);
|
||||
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
|
||||
void ChangeTileOwner(TileIndex tile, byte old_player, byte new_player);
|
||||
void AnimateTile(TileIndex tile);
|
||||
void ClickTile(TileIndex tile);
|
||||
void GetTileDesc(TileIndex tile, TileDesc *td);
|
||||
uint32 GetTileTrackStatus(uint tile, TransportType mode);
|
||||
void GetAcceptedCargo(uint tile, AcceptedCargo ac);
|
||||
void ChangeTileOwner(uint tile, byte old_player, byte new_player);
|
||||
void AnimateTile(uint tile);
|
||||
void ClickTile(uint tile);
|
||||
void GetTileDesc(uint tile, TileDesc *td);
|
||||
void DrawTile(TileInfo *ti);
|
||||
void UpdateTownMaxPass(Town *t);
|
||||
|
||||
bool IsValidTile(TileIndex tile);
|
||||
uint TileAddWrap(TileIndex tile, int addx, int addy);
|
||||
enum {
|
||||
TILE_WRAPPED = (uint)-1
|
||||
};
|
||||
|
||||
bool IsValidTile(uint tile);
|
||||
|
||||
static inline Point RemapCoords(int x, int y, int z)
|
||||
{
|
||||
@@ -43,34 +54,50 @@ static inline Point RemapCoords2(int x, int y)
|
||||
return RemapCoords(x, y, GetSlopeZ(x, y));
|
||||
}
|
||||
|
||||
/* game.c */
|
||||
byte *GetString(byte *buffr, uint16 string);
|
||||
void InjectDparam(int amount);
|
||||
|
||||
int32 GetParamInt32();
|
||||
int GetParamInt16();
|
||||
int GetParamInt8();
|
||||
int GetParamUint16();
|
||||
|
||||
|
||||
/* clear_land.c */
|
||||
void DrawHillyLandTile(const TileInfo *ti);
|
||||
void DrawClearLandTile(const TileInfo *ti, byte set);
|
||||
void DrawClearLandFence(const TileInfo *ti);
|
||||
void TileLoopClearHelper(TileIndex tile);
|
||||
void DrawHillyLandTile(TileInfo *ti);
|
||||
void DrawClearLandTile(TileInfo *ti, byte set);
|
||||
void DrawClearLandFence(TileInfo *ti, byte img);
|
||||
void TileLoopClearHelper(uint tile);
|
||||
|
||||
/* station_land.c */
|
||||
void StationPickerDrawSprite(int x, int y, int railtype, int image);
|
||||
|
||||
/* track_land.c */
|
||||
void DrawTrainDepotSprite(int x, int y, int image, int railtype);
|
||||
void DrawWaypointSprite(int x, int y, int image, int railtype);
|
||||
|
||||
/* road_land.c */
|
||||
void DrawRoadDepotSprite(int x, int y, int image);
|
||||
|
||||
/* water_land.c */
|
||||
void DrawShipDepotSprite(int x, int y, int image);
|
||||
void TileLoop_Water(TileIndex tile);
|
||||
void TileLoop_Water(uint tile);
|
||||
|
||||
/* players.c */
|
||||
bool CheckPlayerHasMoney(int32 cost);
|
||||
void SubtractMoneyFromPlayer(int32 cost);
|
||||
void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost);
|
||||
bool CheckOwnership(PlayerID owner);
|
||||
bool CheckTileOwnership(TileIndex tile);
|
||||
StringID GetPlayerNameString(PlayerID player, uint index);
|
||||
void SubtractMoneyFromPlayerFract(byte player, int32 cost);
|
||||
bool CheckOwnership(byte owner);
|
||||
bool CheckTileOwnership(uint tile);
|
||||
StringID GetPlayerNameString(byte player, byte index);
|
||||
|
||||
/* standard */
|
||||
void ShowInfo(const char *str);
|
||||
void CDECL ShowInfoF(const char *str, ...);
|
||||
void NORETURN CDECL error(const char *str, ...);
|
||||
|
||||
/* openttd.c */
|
||||
/* ttd.c */
|
||||
|
||||
// **************
|
||||
// * Warning: DO NOT enable this unless you understand what it does
|
||||
@@ -84,155 +111,152 @@ void NORETURN CDECL error(const char *str, ...);
|
||||
|
||||
//#define RANDOM_DEBUG
|
||||
|
||||
|
||||
// Enable this to produce higher quality random numbers.
|
||||
// Doesn't work with network yet.
|
||||
//#define MERSENNE_TWISTER
|
||||
|
||||
// Mersenne twister functions
|
||||
void SeedMT(uint32 seed);
|
||||
uint32 RandomMT(void);
|
||||
|
||||
|
||||
#ifdef MERSENNE_TWISTER
|
||||
static inline uint32 Random(void) { return RandomMT(); }
|
||||
uint RandomRange(uint max);
|
||||
#else
|
||||
|
||||
#ifdef RANDOM_DEBUG
|
||||
#define Random() DoRandom(__LINE__, __FILE__)
|
||||
uint32 DoRandom(int line, const char *file);
|
||||
uint32 DoRandom(uint line, char *file);
|
||||
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
|
||||
uint DoRandomRange(uint max, int line, const char *file);
|
||||
uint DoRandomRange(uint max, uint line, char *file);
|
||||
#else
|
||||
uint32 Random(void);
|
||||
uint32 Random();
|
||||
uint RandomRange(uint max);
|
||||
#endif
|
||||
#endif // MERSENNE_TWISTER
|
||||
|
||||
static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
|
||||
static inline TileIndex RandomTile(void) { return TILE_MASK(Random()); }
|
||||
void InitPlayerRandoms();
|
||||
|
||||
|
||||
uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */
|
||||
uint32 InteractiveRandom(); /* Used for random sequences that are not the same on the other end of the multiplayer link */
|
||||
uint InteractiveRandomRange(uint max);
|
||||
|
||||
|
||||
// Used for profiling
|
||||
#define TIC() { extern uint32 _rdtsc(void); uint32 _xxx_ = _rdtsc(); static float __avg__;
|
||||
#define TOC(s) _xxx_ = _rdtsc() - _xxx_; __avg__=__avg__*0.99+_xxx_*0.01; printf("%s: %8d %f\n", s, _xxx_,__avg__); }
|
||||
|
||||
|
||||
void SetDate(uint date);
|
||||
/* facedraw.c */
|
||||
void DrawPlayerFace(uint32 face, int color, int x, int y);
|
||||
|
||||
/* texteff.c */
|
||||
void MoveAllTextEffects(void);
|
||||
void MoveAllTextEffects();
|
||||
void AddTextEffect(StringID msg, int x, int y, uint16 duration);
|
||||
void InitTextEffects(void);
|
||||
void InitTextEffects();
|
||||
void DrawTextEffects(DrawPixelInfo *dpi);
|
||||
|
||||
void InitTextMessage(void);
|
||||
void DrawTextMessage(void);
|
||||
void InitTextMessage();
|
||||
void DrawTextMessage();
|
||||
void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...);
|
||||
void UndrawTextMessage(void);
|
||||
void TextMessageDailyLoop(void);
|
||||
void UndrawTextMessage();
|
||||
void TextMessageDailyLoop();
|
||||
|
||||
bool AddAnimatedTile(TileIndex tile);
|
||||
void DeleteAnimatedTile(TileIndex tile);
|
||||
void AnimateAnimatedTiles(void);
|
||||
void InitializeAnimatedTiles(void);
|
||||
bool AddAnimatedTile(uint tile);
|
||||
void DeleteAnimatedTile(uint tile);
|
||||
void AnimateAnimatedTiles();
|
||||
void InitializeAnimatedTiles();
|
||||
|
||||
/* tunnelbridge_cmd.c */
|
||||
bool CheckTunnelInWay(TileIndex tile, int z);
|
||||
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
|
||||
bool CheckTunnelInWay(uint tile, int z);
|
||||
bool CheckBridge_Stuff(byte bridge_type, int bridge_len);
|
||||
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
|
||||
int CalcBridgeLenCostFactor(int x);
|
||||
|
||||
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||
typedef void CommandCallback(bool success, uint tile, uint32 p1, uint32 p2);
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
|
||||
|
||||
/* network.c */
|
||||
void NetworkUDPClose(void);
|
||||
void NetworkStartUp(void);
|
||||
void NetworkStartUp();
|
||||
void NetworkShutDown(void);
|
||||
void NetworkGameLoop(void);
|
||||
void NetworkUDPGameLoop(void);
|
||||
bool NetworkServerStart(void);
|
||||
bool NetworkClientConnectGame(const char* host, unsigned short port);
|
||||
void NetworkReboot(void);
|
||||
void NetworkDisconnect(void);
|
||||
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
||||
bool NetworkClientConnectGame(const byte* host, unsigned short port);
|
||||
void NetworkReboot();
|
||||
void NetworkDisconnect();
|
||||
void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
||||
|
||||
/* misc_cmd.c */
|
||||
void PlaceTreesRandomly(void);
|
||||
void PlaceTreesRandomly();
|
||||
|
||||
uint GetTileDist(TileIndex xy1, TileIndex xy2);
|
||||
uint GetTileDist1D(TileIndex xy1, TileIndex xy2);
|
||||
uint GetTileDist1Db(TileIndex xy1, TileIndex xy2);
|
||||
uint GetTileDistAdv(TileIndex xy1, TileIndex xy2);
|
||||
bool CheckDistanceFromEdge(TileIndex tile, uint distance);
|
||||
|
||||
void InitializeLandscapeVariables(bool only_constants);
|
||||
|
||||
/* misc.c */
|
||||
void DeleteName(StringID id);
|
||||
char *GetName(int id, char *buff);
|
||||
byte *GetName(int id, byte *buff);
|
||||
|
||||
// AllocateNameUnique also tests if the name used is not used anywere else
|
||||
// and if it is used, it returns an error.
|
||||
#define AllocateNameUnique(name, skip) RealAllocateName(name, skip, true)
|
||||
#define AllocateName(name, skip) RealAllocateName(name, skip, false)
|
||||
StringID RealAllocateName(const char *name, byte skip, bool check_double);
|
||||
StringID RealAllocateName(const byte *name, byte skip, bool check_double);
|
||||
void ConvertDayToYMD(YearMonthDay *ymd, uint16 date);
|
||||
uint ConvertYMDToDay(uint year, uint month, uint day);
|
||||
uint ConvertIntDate(uint date);
|
||||
void CSleep(int milliseconds);
|
||||
|
||||
|
||||
/* misc functions */
|
||||
void MarkTileDirty(int x, int y);
|
||||
void MarkTileDirtyByTile(TileIndex tile);
|
||||
void InvalidateWindow(WindowClass cls, WindowNumber number);
|
||||
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
|
||||
void InvalidateWindowClasses(WindowClass cls);
|
||||
void InvalidateWindow(byte cls, WindowNumber number);
|
||||
void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index);
|
||||
void InvalidateWindowClasses(byte cls);
|
||||
void DeleteWindowById(WindowClass cls, WindowNumber number);
|
||||
void DeleteWindowByClass(WindowClass cls);
|
||||
|
||||
void SetObjectToPlaceWnd(CursorID icon, byte mode, Window *w);
|
||||
void SetObjectToPlace(CursorID icon, byte mode, WindowClass window_class, WindowNumber window_num);
|
||||
void SetObjectToPlaceWnd(int icon, byte mode, Window *w);
|
||||
void SetObjectToPlace(int icon, byte mode, byte window_class, uint16 window_num);
|
||||
|
||||
void ResetObjectToPlace(void);
|
||||
void ResetObjectToPlace();
|
||||
|
||||
bool ScrollWindowToTile(TileIndex tile, Window * w);
|
||||
bool ScrollWindowTo(int x, int y, Window * w);
|
||||
|
||||
bool ScrollMainWindowToTile(TileIndex tile);
|
||||
bool ScrollMainWindowTo(int x, int y);
|
||||
void DrawSprite(uint32 img, int x, int y);
|
||||
uint GetCorrectTileHeight(TileIndex tile);
|
||||
bool EnsureNoVehicle(TileIndex tile);
|
||||
bool EnsureNoVehicleZ(TileIndex tile, byte z);
|
||||
void MarkAllViewportsDirty(int left, int top, int right, int bottom);
|
||||
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost);
|
||||
void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost);
|
||||
void MarkWholeScreenDirty();
|
||||
|
||||
void DrawFoundation(TileInfo *ti, uint f);
|
||||
|
||||
bool CheckIfAuthorityAllows(TileIndex tile);
|
||||
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
|
||||
bool CheckIfAuthorityAllows(uint tile);
|
||||
Town *ClosestTownFromTile(uint tile, uint threshold);
|
||||
void ChangeTownRating(Town *t, int add, int max);
|
||||
|
||||
uint GetRoadBitsByTile(TileIndex tile);
|
||||
int GetTownRadiusGroup(const Town *t, TileIndex tile);
|
||||
int GetTownRadiusGroup(Town *t, uint tile);
|
||||
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type);
|
||||
void ShowNetworkChatQueryWindow(byte desttype, byte dest);
|
||||
void ShowNetworkGiveMoneyWindow(byte player);
|
||||
void ShowNetworkNeedGamePassword(void);
|
||||
void ShowNetworkNeedCompanyPassword(void);
|
||||
void ShowNetworkNeedGamePassword();
|
||||
void ShowNetworkNeedCompanyPassword();
|
||||
void ShowRenameSignWindow(SignStruct *ss);
|
||||
void ShowRenameWaypointWindow(Waypoint *cp);
|
||||
int FindFirstBit(uint32 x);
|
||||
void ShowHighscoreTable(int difficulty, int8 rank);
|
||||
void ShowEndGameChart(void);
|
||||
void ShowHighscoreTable(int tbl);
|
||||
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng);
|
||||
|
||||
void AfterLoadTown(void);
|
||||
void GenRandomNewGame(uint32 rnd1, uint32 rnd2);
|
||||
void StartScenarioEditor(uint32 rnd1, uint32 rnd2);
|
||||
void AskExitGame(void);
|
||||
void AskExitToGameMenu(void);
|
||||
enum SaveOrLoadResult {
|
||||
SL_OK = 0, // completed successfully
|
||||
SL_ERROR = 1, // error that was caught before internal structures were modified
|
||||
SL_REINIT = 2, // error that was caught in the middle of updating game state, need to clear it. (can only happen during load)
|
||||
};
|
||||
enum SaveOrLoadMode {
|
||||
SL_INVALID = -1,
|
||||
SL_LOAD = 0,
|
||||
SL_SAVE = 1,
|
||||
SL_OLD_LOAD = 2,
|
||||
};
|
||||
|
||||
void RedrawAutosave(void);
|
||||
int SaveOrLoad(const char *filename, int mode);
|
||||
|
||||
void AfterLoadTown();
|
||||
void AskExitGame();
|
||||
void AskExitToGameMenu();
|
||||
|
||||
void RedrawAutosave();
|
||||
|
||||
StringID RemapOldStringID(StringID s);
|
||||
|
||||
@@ -247,21 +271,24 @@ enum {
|
||||
};
|
||||
void ShowSaveLoadDialog(int mode);
|
||||
|
||||
void ttd_strlcpy(char *dst, const char *src, size_t len);
|
||||
|
||||
// callback from drivers that is called if the game size changes dynamically
|
||||
void GameSizeChanged(void);
|
||||
void GameSizeChanged();
|
||||
bool FileExists(const char *filename);
|
||||
bool ReadLanguagePack(int index);
|
||||
void InitializeLanguagePacks(void);
|
||||
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
|
||||
void InitializeLanguagePacks();
|
||||
byte *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
|
||||
int GetLanguageList(char **languages, int max);
|
||||
|
||||
void LoadFromConfig(void);
|
||||
void SaveToConfig(void);
|
||||
void CheckConfig(void);
|
||||
void CheckSwitchToEuro();
|
||||
|
||||
void LoadFromConfig();
|
||||
void SaveToConfig();
|
||||
int ttd_main(int argc, char* argv[]);
|
||||
byte GetOSVersion();
|
||||
|
||||
void DeterminePaths(void);
|
||||
void DeterminePaths();
|
||||
char * CDECL str_fmt(const char *str, ...);
|
||||
|
||||
void bubblesort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
|
||||
void CSleep(int milliseconds);
|
||||
#endif /* FUNCTIONS_H */
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef GFX_H
|
||||
#define GFX_H
|
||||
|
||||
typedef byte Pixel;
|
||||
|
||||
typedef struct ColorList {
|
||||
byte unk0, unk1, unk2;
|
||||
@@ -13,20 +10,28 @@ typedef struct ColorList {
|
||||
} ColorList;
|
||||
|
||||
struct DrawPixelInfo {
|
||||
Pixel *dst_ptr;
|
||||
byte *dst_ptr;
|
||||
int left, top, width, height;
|
||||
int pitch;
|
||||
uint16 zoom;
|
||||
};
|
||||
|
||||
|
||||
typedef struct SpriteHdr {
|
||||
byte info;
|
||||
byte height;
|
||||
uint16 width;
|
||||
int16 x_offs, y_offs;
|
||||
} SpriteHdr;
|
||||
assert_compile(sizeof(SpriteHdr) == 8);
|
||||
|
||||
typedef struct CursorVars {
|
||||
Point pos, size, offs, delta;
|
||||
Point draw_pos, draw_size;
|
||||
CursorID sprite;
|
||||
uint32 sprite;
|
||||
|
||||
int wheel; // mouse wheel movement
|
||||
const CursorID *animate_list, *animate_cur;
|
||||
const uint16 *animate_list, *animate_cur;
|
||||
uint animate_timeout;
|
||||
|
||||
bool visible;
|
||||
@@ -37,69 +42,55 @@ typedef struct CursorVars {
|
||||
|
||||
void RedrawScreenRect(int left, int top, int right, int bottom);
|
||||
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
|
||||
|
||||
|
||||
// XXX doesn't really belong here, but the only
|
||||
// consumers always use it in conjunction with DoDrawString()
|
||||
#define UPARROW "\x80"
|
||||
#define DOWNARROW "\xAA"
|
||||
|
||||
|
||||
int DrawStringCentered(int x, int y, StringID str, uint16 color);
|
||||
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
|
||||
int DoDrawStringCentered(int x, int y, const char *str, uint16 color);
|
||||
|
||||
int DrawString(int x, int y, StringID str, uint16 color);
|
||||
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw);
|
||||
|
||||
int DoDrawString(const char *string, int x, int y, uint16 color);
|
||||
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw);
|
||||
|
||||
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color);
|
||||
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color);
|
||||
|
||||
void DrawStringRightAligned(int x, int y, StringID str, uint16 color);
|
||||
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw);
|
||||
|
||||
int DrawStringCentered(int x, int y, uint16 str, uint16 color);
|
||||
int DrawString(int x, int y, uint16 str, uint16 color);
|
||||
void DrawStringCenterUnderline(int x, int y, uint16 str, uint16 color);
|
||||
int DoDrawString(const byte *string, int x, int y, uint16 color);
|
||||
void DrawStringRightAligned(int x, int y, uint16 str, uint16 color);
|
||||
void GfxFillRect(int left, int top, int right, int bottom, int color);
|
||||
void GfxDrawLine(int left, int top, int right, int bottom, int color);
|
||||
void DrawFrameRect(int left, int top, int right, int bottom, int color, int flags);
|
||||
uint16 GetDrawStringPlayerColor(PlayerID player);
|
||||
uint16 GetDrawStringPlayerColor(byte player);
|
||||
|
||||
int GetStringWidth(const char *str);
|
||||
void LoadStringWidthTable(void);
|
||||
void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
|
||||
void DrawStringMultiLine(int x, int y, StringID str, int maxw);
|
||||
void DrawDirtyBlocks(void);
|
||||
int GetStringWidth(const byte *str);
|
||||
void LoadStringWidthTable();
|
||||
void DrawStringMultiCenter(int x, int y, uint16 str, int maxw);
|
||||
void DrawStringMultiLine(int x, int y, uint16 str, int maxw);
|
||||
void DrawDirtyBlocks();
|
||||
void SetDirtyBlocks(int left, int top, int right, int bottom);
|
||||
void MarkWholeScreenDirty(void);
|
||||
void MarkWholeScreenDirty();
|
||||
|
||||
void GfxInitPalettes(void);
|
||||
void GfxInitPalettes();
|
||||
|
||||
bool FillDrawPixelInfo(DrawPixelInfo* n, const DrawPixelInfo* o, int left, int top, int width, int height);
|
||||
bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, int width, int height);
|
||||
|
||||
/* window.c */
|
||||
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
|
||||
|
||||
/* spritecache.c */
|
||||
byte *GetSpritePtr(uint sprite);
|
||||
void GfxInitSpriteMem(byte *ptr, uint32 size);
|
||||
void GfxLoadSprites();
|
||||
|
||||
void SetMouseCursor(uint cursor);
|
||||
void SetAnimatedMouseCursor(const CursorID *table);
|
||||
void CursorTick(void);
|
||||
void DrawMouseCursor(void);
|
||||
void ScreenSizeChanged(void);
|
||||
void UndrawMouseCursor(void);
|
||||
void SetAnimatedMouseCursor(const uint16 *table);
|
||||
void CursorTick();
|
||||
void DrawMouseCursor();
|
||||
void ScreenSizeChanged();
|
||||
void UndrawMouseCursor();
|
||||
bool ChangeResInGame(int w, int h);
|
||||
void SortResolutions(int count);
|
||||
void ToggleFullScreen(bool fs);
|
||||
void ToggleFullScreen(const bool full_screen);
|
||||
|
||||
typedef struct {
|
||||
int xoffs, yoffs;
|
||||
int xsize, ysize;
|
||||
} SpriteDimension;
|
||||
|
||||
const SpriteDimension *GetSpriteDimension(uint sprite);
|
||||
|
||||
/* gfx.c */
|
||||
#define ASCII_LETTERSTART 32
|
||||
VARDEF int _stringwidth_base;
|
||||
VARDEF byte _stringwidth_table[0x2A0];
|
||||
static inline byte GetCharacterWidth(uint key)
|
||||
{
|
||||
assert(key >= ASCII_LETTERSTART && key - ASCII_LETTERSTART < lengthof(_stringwidth_table));
|
||||
return _stringwidth_table[key - ASCII_LETTERSTART];
|
||||
}
|
||||
|
||||
VARDEF DrawPixelInfo _screen;
|
||||
VARDEF DrawPixelInfo *_cur_dpi;
|
||||
@@ -111,21 +102,18 @@ VARDEF int _pal_last_dirty;
|
||||
|
||||
VARDEF bool _use_dos_palette;
|
||||
|
||||
typedef struct Colour {
|
||||
byte r;
|
||||
byte g;
|
||||
byte b;
|
||||
} Colour;
|
||||
/* spritecache.c */
|
||||
//enum { NUM_SPRITES = 0x1320 };
|
||||
//enum { NUM_SPRITES = 0x1500 };
|
||||
enum { NUM_SPRITES = 0x3500 }; // 1500 + space for custom GRF sets
|
||||
|
||||
extern Colour _cur_palette[256];
|
||||
/* tables.h */
|
||||
extern byte _palettes[4][256 * 3];
|
||||
VARDEF byte _cur_palette[768];
|
||||
|
||||
|
||||
typedef enum StringColorFlags {
|
||||
IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor
|
||||
} StringColorFlags;
|
||||
|
||||
#ifdef _DEBUG
|
||||
extern bool _dbg_screen_rect;
|
||||
#endif
|
||||
|
||||
#endif /* GFX_H */
|
||||
|
||||
@@ -1,382 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "gfx.h"
|
||||
#include "gfxinit.h"
|
||||
#include "spritecache.h"
|
||||
#include "table/sprites.h"
|
||||
#include "fileio.h"
|
||||
#include "newgrf.h"
|
||||
#include "md5.h"
|
||||
#include "variables.h"
|
||||
#include <ctype.h>
|
||||
|
||||
typedef struct MD5File {
|
||||
const char * const filename; // filename
|
||||
const md5_byte_t hash[16]; // md5 sum of the file
|
||||
} MD5File;
|
||||
|
||||
typedef struct FileList {
|
||||
const MD5File basic[5]; // grf files that always have to be loaded
|
||||
const MD5File landscape[3]; // landscape specific grf files
|
||||
} FileList;
|
||||
|
||||
enum {
|
||||
SKIP = 0xFFFE,
|
||||
END = 0xFFFF
|
||||
};
|
||||
|
||||
#include "table/files.h"
|
||||
#include "table/landscape_sprite.h"
|
||||
|
||||
static const SpriteID * const _landscape_spriteindexes[] = {
|
||||
_landscape_spriteindexes_1,
|
||||
_landscape_spriteindexes_2,
|
||||
_landscape_spriteindexes_3,
|
||||
};
|
||||
|
||||
static const SpriteID * const _slopes_spriteindexes[] = {
|
||||
_slopes_spriteindexes_0,
|
||||
_slopes_spriteindexes_1,
|
||||
_slopes_spriteindexes_2,
|
||||
_slopes_spriteindexes_3,
|
||||
};
|
||||
|
||||
|
||||
static uint LoadGrfFile(const char* filename, uint load_index, int file_index)
|
||||
{
|
||||
uint load_index_org = load_index;
|
||||
|
||||
FioOpenFile(file_index, filename);
|
||||
|
||||
DEBUG(spritecache, 2) ("Reading grf-file ``%s''", filename);
|
||||
|
||||
while (LoadNextSprite(load_index, file_index)) {
|
||||
load_index++;
|
||||
if (load_index >= MAX_SPRITES) {
|
||||
error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files.");
|
||||
}
|
||||
}
|
||||
DEBUG(spritecache, 2) ("Currently %i sprites are loaded", load_index);
|
||||
|
||||
return load_index - load_index_org;
|
||||
}
|
||||
|
||||
|
||||
static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index)
|
||||
{
|
||||
uint start;
|
||||
|
||||
FioOpenFile(file_index, filename);
|
||||
|
||||
DEBUG(spritecache, 2) ("Reading indexed grf-file ``%s''", filename);
|
||||
|
||||
while ((start = *index_tbl++) != END) {
|
||||
uint end = *index_tbl++;
|
||||
|
||||
if (start == SKIP) { // skip sprites (amount in second var)
|
||||
SkipSprites(end);
|
||||
} else { // load sprites and use indexes from start to end
|
||||
do {
|
||||
#ifdef NDEBUG
|
||||
LoadNextSprite(start, file_index);
|
||||
#else
|
||||
bool b = LoadNextSprite(start, file_index);
|
||||
assert(b);
|
||||
#endif
|
||||
} while (++start <= end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check that the supplied MD5 hash matches that stored for the supplied filename */
|
||||
static bool CheckMD5Digest(const MD5File file, md5_byte_t *digest, bool warn)
|
||||
{
|
||||
uint i;
|
||||
|
||||
/* Loop through each byte of the file MD5 and the stored MD5... */
|
||||
for (i = 0; i < 16; i++) if (file.hash[i] != digest[i]) break;
|
||||
|
||||
/* If all bytes of the MD5's match (i.e. the MD5's match)... */
|
||||
if (i == 16) {
|
||||
return true;
|
||||
} else {
|
||||
if (warn) fprintf(stderr, "MD5 of %s is ****INCORRECT**** - File Corrupt.\n", file.filename);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
/* Calculate and check the MD5 hash of the supplied filename.
|
||||
* returns true if the checksum is correct */
|
||||
static bool FileMD5(const MD5File file, bool warn)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[MAX_PATH];
|
||||
|
||||
// open file
|
||||
sprintf(buf, "%s%s", _path.data_dir, file.filename);
|
||||
f = fopen(buf, "rb");
|
||||
|
||||
#if !defined(WIN32)
|
||||
if (f == NULL) {
|
||||
char *s;
|
||||
// make lower case and check again
|
||||
for (s = buf + strlen(_path.data_dir) - 1; *s != '\0'; s++)
|
||||
*s = tolower(*s);
|
||||
f = fopen(buf, "rb");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (f != NULL) {
|
||||
md5_state_t filemd5state;
|
||||
md5_byte_t buffer[1024];
|
||||
md5_byte_t digest[16];
|
||||
size_t len;
|
||||
|
||||
md5_init(&filemd5state);
|
||||
while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0)
|
||||
md5_append(&filemd5state, buffer, len);
|
||||
|
||||
if (ferror(f) && warn) fprintf(stderr, "Error Reading from %s \n", buf);
|
||||
fclose(f);
|
||||
|
||||
md5_finish(&filemd5state, digest);
|
||||
return CheckMD5Digest(file, digest, warn);
|
||||
} else { // file not found
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Checks, if either the Windows files exist (TRG1R.GRF) or the DOS files (TRG1.GRF)
|
||||
* by comparing the MD5 checksums of the files. _use_dos_palette is set accordingly.
|
||||
* If neither are found, Windows palette is assumed.
|
||||
*
|
||||
* (Note: Also checks sample.cat for corruption) */
|
||||
void CheckExternalFiles(void)
|
||||
{
|
||||
uint i;
|
||||
// count of files from this version
|
||||
uint dos = 0;
|
||||
uint win = 0;
|
||||
|
||||
for (i = 0; i < 2; i++) if (FileMD5(files_dos.basic[i], true)) dos++;
|
||||
for (i = 0; i < 3; i++) if (FileMD5(files_dos.landscape[i], true)) dos++;
|
||||
|
||||
for (i = 0; i < 2; i++) if (FileMD5(files_win.basic[i], true)) win++;
|
||||
for (i = 0; i < 3; i++) if (FileMD5(files_win.landscape[i], true)) win++;
|
||||
|
||||
if (!FileMD5(sample_cat_win, false) && !FileMD5(sample_cat_dos, false))
|
||||
fprintf(stderr, "Your sample.cat file is corrupted or missing!\n");
|
||||
|
||||
/*
|
||||
* forced DOS palette via command line -> leave it that way
|
||||
* all Windows files present -> Windows palette
|
||||
* all DOS files present -> DOS palette
|
||||
* no Windows files present and any DOS file present -> DOS palette
|
||||
* otherwise -> Windows palette
|
||||
*/
|
||||
if (_use_dos_palette) {
|
||||
return;
|
||||
} else if (win == 5) {
|
||||
_use_dos_palette = false;
|
||||
} else if (dos == 5 || (win == 0 && dos > 0)) {
|
||||
_use_dos_palette = true;
|
||||
} else {
|
||||
_use_dos_palette = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const SpriteID trg1idx[] = {
|
||||
0, 1, // Mouse cursor, ZZZ
|
||||
/* Medium font */
|
||||
2, 92, // ' ' till 'z'
|
||||
SKIP, 36,
|
||||
160, 160, // Move ¾ to the correct position
|
||||
98, 98, // Up arrow
|
||||
131, 133,
|
||||
SKIP, 1, // skip currency sign
|
||||
135, 135,
|
||||
SKIP, 1,
|
||||
137, 137,
|
||||
SKIP, 1,
|
||||
139, 139,
|
||||
140, 140, // TODO Down arrow
|
||||
141, 141,
|
||||
142, 142, // TODO Check mark
|
||||
143, 143, // TODO Cross
|
||||
144, 144,
|
||||
145, 145, // TODO Right arrow
|
||||
146, 149,
|
||||
118, 122, // Transport markers
|
||||
SKIP, 2,
|
||||
157, 157,
|
||||
114, 115, // Small up/down arrows
|
||||
SKIP, 1,
|
||||
161, 225,
|
||||
/* Small font */
|
||||
226, 316, // ' ' till 'z'
|
||||
SKIP, 36,
|
||||
384, 384, // Move ¾ to the correct position
|
||||
322, 322, // Up arrow
|
||||
355, 357,
|
||||
SKIP, 1, // skip currency sign
|
||||
359, 359,
|
||||
SKIP, 1,
|
||||
361, 361,
|
||||
SKIP, 1,
|
||||
363, 363,
|
||||
364, 364, // TODO Down arrow
|
||||
365, 366,
|
||||
SKIP, 1,
|
||||
368, 368,
|
||||
369, 369, // TODO Right arrow
|
||||
370, 373,
|
||||
SKIP, 7,
|
||||
381, 381,
|
||||
SKIP, 3,
|
||||
385, 449,
|
||||
/* Big font */
|
||||
450, 540, // ' ' till 'z'
|
||||
SKIP, 36,
|
||||
608, 608, // Move ¾ to the correct position
|
||||
SKIP, 1,
|
||||
579, 581,
|
||||
SKIP, 1,
|
||||
583, 583,
|
||||
SKIP, 5,
|
||||
589, 589,
|
||||
SKIP, 15,
|
||||
605, 605,
|
||||
SKIP, 3,
|
||||
609, 625,
|
||||
SKIP, 1,
|
||||
627, 632,
|
||||
SKIP, 1,
|
||||
634, 639,
|
||||
SKIP, 1,
|
||||
641, 657,
|
||||
SKIP, 1,
|
||||
659, 664,
|
||||
SKIP, 2,
|
||||
667, 671,
|
||||
SKIP, 1,
|
||||
673, 673,
|
||||
/* Graphics */
|
||||
674, 4792,
|
||||
END
|
||||
};
|
||||
|
||||
/* NOTE: When adding a normal sprite, increase OPENTTD_SPRITES_COUNT with the
|
||||
* amount of sprites and add them to the end of the list, with the index of
|
||||
* the old sprite-count offset from SPR_OPENTTD_BASE. With this there is no
|
||||
* correspondence of any kind with the ID's in the grf file, but results in
|
||||
* a maximum use of sprite slots. */
|
||||
#define OPENTTD_SPRITES_COUNT 95
|
||||
static const SpriteID _openttd_grf_indexes[] = {
|
||||
SPR_IMG_AUTORAIL, SPR_CURSOR_WAYPOINT, // icons etc
|
||||
134, 134, // euro symbol medium size
|
||||
582, 582, // euro symbol large size
|
||||
358, 358, // euro symbol tiny
|
||||
SPR_CURSOR_CANAL, SPR_IMG_FASTFORWARD, // more icons
|
||||
648, 648, // nordic char: æ
|
||||
616, 616, // nordic char: Æ
|
||||
666, 666, // nordic char: ø
|
||||
634, 634, // nordic char: Ø
|
||||
SPR_PIN_UP, SPR_CURSOR_CLONE, // more icons
|
||||
382, 383, // ¼ ½ tiny
|
||||
158, 159, // ¼ ½ medium
|
||||
606, 607, // ¼ ½ large
|
||||
360, 360, // ¦ tiny
|
||||
362, 362, // ¨ tiny
|
||||
136, 136, // ¦ medium
|
||||
138, 138, // ¨ medium
|
||||
584, 584, // ¦ large
|
||||
586, 586, // ¨ large
|
||||
626, 626, // Ð large
|
||||
658, 658, // ð large
|
||||
374, 374, // ´ tiny
|
||||
378, 378, // ¸ tiny
|
||||
150, 150, // ´ medium
|
||||
154, 154, // ¸ medium
|
||||
598, 598, // ´ large
|
||||
602, 602, // ¸ large
|
||||
640, 640, // Þ large
|
||||
672, 672, // þ large
|
||||
380, 380, // º tiny
|
||||
156, 156, // º medium
|
||||
604, 604, // º large
|
||||
317, 320, // { | } ~ tiny
|
||||
93, 96, // { | } ~ medium
|
||||
541, 544, // { | } ~ large
|
||||
SPR_HOUSE_ICON, SPR_HOUSE_ICON,
|
||||
585, 585, // § large
|
||||
587, 587, // © large
|
||||
592, 592, // ® large
|
||||
594, 597, // ° ± ² ³ large
|
||||
633, 633, // × large
|
||||
665, 665, // ÷ large
|
||||
END
|
||||
};
|
||||
|
||||
static byte _sprite_page_to_load = 0xFF;
|
||||
|
||||
static void LoadSpriteTables(void)
|
||||
{
|
||||
const FileList* files = _use_dos_palette ? &files_dos : &files_win;
|
||||
uint load_index;
|
||||
uint i;
|
||||
|
||||
LoadGrfIndexed(files->basic[0].filename, trg1idx, 0);
|
||||
DupSprite( 2, 130); // non-breaking space medium
|
||||
DupSprite(226, 354); // non-breaking space tiny
|
||||
DupSprite(450, 578); // non-breaking space large
|
||||
load_index = 4793;
|
||||
|
||||
for (i = 1; files->basic[i].filename != NULL; i++) {
|
||||
load_index += LoadGrfFile(files->basic[i].filename, load_index, i);
|
||||
}
|
||||
|
||||
if (_sprite_page_to_load != 0) {
|
||||
LoadGrfIndexed(
|
||||
files->landscape[_sprite_page_to_load - 1].filename,
|
||||
_landscape_spriteindexes[_sprite_page_to_load - 1],
|
||||
i++
|
||||
);
|
||||
}
|
||||
|
||||
assert(load_index == SPR_CANALS_BASE);
|
||||
load_index += LoadGrfFile("canalsw.grf", load_index, i++);
|
||||
|
||||
assert(load_index == SPR_SLOPES_BASE);
|
||||
LoadGrfIndexed("trkfoundw.grf", _slopes_spriteindexes[_opt.landscape], i++);
|
||||
|
||||
load_index = SPR_AUTORAIL_BASE;
|
||||
load_index += LoadGrfFile("autorail.grf", load_index, i++);
|
||||
|
||||
assert(load_index == SPR_OPENTTD_BASE);
|
||||
LoadGrfIndexed("openttd.grf", _openttd_grf_indexes, i++);
|
||||
load_index = SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT;
|
||||
|
||||
LoadNewGRF(load_index, i);
|
||||
}
|
||||
|
||||
|
||||
void GfxLoadSprites(void)
|
||||
{
|
||||
// Need to reload the sprites only if the landscape changed
|
||||
if (_sprite_page_to_load != _opt.landscape) {
|
||||
_sprite_page_to_load = _opt.landscape;
|
||||
|
||||
// Sprite cache
|
||||
DEBUG(spritecache, 1) ("Loading sprite set %d.", _sprite_page_to_load);
|
||||
|
||||
GfxInitSpriteMem();
|
||||
LoadSpriteTables();
|
||||
GfxInitPalettes();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef GFXINIT_H
|
||||
#define GFXINIT_H
|
||||
|
||||
void CheckExternalFiles(void);
|
||||
void GfxLoadSprites(void);
|
||||
|
||||
#endif /* GFXINIT_H */
|
||||
+428
-565
File diff suppressed because it is too large
Load Diff
@@ -1,128 +1,109 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef GUI_H
|
||||
#define GUI_H
|
||||
|
||||
#include "station.h"
|
||||
#include "window.h"
|
||||
|
||||
/* main_gui.c */
|
||||
void SetupColorsAndInitialWindow(void);
|
||||
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||
void SetupColorsAndInitialWindow();
|
||||
void CcPlaySound10(bool success, uint tile, uint32 p1, uint32 p2);
|
||||
void PlaceProc_Sign(uint tile);
|
||||
|
||||
/* settings_gui.c */
|
||||
void ShowGameOptions(void);
|
||||
void ShowGameDifficulty(void);
|
||||
void ShowPatchesSelection(void);
|
||||
void ShowNewgrf(void);
|
||||
void ShowGameOptions();
|
||||
void ShowGameDifficulty();
|
||||
void ShowPatchesSelection();
|
||||
void ShowNewgrf();
|
||||
void ShowCustCurrency();
|
||||
|
||||
/* graph_gui.c */
|
||||
void ShowOperatingProfitGraph(void);
|
||||
void ShowIncomeGraph(void);
|
||||
void ShowDeliveredCargoGraph(void);
|
||||
void ShowPerformanceHistoryGraph(void);
|
||||
void ShowCompanyValueGraph(void);
|
||||
void ShowCargoPaymentRates(void);
|
||||
void ShowCompanyLeagueTable(void);
|
||||
void ShowPerformanceRatingDetail(void);
|
||||
void ShowOperatingProfitGraph();
|
||||
void ShowIncomeGraph();
|
||||
void ShowDeliveredCargoGraph();
|
||||
void ShowPerformanceHistoryGraph();
|
||||
void ShowCompanyValueGraph();
|
||||
void ShowCargoPaymentRates();
|
||||
void ShowCompanyLeagueTable();
|
||||
void ShowPerformanceRatingDetail();
|
||||
|
||||
/* news_gui.c */
|
||||
void ShowLastNewsMessage(void);
|
||||
void ShowMessageOptions(void);
|
||||
void ShowMessageHistory(void);
|
||||
void ShowLastNewsMessage();
|
||||
void ShowMessageOptions();
|
||||
void ShowMessageHistory();
|
||||
|
||||
/* traintoolb_gui.c */
|
||||
void ShowBuildRailToolbar(RailType railtype, int button);
|
||||
void PlaceProc_BuyLand(TileIndex tile);
|
||||
void ShowBuildRailToolbar(int index, int button);
|
||||
void PlaceProc_BuyLand(uint tile);
|
||||
|
||||
/* train_gui.c */
|
||||
void ShowPlayerTrains(PlayerID player, StationID station);
|
||||
void ShowTrainViewWindow(const Vehicle *v);
|
||||
void ShowOrdersWindow(const Vehicle* v);
|
||||
void ShowPlayerTrains(int player, int station);
|
||||
void ShowTrainViewWindow(Vehicle *v);
|
||||
void ShowTrainDetailsWindow(Vehicle *v);
|
||||
void ShowOrdersWindow(Vehicle *v);
|
||||
|
||||
void ShowRoadVehViewWindow(const Vehicle* v);
|
||||
void ShowRoadVehViewWindow(Vehicle *v);
|
||||
|
||||
/* road_gui.c */
|
||||
void ShowBuildRoadToolbar(void);
|
||||
void ShowBuildRoadScenToolbar(void);
|
||||
void ShowPlayerRoadVehicles(PlayerID player, StationID station);
|
||||
void ShowBuildRoadToolbar();
|
||||
void ShowBuildRoadScenToolbar();
|
||||
void ShowPlayerRoadVehicles(int player, int station);
|
||||
|
||||
/* dock_gui.c */
|
||||
void ShowBuildDocksToolbar(void);
|
||||
void ShowPlayerShips(PlayerID player, StationID station);
|
||||
void ShowBuildDocksToolbar();
|
||||
void ShowPlayerShips(int player, int station);
|
||||
|
||||
void ShowShipViewWindow(const Vehicle* v);
|
||||
void ShowShipViewWindow(Vehicle *v);
|
||||
|
||||
/* aircraft_gui.c */
|
||||
void ShowBuildAirToolbar(void);
|
||||
void ShowPlayerAircraft(PlayerID player, StationID station);
|
||||
void ShowBuildAirToolbar();
|
||||
void ShowPlayerAircraft(int player, int station);
|
||||
|
||||
/* terraform_gui.c */
|
||||
void ShowTerraformToolbar(void);
|
||||
|
||||
void PlaceProc_DemolishArea(TileIndex tile);
|
||||
void PlaceProc_LevelLand(TileIndex tile);
|
||||
bool GUIPlaceProcDragXY(const WindowEvent *we);
|
||||
|
||||
enum { // max 32 - 4 = 28 types
|
||||
GUI_PlaceProc_DemolishArea = 0 << 4,
|
||||
GUI_PlaceProc_LevelArea = 1 << 4,
|
||||
GUI_PlaceProc_DesertArea = 2 << 4,
|
||||
GUI_PlaceProc_WaterArea = 3 << 4,
|
||||
GUI_PlaceProc_ConvertRailArea = 4 << 4,
|
||||
GUI_PlaceProc_RockyArea = 5 << 4,
|
||||
};
|
||||
void PlaceProc_DemolishArea(uint tile);
|
||||
void PlaceProc_LowerLand(uint tile);
|
||||
void PlaceProc_RaiseLand(uint tile);
|
||||
void PlaceProc_LevelLand(uint tile);
|
||||
void ShowTerraformToolbar();
|
||||
|
||||
/* misc_gui.c */
|
||||
void PlaceLandBlockInfo(void);
|
||||
void ShowAboutWindow(void);
|
||||
void ShowBuildTreesToolbar(void);
|
||||
void ShowBuildTreesScenToolbar(void);
|
||||
void ShowTownDirectory(void);
|
||||
void ShowIndustryDirectory(void);
|
||||
void ShowSubsidiesList(void);
|
||||
void ShowPlayerStations(PlayerID player);
|
||||
void ShowPlayerFinances(PlayerID player);
|
||||
void ShowPlayerCompany(PlayerID player);
|
||||
void ShowSignList(void);
|
||||
void PlaceLandBlockInfo();
|
||||
void ShowAboutWindow();
|
||||
void ShowBuildTreesToolbar();
|
||||
void ShowBuildTreesScenToolbar();
|
||||
void ShowTownDirectory();
|
||||
void ShowIndustryDirectory();
|
||||
void ShowSubsidiesList();
|
||||
void ShowPlayerStations(int player);
|
||||
void ShowPlayerFinances(int player);
|
||||
void ShowPlayerCompany(int player);
|
||||
|
||||
void ShowEstimatedCostOrIncome(int32 cost, int x, int y);
|
||||
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y);
|
||||
|
||||
void DrawStationCoverageAreaText(int sx, int sy, uint mask,int rad);
|
||||
void CheckRedrawStationCoverage(const Window* w);
|
||||
void CheckRedrawStationCoverage(Window *w);
|
||||
|
||||
void ShowSmallMap(void);
|
||||
void ShowExtraViewPortWindow(void);
|
||||
void ShowSmallMap();
|
||||
void ShowExtraViewPortWindow();
|
||||
void SetVScrollCount(Window *w, int num);
|
||||
void SetVScroll2Count(Window *w, int num);
|
||||
void SetHScrollCount(Window *w, int num);
|
||||
int HandleEditBoxKey(Window *w, int wid, WindowEvent *we);
|
||||
|
||||
void ShowCheatWindow(void);
|
||||
void AskForNewGameToStart(void);
|
||||
void ShowCheatWindow();
|
||||
void AskForNewGameToStart();
|
||||
|
||||
void DrawEditBox(Window *w, querystr_d *string, int wid);
|
||||
void HandleEditBox(Window *w, querystr_d *string, int wid);
|
||||
int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we);
|
||||
bool HandleCaret(Textbuf *tb);
|
||||
void DrawEditBox(Window *w, int wid);
|
||||
void HandleEditBox(Window *w, int wid);
|
||||
|
||||
void DeleteTextBufferAll(Textbuf *tb);
|
||||
bool DeleteTextBufferChar(Textbuf *tb, int delmode);
|
||||
bool InsertTextBufferChar(Textbuf *tb, byte key);
|
||||
bool InsertTextBufferClipboard(Textbuf *tb);
|
||||
bool MoveTextBufferPos(Textbuf *tb, int navmode);
|
||||
void UpdateTextBufferSize(Textbuf *tb);
|
||||
|
||||
void BuildFileList(void);
|
||||
void BuildFileList();
|
||||
void SetFiosType(const byte fiostype);
|
||||
|
||||
/* FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
|
||||
extern const byte _fios_colors[];
|
||||
static const byte _fios_colors[] = {13, 9, 9, 6, 5, 6, 5};
|
||||
|
||||
|
||||
/* network gui */
|
||||
void ShowNetworkGameWindow(void);
|
||||
void ShowNetworkGameWindow();
|
||||
void ShowChatWindow(StringID str, StringID caption, int maxlen, int maxwidth, byte window_class, uint16 window_number);
|
||||
|
||||
/* bridge_gui.c */
|
||||
void ShowBuildBridgeWindow(uint start, uint end, byte type);
|
||||
@@ -134,15 +115,15 @@ enum {
|
||||
};
|
||||
|
||||
bool DoZoomInOutWindow(int how, Window * w);
|
||||
void ShowBuildIndustryWindow(void);
|
||||
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, WindowClass window_class, WindowNumber window_number);
|
||||
void ShowMusicWindow(void);
|
||||
void ShowBuildIndustryWindow();
|
||||
void ShowQueryString(StringID str, StringID caption, int maxlen, int maxwidth, byte window_class, uint16 window_number);
|
||||
void ShowMusicWindow();
|
||||
|
||||
/* main_gui.c */
|
||||
VARDEF byte _newspaper_flag;
|
||||
VARDEF byte _construct_mode;
|
||||
VARDEF byte _station_show_coverage;
|
||||
VARDEF PlaceProc *_place_proc;
|
||||
|
||||
/* vehicle_gui.c */
|
||||
void InitializeGUI(void);
|
||||
VARDEF bool _no_button_sound;
|
||||
|
||||
#endif /* GUI_H */
|
||||
|
||||
@@ -1,58 +1,116 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef HAL_H
|
||||
#define HAL_H
|
||||
|
||||
typedef struct {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)(void);
|
||||
char *(*start)(char **parm);
|
||||
void (*stop)();
|
||||
} HalCommonDriver;
|
||||
|
||||
typedef struct {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)(void);
|
||||
const char *(*start)(char **parm);
|
||||
void (*stop)();
|
||||
void (*make_dirty)(int left, int top, int width, int height);
|
||||
void (*main_loop)(void);
|
||||
int (*main_loop)();
|
||||
bool (*change_resolution)(int w, int h);
|
||||
void (*toggle_fullscreen)(bool fullscreen);
|
||||
} HalVideoDriver;
|
||||
|
||||
enum {
|
||||
ML_QUIT = 0,
|
||||
ML_SWITCHDRIVER = 1,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)(void);
|
||||
char *(*start)(char **parm);
|
||||
void (*stop)();
|
||||
} HalSoundDriver;
|
||||
|
||||
typedef struct {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)(void);
|
||||
char *(*start)(char **parm);
|
||||
void (*stop)();
|
||||
|
||||
void (*play_song)(const char *filename);
|
||||
void (*stop_song)(void);
|
||||
bool (*is_song_playing)(void);
|
||||
void (*stop_song)();
|
||||
bool (*is_song_playing)();
|
||||
void (*set_volume)(byte vol);
|
||||
} HalMusicDriver;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *longname;
|
||||
const void *drv;
|
||||
uint32 flags;
|
||||
} DriverDesc;
|
||||
|
||||
enum {
|
||||
HALERR_OK = 0,
|
||||
HALERR_ERROR = 1,
|
||||
};
|
||||
|
||||
extern const HalMusicDriver _null_music_driver;
|
||||
extern const HalVideoDriver _null_video_driver;
|
||||
extern const HalSoundDriver _null_sound_driver;
|
||||
|
||||
VARDEF HalMusicDriver *_music_driver;
|
||||
VARDEF HalSoundDriver *_sound_driver;
|
||||
VARDEF HalVideoDriver *_video_driver;
|
||||
|
||||
extern const DriverDesc _video_driver_descs[];
|
||||
extern const DriverDesc _sound_driver_descs[];
|
||||
extern const DriverDesc _music_driver_descs[];
|
||||
|
||||
#if defined(WITH_SDL)
|
||||
extern const HalSoundDriver _sdl_sound_driver;
|
||||
extern const HalVideoDriver _sdl_video_driver;
|
||||
#endif
|
||||
|
||||
#if defined(UNIX)
|
||||
extern const HalMusicDriver _extmidi_music_driver;
|
||||
#endif
|
||||
|
||||
#if defined(__BEOS__)
|
||||
extern const HalMusicDriver _bemidi_music_driver;
|
||||
#endif
|
||||
|
||||
extern const HalVideoDriver _dedicated_video_driver;
|
||||
|
||||
enum DriverType {
|
||||
VIDEO_DRIVER = 0,
|
||||
SOUND_DRIVER = 1,
|
||||
MUSIC_DRIVER = 2,
|
||||
};
|
||||
|
||||
extern void GameLoop(void);
|
||||
extern void GameLoop();
|
||||
extern bool _dbg_screen_rect;
|
||||
|
||||
void LoadDriver(int driver, const char *name);
|
||||
|
||||
char *GetDriverParam(char **parm, const char *name);
|
||||
bool GetDriverParamBool(char **parm, const char *name);
|
||||
int GetDriverParamInt(char **parm, const char *name, int def);
|
||||
|
||||
|
||||
|
||||
// Deals with finding savegames
|
||||
typedef struct {
|
||||
uint16 id;
|
||||
byte type;
|
||||
uint64 mtime;
|
||||
char title[64];
|
||||
char name[256-12-64];
|
||||
int old_extension;
|
||||
} FiosItem;
|
||||
|
||||
// extensions of old savegames, scenarios
|
||||
static const char* const _old_extensions[] = {
|
||||
// old savegame types
|
||||
"ss1", // Transport Tycoon Deluxe preset game
|
||||
"sv1", // Transport Tycoon Deluxe (Patch) saved game
|
||||
"sv2", // Transport Tycoon Deluxe (Patch) saved 2-player game
|
||||
// old scenario game type
|
||||
"sv0", // Transport Tycoon Deluxe (Patch) scenario
|
||||
"ss0", // Transport Tycoon Deluxe preset scenario
|
||||
};
|
||||
|
||||
enum {
|
||||
FIOS_TYPE_DRIVE = 0,
|
||||
FIOS_TYPE_PARENT = 1,
|
||||
@@ -61,7 +119,6 @@ enum {
|
||||
FIOS_TYPE_OLDFILE = 4,
|
||||
FIOS_TYPE_SCENARIO = 5,
|
||||
FIOS_TYPE_OLD_SCENARIO = 6,
|
||||
FIOS_TYPE_DIRECT = 7,
|
||||
};
|
||||
|
||||
|
||||
@@ -80,18 +137,18 @@ FiosItem *FiosGetSavegameList(int *num, int mode);
|
||||
// Get a list of scenarios
|
||||
FiosItem *FiosGetScenarioList(int *num, int mode);
|
||||
// Free the list of savegames
|
||||
void FiosFreeSavegameList(void);
|
||||
void FiosFreeSavegameList();
|
||||
// Browse to. Returns a filename w/path if we reached a file.
|
||||
char *FiosBrowseTo(const FiosItem *item);
|
||||
// Return path, free space and stringID
|
||||
StringID FiosGetDescText(const char **path, uint32 *tot);
|
||||
// Get descriptive texts.
|
||||
// Returns a path as well as a
|
||||
// string describing the path.
|
||||
StringID FiosGetDescText(const char **path);
|
||||
// Delete a name
|
||||
bool FiosDelete(const char *name);
|
||||
void FiosDelete(const char *name);
|
||||
// Make a filename from a name
|
||||
void FiosMakeSavegameName(char *buf, const char *name, size_t size);
|
||||
void FiosMakeSavegameName(char *buf, const char *name);
|
||||
|
||||
int CDECL compare_FiosItems(const void *a, const void *b);
|
||||
|
||||
void CreateConsole(void);
|
||||
void CreateConsole();
|
||||
|
||||
#endif /* HAL_H */
|
||||
|
||||
+4
-40
@@ -1,15 +1,11 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef INDUSTRY_H
|
||||
#define INDUSTRY_H
|
||||
|
||||
#include "pool.h"
|
||||
|
||||
struct Industry {
|
||||
TileIndex xy;
|
||||
byte width; /* swapped order of w/h with town */
|
||||
byte height;
|
||||
const Town* town;
|
||||
Town *town;
|
||||
byte produced_cargo[2];
|
||||
uint16 cargo_waiting[2];
|
||||
byte production_rate[2];
|
||||
@@ -27,44 +23,12 @@ struct Industry {
|
||||
byte color_map;
|
||||
byte last_prod_year;
|
||||
byte was_cargo_delivered;
|
||||
|
||||
uint16 index;
|
||||
};
|
||||
|
||||
extern MemoryPool _industry_pool;
|
||||
|
||||
/**
|
||||
* Check if an Industry really exists.
|
||||
*/
|
||||
static inline bool IsValidIndustry(Industry* industry)
|
||||
{
|
||||
return industry->xy != 0; /* XXX: Replace by INVALID_TILE someday */
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer to the industry with index 'index'
|
||||
*/
|
||||
static inline Industry *GetIndustry(uint index)
|
||||
{
|
||||
return (Industry*)GetItemFromPool(&_industry_pool, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current size of the IndustryPool
|
||||
*/
|
||||
static inline uint16 GetIndustryPoolSize(void)
|
||||
{
|
||||
return _industry_pool.total_items;
|
||||
}
|
||||
|
||||
#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL)
|
||||
#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)
|
||||
|
||||
VARDEF int _total_industries; // For the AI: the amount of industries active
|
||||
|
||||
VARDEF uint16 *_industry_sort;
|
||||
VARDEF Industry _industries[90];
|
||||
#define DEREF_INDUSTRY(i) (&_industries[i])
|
||||
VARDEF bool _industry_sort_dirty;
|
||||
|
||||
void DeleteIndustry(Industry *is);
|
||||
|
||||
enum {
|
||||
@@ -107,4 +71,4 @@ enum {
|
||||
IT_SUGAR_MINE = 36,
|
||||
};
|
||||
|
||||
#endif /* INDUSTRY_H */
|
||||
#endif
|
||||
|
||||
+548
-619
File diff suppressed because it is too large
Load Diff
+200
-295
@@ -1,36 +1,31 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "strings.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "table/sprites.h"
|
||||
#include "map.h"
|
||||
#include "gui.h"
|
||||
//#include "gui.h"
|
||||
#include "window.h"
|
||||
#include "gfx.h"
|
||||
#include "command.h"
|
||||
#include "viewport.h"
|
||||
#include "industry.h"
|
||||
#include "town.h"
|
||||
#include "variables.h"
|
||||
|
||||
/* Present in table/build_industry.h" */
|
||||
extern const byte _build_industry_types[4][12];
|
||||
static const byte _build_industry_types[4][12] = {
|
||||
{ 1, 2, 4, 6, 8, 0, 3, 5, 9, 11, 18 },
|
||||
{ 1, 14, 4, 13, 7, 0, 3, 9, 11, 15 },
|
||||
{ 25, 13, 4, 23, 22, 11, 17, 10, 24, 19, 20, 21 },
|
||||
{ 27, 30, 31, 33, 26, 28, 29, 32, 34, 35, 36 },
|
||||
};
|
||||
|
||||
extern const byte _industry_type_costs[37];
|
||||
|
||||
static void UpdateIndustryProduction(Industry *i);
|
||||
extern void DrawArrowButtons(int x, int y, int state);
|
||||
|
||||
static void BuildIndustryWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
DrawWindowWidgets(w);
|
||||
if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) {
|
||||
int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1];
|
||||
int ind_type = _build_industry_types[_opt.landscape][WP(w,def_d).data_1];
|
||||
|
||||
SetDParam(0, (_price.build_industry >> 5) * _industry_type_costs[ind_type]);
|
||||
DrawStringCentered(85, w->height - 21, STR_482F_COST, 0);
|
||||
@@ -40,13 +35,13 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e)
|
||||
case WE_CLICK: {
|
||||
int wid = e->click.widget;
|
||||
if (wid >= 3) {
|
||||
if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL))
|
||||
if (HandlePlacePushButton(w, wid, 0xFF1, 1, NULL))
|
||||
WP(w,def_d).data_1 = wid - 3;
|
||||
}
|
||||
} break;
|
||||
|
||||
case WE_PLACE_OBJ:
|
||||
if (DoCommandP(e->place.tile, _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)))
|
||||
if (DoCommandP(e->place.tile, _build_industry_types[_opt.landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)))
|
||||
ResetObjectToPlace();
|
||||
break;
|
||||
|
||||
@@ -58,130 +53,130 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
|
||||
static const Widget _build_industry_land0_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static const Widget _build_industry_land1_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static const Widget _build_industry_land2_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static const Widget _build_industry_land3_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 115, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static const Widget _build_industry_land0_widgets_extra[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY,STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY,STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 187, 0x0, STR_NULL},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION,STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION,STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 110, 121, STR_0245_OIL_RIG, STR_CONSTRUCT_OIL_RIG_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 136, 147, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 149, 160, STR_0249_IRON_ORE_MINE, STR_CONSTRUCT_IRON_ORE_MINE_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 84, 95, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 97, 108, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 110, 121, STR_0245_OIL_RIG, STR_CONSTRUCT_OIL_RIG_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 123, 134, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 136, 147, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 149, 160, STR_0249_IRON_ORE_MINE, STR_CONSTRUCT_IRON_ORE_MINE_TIP},
|
||||
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static const Widget _build_industry_land1_widgets_extra[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 174, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 174, 0x0, STR_NULL},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81+3, 92+3, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94+3, 105+3, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107+3, 118+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120+3, 131+3, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133+3, 144+3, STR_024F_GOLD_MINE, STR_CONSTRUCT_GOLD_MINE_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 81+3, 92+3, STR_0240_COAL_MINE, STR_CONSTRUCT_COAL_MINE_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 94+3, 105+3, STR_0243_FOREST, STR_CONSTRUCT_FOREST_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 107+3, 118+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 120+3, 131+3, STR_024A_OIL_WELLS, STR_CONSTRUCT_OIL_WELLS_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 133+3, 144+3, STR_024F_GOLD_MINE, STR_CONSTRUCT_GOLD_MINE_TIP},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static const Widget _build_industry_land2_widgets_extra[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 200, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 200, 0x0, STR_NULL},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_024D_FOOD_PROCESSING_PLANT,STR_026F_CONSTRUCT_FOOD_PROCESSING},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 68, 79, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81+3, 92+3, STR_024A_OIL_WELLS,STR_CONSTRUCT_OIL_WELLS_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94+3, 105+3, STR_0255_DIAMOND_MINE, STR_CONSTRUCT_DIAMOND_MINE_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107+3, 118+3, STR_0256_COPPER_ORE_MINE, STR_CONSTRUCT_COPPER_ORE_MINE_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120+3, 131+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133+3, 144+3, STR_0251_FRUIT_PLANTATION, STR_CONSTRUCT_FRUIT_PLANTATION_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146+3, 157+3, STR_0252_RUBBER_PLANTATION,STR_CONSTRUCT_RUBBER_PLANTATION_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159+3, 170+3, STR_0253_WATER_SUPPLY, STR_CONSTRUCT_WATER_SUPPLY_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 81+3, 92+3, STR_024A_OIL_WELLS,STR_CONSTRUCT_OIL_WELLS_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 94+3, 105+3, STR_0255_DIAMOND_MINE, STR_CONSTRUCT_DIAMOND_MINE_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 107+3, 118+3, STR_0256_COPPER_ORE_MINE, STR_CONSTRUCT_COPPER_ORE_MINE_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 120+3, 131+3, STR_0248_FARM, STR_CONSTRUCT_FARM_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 133+3, 144+3, STR_0251_FRUIT_PLANTATION, STR_CONSTRUCT_FRUIT_PLANTATION_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 146+3, 157+3, STR_0252_RUBBER_PLANTATION,STR_CONSTRUCT_RUBBER_PLANTATION_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 159+3, 170+3, STR_0253_WATER_SUPPLY, STR_CONSTRUCT_WATER_SUPPLY_TIP},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static const Widget _build_industry_land3_widgets_extra[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 187, 0x0, STR_NULL},
|
||||
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 7, 11, 169, 0, 13, STR_0314_FUND_NEW_INDUSTRY, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_PANEL, 7, 0, 169, 14, 187, 0x0, STR_NULL},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 16, 27, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 29, 40, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 42, 53, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 55, 66, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY},
|
||||
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68+3, 79+3, STR_0257_COTTON_CANDY_FOREST,STR_CONSTRUCT_COTTON_CANDY_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81+3, 92+3, STR_0259_BATTERY_FARM, STR_CONSTRUCT_BATTERY_FARM_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94+3, 105+3, STR_025A_COLA_WELLS, STR_CONSTRUCT_COLA_WELLS_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107+3, 118+3, STR_025D_PLASTIC_FOUNTAINS,STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120+3, 131+3, STR_025F_BUBBLE_GENERATOR, STR_CONSTRUCT_BUBBLE_GENERATOR_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133+3, 144+3, STR_0260_TOFFEE_QUARRY, STR_CONSTRUCT_TOFFEE_QUARRY_TIP},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146+3, 157+3, STR_0261_SUGAR_MINE, STR_CONSTRUCT_SUGAR_MINE_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 68+3, 79+3, STR_0257_COTTON_CANDY_FOREST,STR_CONSTRUCT_COTTON_CANDY_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 81+3, 92+3, STR_0259_BATTERY_FARM, STR_CONSTRUCT_BATTERY_FARM_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 94+3, 105+3, STR_025A_COLA_WELLS, STR_CONSTRUCT_COLA_WELLS_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 107+3, 118+3, STR_025D_PLASTIC_FOUNTAINS,STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 120+3, 131+3, STR_025F_BUBBLE_GENERATOR, STR_CONSTRUCT_BUBBLE_GENERATOR_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 133+3, 144+3, STR_0260_TOFFEE_QUARRY, STR_CONSTRUCT_TOFFEE_QUARRY_TIP},
|
||||
{ WWT_CLOSEBOX, 14, 2, 167, 146+3, 157+3, STR_0261_SUGAR_MINE, STR_CONSTRUCT_SUGAR_MINE_TIP},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -265,35 +260,33 @@ static const WindowDesc * const _industry_window_desc[2][4] = {
|
||||
},
|
||||
};
|
||||
|
||||
void ShowBuildIndustryWindow(void)
|
||||
void ShowBuildIndustryWindow()
|
||||
{
|
||||
if (_current_player == OWNER_SPECTATOR) return;
|
||||
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
|
||||
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt.landscape],0);
|
||||
}
|
||||
|
||||
#define NEED_ALTERB ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES))
|
||||
static void IndustryViewWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
// WP(w,vp2_d).data_1 is for the editbox line
|
||||
// WP(w,vp2_d).data_2 is for the clickline
|
||||
// WP(w,vp2_d).data_3 is for the click pos (left or right)
|
||||
Industry *i;
|
||||
StringID str;
|
||||
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
const Industry *i;
|
||||
StringID str;
|
||||
|
||||
i = GetIndustry(w->window_number);
|
||||
SetDParam(0, w->window_number);
|
||||
case WE_PAINT:
|
||||
// in editor, use bulldoze to destroy industry
|
||||
// Destroy Industry button costing money removed per request of dominik
|
||||
//w->disabled_state = (_patches.extra_dynamite && !_networking && _game_mode != GM_EDITOR) ? 0 : (1 << 6);
|
||||
i = DEREF_INDUSTRY(w->window_number);
|
||||
SetDParam(0, i->town->index);
|
||||
SetDParam(1, i->type + STR_4802_COAL_MINE);
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
if (i->accepts_cargo[0] != CT_INVALID) {
|
||||
if (i->accepts_cargo[0] != 0xFF) {
|
||||
SetDParam(0, _cargoc.names_s[i->accepts_cargo[0]]);
|
||||
str = STR_4827_REQUIRES;
|
||||
if (i->accepts_cargo[1] != CT_INVALID) {
|
||||
if (i->accepts_cargo[1] != 0xFF) {
|
||||
SetDParam(1, _cargoc.names_s[i->accepts_cargo[1]]);
|
||||
str++;
|
||||
if (i->accepts_cargo[2] != CT_INVALID) {
|
||||
if (i->accepts_cargo[2] != 0xFF) {
|
||||
SetDParam(2, _cargoc.names_s[i->accepts_cargo[2]]);
|
||||
str++;
|
||||
}
|
||||
@@ -301,133 +294,58 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
|
||||
DrawString(2, 107, str, 0);
|
||||
}
|
||||
|
||||
if (i->produced_cargo[0] != CT_INVALID) {
|
||||
if (i->produced_cargo[0] != 0xFF) {
|
||||
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0);
|
||||
|
||||
SetDParam(0, _cargoc.names_long[i->produced_cargo[0]]);
|
||||
SetDParam(1, i->total_production[0]);
|
||||
|
||||
SetDParam(0, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5));
|
||||
SetDParam(2, i->pct_transported[0] * 100 >> 8);
|
||||
DrawString(4 + (NEED_ALTERB ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
|
||||
// Let's put out those buttons..
|
||||
if (NEED_ALTERB)
|
||||
DrawArrowButtons(5, 127, (WP(w,vp2_d).data_2 == 1 ? WP(w,vp2_d).data_3 : 0));
|
||||
DrawString(4, 127, STR_482B_TRANSPORTED, 0);
|
||||
|
||||
if (i->produced_cargo[1] != CT_INVALID) {
|
||||
SetDParam(0, _cargoc.names_long[i->produced_cargo[1]]);
|
||||
if (i->produced_cargo[1] != 0xFF) {
|
||||
SetDParam(1, i->total_production[1]);
|
||||
SetDParam(0, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5));
|
||||
SetDParam(2, i->pct_transported[1] * 100 >> 8);
|
||||
DrawString(4 + (NEED_ALTERB ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
|
||||
// Let's put out those buttons..
|
||||
if (NEED_ALTERB)
|
||||
DrawArrowButtons(5, 137, (WP(w,vp2_d).data_2 == 2 ? WP(w,vp2_d).data_3 : 0));
|
||||
DrawString(4, 137, STR_482B_TRANSPORTED, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DrawWindowViewport(w);
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_CLICK: {
|
||||
Industry *i;
|
||||
|
||||
case WE_CLICK:
|
||||
switch(e->click.widget) {
|
||||
case 5: {
|
||||
int line;
|
||||
int x;
|
||||
byte b;
|
||||
|
||||
i = GetIndustry(w->window_number);
|
||||
|
||||
// We should work if needed..
|
||||
if (!NEED_ALTERB)
|
||||
return;
|
||||
|
||||
x = e->click.pt.x;
|
||||
line = (e->click.pt.y - 127) / 10;
|
||||
if (e->click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
|
||||
if (IS_INT_INSIDE(x, 5, 25) ) {
|
||||
// clicked buttons
|
||||
if (x < 15) {
|
||||
// decrease
|
||||
i->production_rate[line] /= 2;
|
||||
if (i->production_rate[line] < 4)
|
||||
i->production_rate[line] = 4;
|
||||
} else {
|
||||
// increase
|
||||
b = i->production_rate[line] * 2;
|
||||
if (i->production_rate[line] >= 128)
|
||||
b=255;
|
||||
i->production_rate[line] = b;
|
||||
}
|
||||
UpdateIndustryProduction(i);
|
||||
SetWindowDirty(w);
|
||||
w->flags4 |= 5 << WF_TIMEOUT_SHL;
|
||||
WP(w,vp2_d).data_2 = line+1;
|
||||
WP(w,vp2_d).data_3 = (x < 15 ? 1 : 2);
|
||||
} else if (IS_INT_INSIDE(x, 34, 160)) {
|
||||
// clicked the text
|
||||
WP(w,vp2_d).data_1 = line;
|
||||
SetDParam(0, i->production_rate[line] * 8);
|
||||
ShowQueryString(STR_CONFIG_PATCHES_INT32,
|
||||
STR_CONFIG_GAME_PRODUCTION,
|
||||
10, 100, w->window_class,
|
||||
w->window_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
i = GetIndustry(w->window_number);
|
||||
ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1));
|
||||
i = DEREF_INDUSTRY(w->window_number);
|
||||
ScrollMainWindowToTile(i->xy + TILE_XY(1,1));
|
||||
break;
|
||||
case 7:
|
||||
// Destroy Industry button costing money removed per request of dominik
|
||||
//i = DEREF_INDUSTRY(w->window_number);
|
||||
/* passing only i->xy is not safe if industry has a weird shape like:
|
||||
_ X X
|
||||
X X X
|
||||
_ <--- grass, no industry, but i->xy points there (first top-left tile)!,
|
||||
so passing i->xy to destroy industry will fail in called procedure
|
||||
*/
|
||||
//DoCommandP(i->xy, w->window_number, 0, CcPlaySound10, CMD_DESTROY_INDUSTRY | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WE_TIMEOUT:
|
||||
WP(w,vp2_d).data_2 = 0;
|
||||
WP(w,vp2_d).data_3 = 0;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
||||
case WE_ON_EDIT_TEXT:
|
||||
if (*e->edittext.str) {
|
||||
Industry *i;
|
||||
int val;
|
||||
int line;
|
||||
|
||||
i = GetIndustry(w->window_number);
|
||||
line = WP(w,vp2_d).data_1;
|
||||
val = atoi(e->edittext.str);
|
||||
if (!IS_INT_INSIDE(val, 32, 2040)) {
|
||||
if (val < 32) val = 32;
|
||||
else val = 2040;
|
||||
}
|
||||
i->production_rate[line] = (byte)(val / 8);
|
||||
UpdateIndustryProduction(i);
|
||||
SetWindowDirty(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateIndustryProduction(Industry *i)
|
||||
{
|
||||
if (i->produced_cargo[0] != CT_INVALID)
|
||||
i->total_production[0] = 8 * i->production_rate[0];
|
||||
|
||||
if (i->produced_cargo[1] != CT_INVALID)
|
||||
i->total_production[1] = 8 * i->production_rate[1];
|
||||
}
|
||||
|
||||
static const Widget _industry_view_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 9, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 9, 11, 247, 0, 13, STR_4801, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, RESIZE_NONE, 9, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_IMGBTN, RESIZE_NONE, 9, 0, 259, 14, 105, 0x0, STR_NULL},
|
||||
{ WWT_6, RESIZE_NONE, 9, 2, 257, 16, 103, 0x0, STR_NULL},
|
||||
{ WWT_IMGBTN, RESIZE_NONE, 9, 0, 259, 106, 147, 0x0, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 9, 0, 129, 148, 159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON},
|
||||
{ WWT_IMGBTN, RESIZE_NONE, 9, 130, 259, 148, 159, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, 9, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 9, 11, 247, 0, 13, STR_4801, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, 9, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_IMGBTN, 9, 0, 259, 14, 105, 0x0, STR_NULL},
|
||||
{ WWT_6, 9, 2, 257, 16, 103, 0x0, STR_NULL},
|
||||
{ WWT_IMGBTN, 9, 0, 259, 106, 147, 0x0, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, 9, 0, 129, 148, 159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON},
|
||||
{ WWT_IMGBTN, 9, 130, 259, 148, 159, 0x0, STR_NULL},
|
||||
// Destroy Industry button costing money removed per request of dominik
|
||||
//{ WWT_PUSHTXTBTN, 9, 130, 259, 148, 159, STR_INDUSTRYDIR_DESTROY, STR_482C_DESTROY_INDUSTRY},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
@@ -447,42 +365,39 @@ void ShowIndustryViewWindow(int industry)
|
||||
w = AllocateWindowDescFront(&_industry_view_desc, industry);
|
||||
if (w) {
|
||||
w->flags4 |= WF_DISABLE_VP_SCROLL;
|
||||
WP(w,vp2_d).data_1 = 0;
|
||||
WP(w,vp2_d).data_2 = 0;
|
||||
WP(w,vp2_d).data_3 = 0;
|
||||
i = GetIndustry(w->window_number);
|
||||
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, i->xy + TileDiffXY(1, 1), 1);
|
||||
i = DEREF_INDUSTRY(w->window_number);
|
||||
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, i->xy + TILE_XY(1,1), 1);
|
||||
}
|
||||
}
|
||||
|
||||
static const Widget _industry_directory_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 495, 0, 13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, RESIZE_NONE, 13, 496, 507, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 100, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 101, 200, 14, 25, STR_SORT_BY_TYPE, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 201, 300, 14, 25, STR_SORT_BY_PRODUCTION, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 301, 400, 14, 25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PANEL, RESIZE_NONE, 13, 401, 495, 14, 25, 0x0, STR_NULL},
|
||||
{ WWT_IMGBTN, RESIZE_BOTTOM, 13, 0, 495, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME},
|
||||
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 496, 507, 14, 177, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WWT_RESIZEBOX, RESIZE_TB, 13, 496, 507, 178, 189, 0x0, STR_RESIZE_BUTTON},
|
||||
{ WWT_TEXTBTN, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, 13, 11, 495, 0, 13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_STICKYBOX, 13, 496, 507, 0, 13, 0x0, STR_STICKY_BUTTON},
|
||||
{ WWT_PUSHTXTBTN, 13, 0, 100, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PUSHTXTBTN, 13, 101, 200, 14, 25, STR_SORT_BY_TYPE, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PUSHTXTBTN, 13, 201, 300, 14, 25, STR_SORT_BY_PRODUCTION, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PUSHTXTBTN, 13, 301, 400, 14, 25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP},
|
||||
{ WWT_PANEL, 13, 401, 496, 14, 25, 0x0, STR_NULL},
|
||||
{ WWT_IMGBTN, 13, 0, 496, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME},
|
||||
{ WWT_SCROLLBAR, 13, 497, 507, 14, 189, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static byte _industry_sort[lengthof(_industries)];
|
||||
static uint _num_industry_sort;
|
||||
|
||||
static char _bufcache[96];
|
||||
static uint16 _last_industry_idx;
|
||||
static byte _last_industry_idx;
|
||||
|
||||
static byte _industry_sort_order;
|
||||
|
||||
static int CDECL GeneralIndustrySorter(const void *a, const void *b)
|
||||
{
|
||||
char buf1[96];
|
||||
uint16 val;
|
||||
Industry *i = GetIndustry(*(const uint16*)a);
|
||||
Industry *j = GetIndustry(*(const uint16*)b);
|
||||
byte val;
|
||||
Industry *i = DEREF_INDUSTRY(*(const byte*)a);
|
||||
Industry *j = DEREF_INDUSTRY(*(const byte*)b);
|
||||
int r = 0;
|
||||
|
||||
switch (_industry_sort_order >> 1) {
|
||||
@@ -493,28 +408,28 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
|
||||
// FIXME - Production & Transported sort need to be inversed...but, WTF it does not wanna!
|
||||
// FIXME - And no simple --> "if (!(_industry_sort_order & 1)) r = -r;" hack at the bottom!!
|
||||
case 2: { /* Sort by Production */
|
||||
if (i->produced_cargo[0] != CT_INVALID && j->produced_cargo[0] != CT_INVALID) { // both industries produce cargo?
|
||||
if (i->produced_cargo[1] == CT_INVALID) // producing one or two things?
|
||||
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo?
|
||||
if (i->produced_cargo[1] == 0xFF) // producing one or two things?
|
||||
r = j->total_production[0] - i->total_production[0];
|
||||
else
|
||||
r = (j->total_production[0] + j->total_production[1]) / 2 - (i->total_production[0] + i->total_production[1]) / 2;
|
||||
} else if (i->produced_cargo[0] == CT_INVALID && j->produced_cargo[0] == CT_INVALID) // none of them producing anything, let them go to the name-sorting
|
||||
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting
|
||||
r = 0;
|
||||
else if (i->produced_cargo[0] == CT_INVALID) // end up the non-producer industry first/last in list
|
||||
else if (i->produced_cargo[0] == 0xFF) // end up the non-producer industry first/last in list
|
||||
r = 1;
|
||||
else
|
||||
r = -1;
|
||||
break;
|
||||
}
|
||||
case 3: /* Sort by Transported amount */
|
||||
if (i->produced_cargo[0] != CT_INVALID && j->produced_cargo[0] != CT_INVALID) { // both industries produce cargo?
|
||||
if (i->produced_cargo[1] == CT_INVALID) // producing one or two things?
|
||||
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo?
|
||||
if (i->produced_cargo[1] == 0xFF) // producing one or two things?
|
||||
r = (j->pct_transported[0] * 100 >> 8) - (i->pct_transported[0] * 100 >> 8);
|
||||
else
|
||||
r = ((j->pct_transported[0] * 100 >> 8) + (j->pct_transported[1] * 100 >> 8)) / 2 - ((i->pct_transported[0] * 100 >> 8) + (i->pct_transported[1] * 100 >> 8)) / 2;
|
||||
} else if (i->produced_cargo[0] == CT_INVALID && j->produced_cargo[0] == CT_INVALID) // none of them producing anything, let them go to the name-sorting
|
||||
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting
|
||||
r = 0;
|
||||
else if (i->produced_cargo[0] == CT_INVALID) // end up the non-producer industry first/last in list
|
||||
else if (i->produced_cargo[0] == 0xFF) // end up the non-producer industry first/last in list
|
||||
r = 1;
|
||||
else
|
||||
r = -1;
|
||||
@@ -523,13 +438,13 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
|
||||
|
||||
// default to string sorting if they are otherwise equal
|
||||
if (r == 0) {
|
||||
SetDParam(0, i->town->index);
|
||||
GetString(buf1, STR_TOWN);
|
||||
SetDParam(0, i->town->townnameparts);
|
||||
GetString(buf1, i->town->townnametype);
|
||||
|
||||
if ( (val=*(const uint16*)b) != _last_industry_idx) {
|
||||
if ( (val=*(const byte*)b) != _last_industry_idx) {
|
||||
_last_industry_idx = val;
|
||||
SetDParam(0, j->town->index);
|
||||
GetString(_bufcache, STR_TOWN);
|
||||
SetDParam(0, j->town->townnameparts);
|
||||
GetString(_bufcache, j->town->townnametype);
|
||||
}
|
||||
r = strcmp(buf1, _bufcache);
|
||||
}
|
||||
@@ -538,24 +453,19 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
|
||||
return r;
|
||||
}
|
||||
|
||||
static void MakeSortedIndustryList(void)
|
||||
static void MakeSortedIndustryList()
|
||||
{
|
||||
Industry *i;
|
||||
int n = 0;
|
||||
int n = 0, index = 0;
|
||||
|
||||
/* Create array for sorting */
|
||||
_industry_sort = realloc(_industry_sort, GetIndustryPoolSize() * sizeof(_industry_sort[0]));
|
||||
if (_industry_sort == NULL)
|
||||
error("Could not allocate memory for the industry-sorting-list");
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
if(i->xy)
|
||||
_industry_sort[n++] = i->index;
|
||||
for(i=_industries; i != endof(_industries); i++) {
|
||||
if(i->xy) _industry_sort[n++] = index;
|
||||
index++;
|
||||
}
|
||||
_num_industry_sort = n;
|
||||
_last_industry_idx = 0xFFFF; // used for "cache"
|
||||
_last_industry_idx = 255; // used for "cache"
|
||||
|
||||
qsort(_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter);
|
||||
qsort(_industry_sort, n, 1, GeneralIndustrySorter);
|
||||
|
||||
DEBUG(misc, 1) ("Resorting Industries list...");
|
||||
}
|
||||
@@ -575,36 +485,37 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
|
||||
MakeSortedIndustryList();
|
||||
}
|
||||
|
||||
SetVScrollCount(w, _num_industry_sort);
|
||||
w->vscroll.count = _num_industry_sort;
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
DoDrawString(_industry_sort_order & 1 ? DOWNARROW : UPARROW, _indicator_positions[_industry_sort_order>>1], 15, 0x10);
|
||||
DoDrawString(_industry_sort_order & 1 ? "\xAA" : "\xA0", _indicator_positions[_industry_sort_order>>1], 15, 0x10);
|
||||
|
||||
p = w->vscroll.pos;
|
||||
n = 0;
|
||||
|
||||
while (p < _num_industry_sort) {
|
||||
i = GetIndustry(_industry_sort[p]);
|
||||
SetDParam(0, i->index);
|
||||
if (i->produced_cargo[0] != CT_INVALID) {
|
||||
SetDParam(1, _cargoc.names_long[i->produced_cargo[0]]);
|
||||
SetDParam(2, i->total_production[0]);
|
||||
i = DEREF_INDUSTRY(_industry_sort[p]);
|
||||
SetDParam(0, i->town->index);
|
||||
SetDParam(1, i->type + STR_4802_COAL_MINE);
|
||||
if (i->produced_cargo[0] != 0xFF) {
|
||||
SetDParam(3, i->total_production[0]);
|
||||
SetDParam(2, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5));
|
||||
|
||||
if (i->produced_cargo[1] != CT_INVALID) {
|
||||
SetDParam(3, _cargoc.names_long[i->produced_cargo[1]]);
|
||||
SetDParam(4, i->total_production[1]);
|
||||
SetDParam(5, i->pct_transported[0] * 100 >> 8);
|
||||
SetDParam(6, i->pct_transported[1] * 100 >> 8);
|
||||
if (i->produced_cargo[1] != 0xFF) {
|
||||
SetDParam(5, i->total_production[1]);
|
||||
SetDParam(4, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5));
|
||||
SetDParam(6, i->pct_transported[0] * 100 >> 8);
|
||||
SetDParam(7, i->pct_transported[1] * 100 >> 8);
|
||||
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_TWO, 0);
|
||||
} else {
|
||||
SetDParam(3, i->pct_transported[0] * 100 >> 8);
|
||||
SetDParam(4, i->pct_transported[0] * 100 >> 8);
|
||||
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM, 0);
|
||||
}
|
||||
} else {
|
||||
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_NOPROD, 0);
|
||||
}
|
||||
p++;
|
||||
if (++n == w->vscroll.cap)
|
||||
if (++n == 16)
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
@@ -637,14 +548,14 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
case 8: {
|
||||
int y = (e->click.pt.y - 28) / 10;
|
||||
uint16 p;
|
||||
byte p;
|
||||
Industry *c;
|
||||
|
||||
if (!IS_INT_INSIDE(y, 0, w->vscroll.cap))
|
||||
if (!IS_INT_INSIDE(y, 0, 16))
|
||||
return;
|
||||
p = y + w->vscroll.pos;
|
||||
if (p < _num_industry_sort) {
|
||||
c = GetIndustry(_industry_sort[p]);
|
||||
c = DEREF_INDUSTRY(_industry_sort[p]);
|
||||
ScrollMainWindowToTile(c->xy);
|
||||
}
|
||||
} break;
|
||||
@@ -654,10 +565,6 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
|
||||
case WE_4:
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
||||
case WE_RESIZE:
|
||||
w->vscroll.cap += e->sizing.diff.y / 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,14 +573,14 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
|
||||
static const WindowDesc _industry_directory_desc = {
|
||||
-1, -1, 508, 190,
|
||||
WC_INDUSTRY_DIRECTORY,0,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
|
||||
_industry_directory_widgets,
|
||||
IndustryDirectoryWndProc
|
||||
};
|
||||
|
||||
|
||||
|
||||
void ShowIndustryDirectory(void)
|
||||
void ShowIndustryDirectory()
|
||||
{
|
||||
/* Industry List */
|
||||
Window *w;
|
||||
@@ -681,8 +588,6 @@ void ShowIndustryDirectory(void)
|
||||
w = AllocateWindowDescFront(&_industry_directory_desc, 0);
|
||||
if (w) {
|
||||
w->vscroll.cap = 16;
|
||||
w->resize.height = w->height - 6 * 10; // minimum 10 items
|
||||
w->resize.step_height = 10;
|
||||
SetWindowDirty(w);
|
||||
}
|
||||
}
|
||||
|
||||
+182
-139
@@ -1,114 +1,87 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "ttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
#include "viewport.h"
|
||||
#include "gfx.h"
|
||||
#include "player.h"
|
||||
#include "command.h"
|
||||
#include "console.h"
|
||||
#include "network.h"
|
||||
#include "variables.h"
|
||||
|
||||
extern void SwitchMode(int new_mode);
|
||||
|
||||
/*
|
||||
static void ShowSelectTutorialWindow()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
static const Widget _select_game_widgets[] = {
|
||||
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
|
||||
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 335, 14, 196, STR_NULL, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 40, 51, STR_0220_CREATE_SCENARIO,STR_02FE_CREATE_A_CUSTOMIZED_GAME},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING},
|
||||
{ WWT_PANEL_2, RESIZE_NONE, 12, 10, 86, 59, 113, 0x1312, STR_030E_SELECT_TEMPERATE_LANDSCAPE},
|
||||
{ WWT_PANEL_2, RESIZE_NONE, 12, 90, 166, 59, 113, 0x1314, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
|
||||
{ WWT_PANEL_2, RESIZE_NONE, 12, 170, 246, 59, 113, 0x1316, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
|
||||
{ WWT_PANEL_2, RESIZE_NONE, 12, 250, 326, 59, 113, 0x1318, STR_0311_SELECT_TOYLAND_LANDSCAPE},
|
||||
|
||||
{ WWT_PANEL, RESIZE_NONE, 12, 219, 254, 120, 131, STR_NULL, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 12, 255, 266, 120, 131, STR_0225, STR_NULL},
|
||||
{ WWT_PANEL, RESIZE_NONE, 12, 279, 314, 120, 131, STR_NULL, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 12, 315, 326, 120, 131, STR_0225, STR_NULL},
|
||||
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 138, 149, STR_SINGLE_PLAYER, STR_02FF_SELECT_SINGLE_PLAYER_GAME},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 138, 149, STR_MULTIPLAYER, STR_0300_SELECT_MULTIPLAYER_GAME},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 159, 170, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 159, 170, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 177, 188, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP},
|
||||
{ WWT_PUSHTXTBTN, RESIZE_NONE, 12, 168, 325, 177, 188, STR_0304_QUIT, STR_0305_QUIT_OPENTTD},
|
||||
{ WIDGETS_END },
|
||||
{ WWT_CAPTION, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
|
||||
{ WWT_IMGBTN, 13, 0, 335, 14, 196, 0x0, STR_NULL},
|
||||
{ WWT_PUSHTXTBTN, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME},
|
||||
{ WWT_PUSHTXTBTN, 12, 168, 325, 22, 33, STR_0141_LOAD_GAME, STR_02FC_LOAD_A_SAVED_GAME},
|
||||
//{ WWT_PUSHTXTBTN, 12, 10, 167, 177, 188, STR_0142_TUTORIAL_DEMONSTRATION, STR_02FD_VIEW_DEMONSTRATIONS_TUTORIALS},
|
||||
{ WWT_PUSHTXTBTN, 12, 10, 167, 177, 188, STR_CONFIG_PATCHES, STR_CONFIG_PATCHES_TIP},
|
||||
{ WWT_PUSHTXTBTN, 12, 10, 167, 40, 51, STR_0220_CREATE_SCENARIO,STR_02FE_CREATE_A_CUSTOMIZED_GAME},
|
||||
{ WWT_PUSHTXTBTN, 12, 10, 167, 136, 147, STR_SINGLE_PLAYER, STR_02FF_SELECT_SINGLE_PLAYER_GAME},
|
||||
{ WWT_PUSHTXTBTN, 12, 168, 325, 136, 147, STR_MULTIPLAYER, STR_0300_SELECT_MULTIPLAYER_GAME},
|
||||
{ WWT_PUSHTXTBTN, 12, 10, 167, 159, 170, STR_0148_GAME_OPTIONS, STR_0301_DISPLAY_GAME_OPTIONS},
|
||||
{ WWT_PUSHTXTBTN, 12, 168, 325, 159, 170, STR_01FE_DIFFICULTY, STR_0302_DISPLAY_DIFFICULTY_OPTIONS},
|
||||
{ WWT_PUSHTXTBTN, 12, 168, 325, 40, 51, STR_029A_PLAY_SCENARIO, STR_0303_START_A_NEW_GAME_USING},
|
||||
{ WWT_PUSHTXTBTN, 12, 168, 325, 177, 188, STR_0304_QUIT, STR_0305_QUIT_OPENTTD},
|
||||
{ WWT_PANEL_2, 12, 10, 85, 69, 122, 0x1312, STR_030E_SELECT_TEMPERATE_LANDSCAPE},
|
||||
{ WWT_PANEL_2, 12, 90, 165, 69, 122, 0x1314, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
|
||||
{ WWT_PANEL_2, 12, 170, 245, 69, 122, 0x1316, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
|
||||
{ WWT_PANEL_2, 12, 250, 325, 69, 122, 0x1318, STR_0311_SELECT_TOYLAND_LANDSCAPE},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
extern void HandleOnEditText(WindowEvent *e);
|
||||
extern void HandleOnEditTextCancel(void);
|
||||
extern void HandleOnEditTextCancel();
|
||||
|
||||
static inline void CreateScenario(void) {_switch_mode = SM_EDITOR;}
|
||||
|
||||
static inline void SetNewLandscapeType(byte landscape)
|
||||
{
|
||||
_opt_newgame.landscape = landscape;
|
||||
InvalidateWindowClasses(WC_SELECT_GAME);
|
||||
}
|
||||
|
||||
static void SelectGameWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
/* We do +/- 6 for the map_xy because 64 is 2^6, but it is the lowest available element */
|
||||
static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
|
||||
|
||||
switch (e->event) {
|
||||
static void SelectGameWndProc(Window *w, WindowEvent *e) {
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
w->click_state = (w->click_state & ~(1 << 14) & ~(0xF << 6)) | (1 << (_opt_newgame.landscape + 6)) | (1 << 14);
|
||||
SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
|
||||
w->click_state = (w->click_state & ~(0xC0) & ~(0xF << 12)) | (1 << (_new_opt.landscape+12)) | (1<<6);
|
||||
SetDParam(0, STR_6801_EASY + _new_opt.diff_level);
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
DrawStringRightAligned(216, 121, STR_MAPSIZE, 0);
|
||||
DrawString(223, 121, mapsizes[_patches.map_x - 6], 0x10);
|
||||
DrawString(270, 121, STR_BY, 0);
|
||||
DrawString(283, 121, mapsizes[_patches.map_y - 6], 0x10);
|
||||
break;
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->click.widget) {
|
||||
case 2: AskForNewGameToStart(); break;
|
||||
switch(e->click.widget) {
|
||||
case 2: DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME); break;
|
||||
case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
|
||||
case 4: CreateScenario(); break;
|
||||
case 5: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
|
||||
case 6: case 7: case 8: case 9:
|
||||
SetNewLandscapeType(e->click.widget - 6);
|
||||
break;
|
||||
case 10: case 11: /* Mapsize X */
|
||||
ShowDropDownMenu(w, mapsizes, _patches.map_x - 6, 11, 0, 0);
|
||||
break;
|
||||
case 12: case 13: /* Mapsize Y */
|
||||
ShowDropDownMenu(w, mapsizes, _patches.map_y - 6, 13, 0, 0);
|
||||
break;
|
||||
case 15:
|
||||
#ifdef ENABLE_NETWORK
|
||||
case 4: ShowPatchesSelection(); break;
|
||||
case 5: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break;
|
||||
case 7:
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_network_available) {
|
||||
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
ShowErrorMessage(-1, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
} else
|
||||
ShowNetworkGameWindow();
|
||||
#else
|
||||
ShowErrorMessage(INVALID_STRING_ID ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
#endif
|
||||
#else
|
||||
ShowErrorMessage(-1 ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
break;
|
||||
case 16: ShowGameOptions(); break;
|
||||
case 17: ShowGameDifficulty(); break;
|
||||
case 18: ShowPatchesSelection(); break;
|
||||
case 19: AskExitGame(); break;
|
||||
case 8: ShowGameOptions(); break;
|
||||
case 9: ShowGameDifficulty(); break;
|
||||
case 10:ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
|
||||
case 11:AskExitGame(); break;
|
||||
case 12: case 13: case 14: case 15:
|
||||
DoCommandP(0, e->click.widget - 12, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE);
|
||||
break;
|
||||
}
|
||||
case WE_KEYPRESS:
|
||||
switch(e->keypress.keycode) {
|
||||
case WKC_BACKQUOTE: IConsoleSwitch(); break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
|
||||
case WE_ON_EDIT_TEXT_CANCEL: HandleOnEditTextCancel(); break;
|
||||
|
||||
case WE_DROPDOWN_SELECT: /* Mapsize selection */
|
||||
switch (e->dropdown.button) {
|
||||
case 11: _patches.map_x = e->dropdown.index + 6; break;
|
||||
case 13: _patches.map_y = e->dropdown.index + 6; break;
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -121,39 +94,99 @@ static const WindowDesc _select_game_desc = {
|
||||
SelectGameWndProc
|
||||
};
|
||||
|
||||
void ShowSelectGameWindow(void)
|
||||
void ShowSelectGameWindow()
|
||||
{
|
||||
AllocateWindowDesc(&_select_game_desc);
|
||||
}
|
||||
|
||||
void GenRandomNewGame(uint32 rnd1, uint32 rnd2)
|
||||
|
||||
// p1 = mode
|
||||
// 0 - start new game
|
||||
// 1 - close new game dialog
|
||||
|
||||
int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
_random_seeds[0][0] = rnd1;
|
||||
_random_seeds[0][1] = rnd2;
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
switch(p1) {
|
||||
case 0: // show select game window
|
||||
AskForNewGameToStart();
|
||||
break;
|
||||
case 1: // close select game window
|
||||
DeleteWindowById(WC_SAVELOAD, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdGenRandomNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
// this forces stuff into test mode.
|
||||
_docommand_recursive = 0;
|
||||
|
||||
_random_seeds[0][0] = p1;
|
||||
_random_seeds[0][1] = p2;
|
||||
|
||||
SwitchMode(SM_NEWGAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void StartScenarioEditor(uint32 rnd1, uint32 rnd2)
|
||||
int32 CmdLoadGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
_random_seeds[0][0] = rnd1;
|
||||
_random_seeds[0][1] = rnd2;
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
// ShowSaveLoadDialog(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdCreateScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
_switch_mode = SM_EDITOR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdSetSinglePlayer(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
printf("CmdSetSinglePlayer\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
// this forces stuff into test mode.
|
||||
_docommand_recursive = 0;
|
||||
|
||||
_random_seeds[0][0] = p1;
|
||||
_random_seeds[0][1] = p2;
|
||||
|
||||
SwitchMode(SM_START_SCENARIO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const Widget _ask_abandon_game_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_00C7_QUIT, STR_NULL},
|
||||
{ WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
|
||||
{ WIDGETS_END },
|
||||
{ WWT_TEXTBTN, 4, 0, 10, 0, 13, STR_00C5, STR_NULL},
|
||||
{ WWT_CAPTION, 4, 11, 179, 0, 13, STR_00C7_QUIT, STR_NULL},
|
||||
{ WWT_IMGBTN, 4, 0, 179, 14, 91, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
|
||||
{ WWT_TEXTBTN, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static void AskAbandonGameWndProc(Window* w, WindowEvent* e)
|
||||
{
|
||||
switch (e->event) {
|
||||
static void AskAbandonGameWndProc(Window *w, WindowEvent *e) {
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
DrawWindowWidgets(w);
|
||||
#if defined(_WIN32)
|
||||
@@ -164,30 +197,27 @@ static void AskAbandonGameWndProc(Window* w, WindowEvent* e)
|
||||
SetDParam(0, STR_OSNAME_BEOS);
|
||||
#elif defined(__MORPHOS__)
|
||||
SetDParam(0, STR_OSNAME_MORPHOS);
|
||||
#elif defined(__AMIGA__)
|
||||
#elif defined(__AMIGA__)
|
||||
SetDParam(0, STR_OSNAME_AMIGAOS);
|
||||
#elif defined(__OS2__)
|
||||
SetDParam(0, STR_OSNAME_OS2);
|
||||
#else
|
||||
SetDParam(0, STR_0134_UNIX);
|
||||
#endif
|
||||
DrawStringMultiCenter(90, 38, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178);
|
||||
DrawStringMultiCenter(0x5A, 0x26, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178);
|
||||
return;
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->click.widget) {
|
||||
case 3: DeleteWindow(w); break;
|
||||
case 4: _exit_game = true; break;
|
||||
switch(e->click.widget) {
|
||||
case 3:
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
case 4:
|
||||
_exit_game = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_KEYPRESS: /* Exit game on pressing 'Enter' */
|
||||
switch (e->keypress.keycode) {
|
||||
case WKC_RETURN:
|
||||
case WKC_NUM_ENTER:
|
||||
_exit_game = true;
|
||||
break;
|
||||
}
|
||||
if (e->keypress.keycode == WKC_RETURN)
|
||||
_exit_game = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -200,44 +230,47 @@ static const WindowDesc _ask_abandon_game_desc = {
|
||||
AskAbandonGameWndProc
|
||||
};
|
||||
|
||||
void AskExitGame(void)
|
||||
void AskExitGame()
|
||||
{
|
||||
AllocateWindowDescFront(&_ask_abandon_game_desc, 0);
|
||||
}
|
||||
|
||||
|
||||
static const Widget _ask_quit_game_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME, STR_NULL},
|
||||
{ WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
|
||||
{ WIDGETS_END },
|
||||
{ WWT_TEXTBTN, 4, 0, 10, 0, 13, STR_00C5, STR_NULL},
|
||||
{ WWT_CAPTION, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME, STR_NULL},
|
||||
{ WWT_IMGBTN, 4, 0, 179, 14, 91, 0x0, STR_NULL},
|
||||
{ WWT_TEXTBTN, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
|
||||
{ WWT_TEXTBTN, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
static void AskQuitGameWndProc(Window* w, WindowEvent* e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT:
|
||||
DrawWindowWidgets(w);
|
||||
DrawStringMultiCenter(
|
||||
90, 38,
|
||||
_game_mode != GM_EDITOR ?
|
||||
STR_0160_ARE_YOU_SURE_YOU_WANT_TO : STR_029B_ARE_YOU_SURE_YOU_WANT_TO,
|
||||
178
|
||||
);
|
||||
break;
|
||||
static void AskQuitGameWndProc(Window *w, WindowEvent *e) {
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
DrawWindowWidgets(w);
|
||||
DrawStringMultiCenter(0x5A, 0x26,
|
||||
_game_mode != GM_EDITOR ? STR_0160_ARE_YOU_SURE_YOU_WANT_TO :
|
||||
STR_029B_ARE_YOU_SURE_YOU_WANT_TO,
|
||||
178);
|
||||
return;
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->click.widget) {
|
||||
case 3: DeleteWindow(w); break;
|
||||
case 4: _switch_mode = SM_MENU; break;
|
||||
}
|
||||
case WE_CLICK:
|
||||
switch(e->click.widget) {
|
||||
case 3:
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
case 4:
|
||||
_switch_mode = SM_MENU;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */
|
||||
if (e->keypress.keycode == WKC_RETURN)
|
||||
_switch_mode = SM_MENU;
|
||||
break;
|
||||
|
||||
case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */
|
||||
if (e->keypress.keycode == WKC_RETURN) _switch_mode = SM_MENU;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +283,17 @@ static const WindowDesc _ask_quit_game_desc = {
|
||||
};
|
||||
|
||||
|
||||
void AskExitToGameMenu(void)
|
||||
void AskExitToGameMenu()
|
||||
{
|
||||
AllocateWindowDescFront(&_ask_quit_game_desc, 0);
|
||||
}
|
||||
|
||||
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
// XXX: some stuff
|
||||
_new_opt.landscape = p1;
|
||||
InvalidateWindowClasses(WC_SELECT_GAME);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+49
-61
@@ -1,6 +1,6 @@
|
||||
README
|
||||
------------------------------------------------------------------------
|
||||
All bugs listed below are marked as known. Please do not submit any bugs
|
||||
All bugs listed below are marked as known. Please do not submit any bugs
|
||||
that are the same as these. If you do, don't act surprised, because
|
||||
we WILL flame you!!
|
||||
|
||||
@@ -11,70 +11,58 @@ go to: http://www.tt-forums.net/viewtopic.php?t=9576
|
||||
Of course if you have more knowledge about any of these bugs, have more
|
||||
specifics, we welcome you to report them. React to the given bug indicated
|
||||
by the number below on http://sourceforge.net/tracker/?group_id=103924&atid=636365
|
||||
or http://bugs.openttd.org.
|
||||
If the bug report is closed, it has been fixed, which then can be verified
|
||||
If the the bug-report is closed, it has been fixed, which then can be verified
|
||||
in the latest SVN version.
|
||||
|
||||
Bugs for 0.4.8
|
||||
------------------------------------------------------------------------
|
||||
URL: http://bugs.openttd.org
|
||||
|
||||
-78 Low Save vs. Autosave
|
||||
-73 vehicle selection bug
|
||||
-66 wagon re-fitting
|
||||
-65 short wagons bug
|
||||
-51 Windows doesn't support CUSTOM_LANG_DIR
|
||||
-50 Trains chosing an alternative path when encountering a 1-way presignal instead of waiting
|
||||
-47 Low rating calculation and cargo loading priority
|
||||
-20 Low Saving files when run from gdb 2005-12-06 Unconfirmed
|
||||
|
||||
Bugs for 0.3.5
|
||||
------------------------------------------------------------------------
|
||||
URL: http://sourceforge.net/tracker/?atid=636365&group_id=103924&func=browse
|
||||
-1085486 Subsidies: Only count when station is in right suburb
|
||||
-1084797 building stretch leaves gap
|
||||
-1084789 delivered cargo bug
|
||||
-1083941 Train gui crash assertion error
|
||||
-1083717 graphical glitch
|
||||
-1083710 Reverse train in depot crashes OpenTTD
|
||||
-1074623 bus pathfinding inadequacies
|
||||
-1074610 overtaking at signals bug
|
||||
-1065168 accept iron ore doesn't produce steel
|
||||
-1060686 changing (load) order doesn't take effect immediately
|
||||
-1053339 depot/station looping
|
||||
-1050990 Buying trains sometimes accounted for incorrectly
|
||||
-1040119 Flood and wagons in depot
|
||||
-1034778 train breaksdown, when breaks set to none
|
||||
-1033300 signal bug
|
||||
-1030918 Negative city population
|
||||
-1030502 Buying up a company isn't complete
|
||||
-1024703 Infinite access of A: when saving and no disk in drive
|
||||
-997251 Realistic acceleration: Trains don't slow down in curves
|
||||
-996503 Sound volume bug
|
||||
-992677 BeOS MIDI does not initialise on newer BeOS releases
|
||||
-985475 Different kinds of signals in same tile? [Bug]
|
||||
-980271 Realistic acceleration bug / Lev4 Chimaera becomes useless
|
||||
-978372 Inconsistent stopping.
|
||||
-968036 Ship blocked at the edge
|
||||
|
||||
-1459262 Towns building too many roads way too long now
|
||||
-1458995 Another bug with smooth_economy
|
||||
-1436419 Vehicles profits gone negative.......bug
|
||||
-1434000 Error in Transfer-Function
|
||||
-1427531 Newspapers problem
|
||||
-1417453 Makefile and Variables issue
|
||||
-1397638 Economics bug?
|
||||
-1394799 Dual headed engines disagreement
|
||||
-1393415 NPF & one-way sigs
|
||||
-1389986 Shares problem (nightly 3330)
|
||||
-1299162 Music volume too low
|
||||
-1250094 Towns Shrink when center tile is built on
|
||||
-1244842 Multiplayer interface bug (0.4.0.1)
|
||||
-1212267 station visited twice when servicing
|
||||
-1208170 Duplicate station names can be created
|
||||
-1197116 Some stations are cargo-less
|
||||
-1174829 Waypoint / Orders Bug
|
||||
-1168820 Some mouse and keyboard events are lost
|
||||
-1167810 Cargo payment after deleting stations (st->xy = 0)
|
||||
-1116638 "More, but smaller changes" deficiency
|
||||
-1106356 re-offered prototypes
|
||||
-1085486 Subsidies: Only count when station is in right suburb
|
||||
|
||||
Minor Bugs for 0.4.8
|
||||
Minor Bugs for 0.3.5
|
||||
------------------------------------------------------------------------
|
||||
URL: http://sourceforge.net/tracker/?atid=669662&group_id=103924&func=browse
|
||||
|
||||
-1412031 fast forward scrolling is also fast forward :)
|
||||
-1387424 overtake insolvent company is to cheap
|
||||
-1382782 Loan interest calculated 'wrong'
|
||||
-1236320 Bug in main menu allows moving screen
|
||||
-1201284 permanent hilight in a depot
|
||||
-1185852 Scrollbars get arbitrarily small
|
||||
-1184634 Replace vehicles window bug
|
||||
-1160732 little bug with transparency
|
||||
-1117731 Editor-StartingDate
|
||||
-1108046 game freezes
|
||||
-1102174 Bug if 3 people buy 25% shares in one company
|
||||
-1084620 Minor bug considering buses/trucks
|
||||
-1034310 color mauve in diagrams
|
||||
-1030661 It's possible to build a tunnel under oil wells
|
||||
-0993516 Canal + bouy -> wrong graphics.
|
||||
-0987891 Large UFO destruction bug
|
||||
-0987883 Aircraft landing/taking off
|
||||
-0987880 company league table updating
|
||||
-0985924 aircraft taxi speed
|
||||
-0941694 Clipping problems stations/vehicles on slopes
|
||||
-1090495 Bridges and straight lakesides
|
||||
-1087407 wrong message in history
|
||||
-1084620 Minor bug considering buses/trucks
|
||||
-1034310 color mauve in diagrams
|
||||
-1031451 Catchment area shows when buying sign.
|
||||
-1031184 Smoke visible through tunnel
|
||||
-1030661 It's possible to build a tunnel under oil wells
|
||||
-1009171 Canals and locks at sea level cause flooding
|
||||
-998902 Annoying out-of-date message
|
||||
-993516 Canal + bouy -> wrong graphics.
|
||||
-987891 Large UFO destruction bug
|
||||
-987884 farm fences
|
||||
-987883 Aircraft landing/taking off
|
||||
-987880 company league table updating
|
||||
-985927 many carriages in depot
|
||||
-985924 aircraft taxi speed
|
||||
-980276 Overflow in factory directory
|
||||
-976824 transmitter base
|
||||
-941694 Clipping problems stations/vehicles on slopes
|
||||
-936997 Stationname too long to fit in trainwindow bug
|
||||
+340
-301
@@ -1,18 +1,11 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "ttd.h"
|
||||
#include "map.h"
|
||||
#include "player.h"
|
||||
#include "spritecache.h"
|
||||
#include "table/sprites.h"
|
||||
#include "tile.h"
|
||||
#include <stdarg.h>
|
||||
#include "gfx.h"
|
||||
#include "viewport.h"
|
||||
#include "command.h"
|
||||
#include "vehicle.h"
|
||||
#include "variables.h"
|
||||
|
||||
extern const TileTypeProcs
|
||||
_tile_type_clear_procs,
|
||||
@@ -47,37 +40,84 @@ const byte _tileh_to_sprite[32] = {
|
||||
0,0,0,0,0,0,0,16,0,0,0,17,0,15,18,0,
|
||||
};
|
||||
|
||||
const byte _inclined_tileh[] = {
|
||||
3, 9, 3, 6, 12, 6, 12, 9
|
||||
};
|
||||
|
||||
|
||||
void FindLandscapeHeightByTile(TileInfo *ti, TileIndex tile)
|
||||
uint GetTileSlope(uint tile, int *h)
|
||||
{
|
||||
assert(tile < MapSize());
|
||||
uint a,b,c,d,min;
|
||||
int r;
|
||||
|
||||
ti->tile = tile;
|
||||
ti->map5 = _m[tile].m5;
|
||||
ti->type = GetTileType(tile);
|
||||
ti->tileh = GetTileSlope(tile, &ti->z);
|
||||
if (GET_TILE_X(tile) == TILE_X_MAX || GET_TILE_Y(tile) == TILE_Y_MAX) {
|
||||
if (h)
|
||||
*h = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(tile < TILES_X * TILES_Y && GET_TILE_X(tile) != TILE_X_MAX && GET_TILE_Y(tile) != TILE_Y_MAX);
|
||||
|
||||
min = a = _map_type_and_height[tile] & 0xF;
|
||||
b = _map_type_and_height[tile+TILE_XY(1,0)] & 0xF;
|
||||
if (min >= b) min = b;
|
||||
c = _map_type_and_height[tile+TILE_XY(0,1)] & 0xF;
|
||||
if (min >= c) min = c;
|
||||
d = _map_type_and_height[tile+TILE_XY(1,1)] & 0xF;
|
||||
if (min >= d) min = d;
|
||||
|
||||
r = 0;
|
||||
if ((a-=min)!=0) { r += (--a << 4) + 8; }
|
||||
if ((c-=min)!=0) { r += (--c << 4) + 4; }
|
||||
if ((d-=min)!=0) { r += (--d << 4) + 2; }
|
||||
if ((b-=min)!=0) { r += (--b << 4) + 1; }
|
||||
|
||||
if (h != 0)
|
||||
*h = min * 8;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* find the landscape height for the coordinates x y */
|
||||
void FindLandscapeHeight(TileInfo *ti, uint x, uint y)
|
||||
int GetTileZ(uint tile)
|
||||
{
|
||||
ti->x = x;
|
||||
ti->y = y;
|
||||
int h;
|
||||
GetTileSlope(tile, &h);
|
||||
return h;
|
||||
}
|
||||
|
||||
if (x >= MapMaxX() * 16 - 1 || y >= MapMaxY() * 16 - 1) {
|
||||
void FindLandscapeHeightByTile(TileInfo *ti, uint tile)
|
||||
{
|
||||
if (GET_TILE_X(tile) == TILE_X_MAX ||
|
||||
GET_TILE_Y(tile) == TILE_Y_MAX) {
|
||||
ti->tileh = 0;
|
||||
ti->type = MP_VOID;
|
||||
ti->type = MP_STRANGE;
|
||||
ti->tile = 0;
|
||||
ti->map5 = 0;
|
||||
ti->z = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
FindLandscapeHeightByTile(ti, TileVirtXY(x, y));
|
||||
ti->tile = tile;
|
||||
ti->map5 = _map5[tile];
|
||||
ti->type = GET_TILETYPE(tile);
|
||||
ti->tileh = GetTileSlope(tile, &ti->z);
|
||||
// ti->z = min * 8;
|
||||
}
|
||||
|
||||
/* find the landscape height for the coordinates x y */
|
||||
void FindLandscapeHeight(TileInfo *ti, uint x, uint y)
|
||||
{
|
||||
int tile;
|
||||
|
||||
ti->x = x;
|
||||
ti->y = y;
|
||||
|
||||
if (x >= TILE_X_MAX*16-1 || y >= TILE_Y_MAX*16-1) {
|
||||
ti->tileh = 0;
|
||||
ti->type = MP_STRANGE;
|
||||
ti->tile = 0;
|
||||
ti->map5 = 0;
|
||||
ti->z = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
tile = TILE_FROM_XY(x,y);
|
||||
FindLandscapeHeightByTile(ti, tile);
|
||||
}
|
||||
|
||||
uint GetPartialZ(int x, int y, int corners)
|
||||
@@ -178,67 +218,55 @@ uint GetPartialZ(int x, int y, int corners)
|
||||
uint GetSlopeZ(int x, int y)
|
||||
{
|
||||
TileInfo ti;
|
||||
// int z;
|
||||
|
||||
FindLandscapeHeight(&ti, x, y);
|
||||
|
||||
/*
|
||||
z = ti.z;
|
||||
x &= 0xF;
|
||||
y &= 0xF;
|
||||
|
||||
|
||||
assert(z < 256);
|
||||
*/
|
||||
return _tile_type_procs[ti.type]->get_slope_z_proc(&ti);
|
||||
}
|
||||
|
||||
|
||||
static Slope GetFoundationSlope(TileIndex tile, uint* z)
|
||||
// direction=true: check for foundation in east and south corner
|
||||
// direction=false: check for foundation in west and south corner
|
||||
bool hasFoundation(TileInfo *ti, bool direction)
|
||||
{
|
||||
TileInfo ti;
|
||||
Slope tileh;
|
||||
Slope slope;
|
||||
bool south, other; // southern corner and east/west corner
|
||||
uint slope = _tile_type_procs[ti->type]->get_slope_tileh_proc(ti);
|
||||
uint tileh = ti->tileh;
|
||||
|
||||
FindLandscapeHeightByTile(&ti, tile);
|
||||
tileh = ti.tileh;
|
||||
*z = ti.z;
|
||||
slope = _tile_type_procs[GetTileType(tile)]->get_slope_tileh_proc(&ti);
|
||||
if(slope==0 && slope!=tileh) tileh=15;
|
||||
south = (tileh & 2) != (slope & 2);
|
||||
|
||||
if(direction)
|
||||
other = (tileh & 4) != (slope & 4);
|
||||
else
|
||||
other = (tileh & 1) != (slope & 1);
|
||||
return south || other;
|
||||
|
||||
// Flatter slope -> higher base height
|
||||
if (slope < tileh) *z += TILE_HEIGHT;
|
||||
return slope;
|
||||
}
|
||||
|
||||
|
||||
static bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here)
|
||||
{
|
||||
uint z;
|
||||
Slope slope = GetFoundationSlope(TILE_ADDXY(tile, 0, -1), &z);
|
||||
|
||||
return
|
||||
(z_here + (slope_here & SLOPE_N ? TILE_HEIGHT : 0) > z + (slope & SLOPE_E ? TILE_HEIGHT : 0)) ||
|
||||
(z_here + (slope_here & SLOPE_W ? TILE_HEIGHT : 0) > z + (slope & SLOPE_S ? TILE_HEIGHT : 0));
|
||||
}
|
||||
|
||||
|
||||
static bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here)
|
||||
{
|
||||
uint z;
|
||||
Slope slope = GetFoundationSlope(TILE_ADDXY(tile, -1, 0), &z);
|
||||
|
||||
return
|
||||
(z_here + (slope_here & SLOPE_N ? TILE_HEIGHT : 0) > z + (slope & SLOPE_W ? TILE_HEIGHT : 0)) ||
|
||||
(z_here + (slope_here & SLOPE_E ? TILE_HEIGHT : 0) > z + (slope & SLOPE_S ? TILE_HEIGHT : 0));
|
||||
}
|
||||
|
||||
|
||||
void DrawFoundation(TileInfo *ti, uint f)
|
||||
{
|
||||
uint32 sprite_base = SPR_SLOPES_BASE-14;
|
||||
Slope slope;
|
||||
uint z;
|
||||
|
||||
slope = GetFoundationSlope(ti->tile, &z);
|
||||
if (!HasFoundationNW(ti->tile, slope, z)) sprite_base += 22;
|
||||
if (!HasFoundationNE(ti->tile, slope, z)) sprite_base += 44;
|
||||
TileInfo ti2;
|
||||
FindLandscapeHeight(&ti2, ti->x, ti->y-1);
|
||||
if(hasFoundation( &ti2, true )) sprite_base += 22; // foundation in NW direction
|
||||
FindLandscapeHeight(&ti2, ti->x-1, ti->y);
|
||||
if(hasFoundation( &ti2, false )) sprite_base += 22*2; // foundation in NE direction
|
||||
|
||||
if (f < 15) {
|
||||
// leveled foundation
|
||||
if (sprite_base < SPR_SLOPES_BASE) sprite_base = SPR_FOUNDATION_BASE + 1; // use original slope sprites
|
||||
if( sprite_base < SPR_SLOPES_BASE ) sprite_base = 990; // use original slope sprites
|
||||
|
||||
AddSortableSpriteToDraw(f - 1 + sprite_base, ti->x, ti->y, 16, 16, 7, ti->z);
|
||||
AddSortableSpriteToDraw(f-1 + sprite_base, ti->x, ti->y, 16, 16, 7, ti->z);
|
||||
ti->z += 8;
|
||||
ti->tileh = 0;
|
||||
OffsetGroundSprite(31, 1);
|
||||
@@ -247,7 +275,7 @@ void DrawFoundation(TileInfo *ti, uint f)
|
||||
sprite_base += 14;
|
||||
|
||||
AddSortableSpriteToDraw(
|
||||
HASBIT((1<<1) | (1<<2) | (1<<4) | (1<<8), ti->tileh) ? sprite_base + (f - 15) : SPR_FOUNDATION_BASE + ti->tileh,
|
||||
HASBIT( (1<<1) | (1<<2) | (1<<4) | (1<<8), ti->tileh) ? sprite_base + (f - 15) : ti->tileh + 0x3DE - 1,
|
||||
ti->x, ti->y, 1, 1, 1, ti->z
|
||||
);
|
||||
|
||||
@@ -256,7 +284,7 @@ void DrawFoundation(TileInfo *ti, uint f)
|
||||
}
|
||||
}
|
||||
|
||||
void DoClearSquare(TileIndex tile)
|
||||
void DoClearSquare(uint tile)
|
||||
{
|
||||
ModifyTile(tile,
|
||||
MP_SETTYPE(MP_CLEAR) |
|
||||
@@ -266,30 +294,30 @@ void DoClearSquare(TileIndex tile)
|
||||
);
|
||||
}
|
||||
|
||||
uint32 GetTileTrackStatus(TileIndex tile, TransportType mode)
|
||||
uint32 GetTileTrackStatus(uint tile, TransportType mode)
|
||||
{
|
||||
return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode);
|
||||
return _tile_type_procs[GET_TILETYPE(tile)]->get_tile_track_status_proc(tile, mode);
|
||||
}
|
||||
|
||||
void ChangeTileOwner(TileIndex tile, byte old_player, byte new_player)
|
||||
void ChangeTileOwner(uint tile, byte old_player, byte new_player)
|
||||
{
|
||||
_tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_player, new_player);
|
||||
_tile_type_procs[GET_TILETYPE(tile)]->change_tile_owner_proc(tile, old_player, new_player);
|
||||
}
|
||||
|
||||
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac)
|
||||
void GetAcceptedCargo(uint tile, AcceptedCargo ac)
|
||||
{
|
||||
memset(ac, 0, sizeof(AcceptedCargo));
|
||||
_tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac);
|
||||
_tile_type_procs[GET_TILETYPE(tile)]->get_accepted_cargo_proc(tile, ac);
|
||||
}
|
||||
|
||||
void AnimateTile(TileIndex tile)
|
||||
void AnimateTile(uint tile)
|
||||
{
|
||||
_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile);
|
||||
_tile_type_procs[GET_TILETYPE(tile)]->animate_tile_proc(tile);
|
||||
}
|
||||
|
||||
void ClickTile(TileIndex tile)
|
||||
void ClickTile(uint tile)
|
||||
{
|
||||
_tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
|
||||
_tile_type_procs[GET_TILETYPE(tile)]->click_tile_proc(tile);
|
||||
}
|
||||
|
||||
void DrawTile(TileInfo *ti)
|
||||
@@ -297,117 +325,109 @@ void DrawTile(TileInfo *ti)
|
||||
_tile_type_procs[ti->type]->draw_tile_proc(ti);
|
||||
}
|
||||
|
||||
void GetTileDesc(TileIndex tile, TileDesc *td)
|
||||
void GetTileDesc(uint tile, TileDesc *td)
|
||||
{
|
||||
_tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td);
|
||||
_tile_type_procs[GET_TILETYPE(tile)]->get_tile_desc_proc(tile, td);
|
||||
}
|
||||
|
||||
/** Clear a piece of landscape
|
||||
* @param x,y coordinates of clearance
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
/* Clear a piece of landscape
|
||||
* p1 = 0,
|
||||
* p2 = 0
|
||||
*/
|
||||
|
||||
int32 CmdLandscapeClear(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
TileIndex tile = TileVirtXY(x, y);
|
||||
|
||||
uint tile;
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
|
||||
tile = TILE_FROM_XY(x,y);
|
||||
return _tile_type_procs[GET_TILETYPE(tile)]->clear_tile_proc(tile, flags);
|
||||
}
|
||||
|
||||
/** Clear a big piece of landscape
|
||||
* @param x,y end coordinates of area dragging
|
||||
* @param p1 start tile of area dragging
|
||||
* @param p2 unused
|
||||
*/
|
||||
// p1 = end tile
|
||||
int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
int32 cost, ret, money;
|
||||
int32 cost,ret, money;
|
||||
int sx,sy;
|
||||
int x,y;
|
||||
bool success = false;
|
||||
|
||||
if (p1 >= MapSize()) return CMD_ERROR;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
// make sure sx,sy are smaller than ex,ey
|
||||
sx = TileX(p1) * 16;
|
||||
sy = TileY(p1) * 16;
|
||||
sx = GET_TILE_X(p1)*16;
|
||||
sy = GET_TILE_Y(p1)*16;
|
||||
if (ex < sx) intswap(ex, sx);
|
||||
if (ey < sy) intswap(ey, sy);
|
||||
|
||||
money = GetAvailableMoneyForCommand();
|
||||
cost = 0;
|
||||
|
||||
for (x = sx; x <= ex; x += 16) {
|
||||
for (y = sy; y <= ey; y += 16) {
|
||||
ret = DoCommandByTile(TileVirtXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
if (CmdFailed(ret)) continue;
|
||||
for(x=sx; x<=ex; x+=16) {
|
||||
for(y=sy; y<=ey; y+=16) {
|
||||
ret = DoCommandByTile(TILE_FROM_XY(x,y), 0, 0, flags &~DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
if (ret == CMD_ERROR) continue;
|
||||
cost += ret;
|
||||
success = true;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (ret > 0 && (money -= ret) < 0) {
|
||||
if ( ret>0 && (money -= ret) < 0) {
|
||||
_additional_cash_required = ret;
|
||||
return cost - ret;
|
||||
}
|
||||
DoCommandByTile(TileVirtXY(x, y), 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||
DoCommandByTile(TILE_FROM_XY(x,y), 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||
|
||||
// draw explosion animation...
|
||||
if ((x == sx || x == ex) && (y == sy || y == ey)) {
|
||||
if ((x==sx || x==ex) && (y==sy || y==ey)) {
|
||||
// big explosion in each corner, or small explosion for single tiles
|
||||
CreateEffectVehicleAbove(x + 8, y + 8, 2,
|
||||
sy == ey && sx == ex ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE
|
||||
);
|
||||
CreateEffectVehicleAbove(x + 8,y + 8, 2, sy==ey && sx==ex ? EV_DEMOLISH : EV_CRASHED_SMOKE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (success) ? cost : CMD_ERROR;
|
||||
if (!success)
|
||||
cost = CMD_ERROR;
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
||||
/* utility function used to modify a tile */
|
||||
void CDECL ModifyTile(TileIndex tile, uint flags, ...)
|
||||
void CDECL ModifyTile(uint tile, uint flags, ...)
|
||||
{
|
||||
va_list va;
|
||||
int i;
|
||||
|
||||
va_start(va, flags);
|
||||
|
||||
if ((i = GB(flags, 8, 4)) != 0) {
|
||||
SetTileType(tile, i - 1);
|
||||
if ((i = (flags >> 8) & 0xF) != 0) {
|
||||
_map_type_and_height[tile] = (_map_type_and_height[tile]&~0xF0)|((i-1) << 4);
|
||||
}
|
||||
|
||||
if (flags & (MP_MAP2_CLEAR | MP_MAP2)) {
|
||||
int x = 0;
|
||||
if (flags & MP_MAP2) x = va_arg(va, int);
|
||||
_m[tile].m2 = x;
|
||||
_map2[tile] = x;
|
||||
}
|
||||
|
||||
if (flags & (MP_MAP3LO_CLEAR | MP_MAP3LO)) {
|
||||
int x = 0;
|
||||
if (flags & MP_MAP3LO) x = va_arg(va, int);
|
||||
_m[tile].m3 = x;
|
||||
_map3_lo[tile] = x;
|
||||
}
|
||||
|
||||
if (flags & (MP_MAP3HI_CLEAR | MP_MAP3HI)) {
|
||||
int x = 0;
|
||||
if (flags & MP_MAP3HI) x = va_arg(va, int);
|
||||
_m[tile].m4 = x;
|
||||
_map3_hi[tile] = x;
|
||||
}
|
||||
|
||||
if (flags & (MP_MAPOWNER|MP_MAPOWNER_CURRENT)) {
|
||||
PlayerID x = _current_player;
|
||||
byte x = _current_player;
|
||||
if (flags & MP_MAPOWNER) x = va_arg(va, int);
|
||||
_m[tile].m1 = x;
|
||||
_map_owner[tile] = x;
|
||||
}
|
||||
|
||||
if (flags & MP_MAP5) {
|
||||
_m[tile].m5 = va_arg(va, int);
|
||||
_map5[tile] = va_arg(va, int);
|
||||
}
|
||||
|
||||
va_end(va);
|
||||
@@ -416,72 +436,82 @@ void CDECL ModifyTile(TileIndex tile, uint flags, ...)
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
void SetMapExtraBits(uint tile, byte bits)
|
||||
{
|
||||
_map_extra_bits[tile >> 2] &= ~(3 << ((tile&3)*2));
|
||||
_map_extra_bits[tile >> 2] |= (bits&3) << ((tile&3)*2);
|
||||
}
|
||||
|
||||
uint GetMapExtraBits(uint tile)
|
||||
{
|
||||
return (_map_extra_bits[tile >> 2] >> (tile&3)*2)&3;
|
||||
}
|
||||
|
||||
#define TILELOOP_BITS 4
|
||||
#define TILELOOP_SIZE (1 << TILELOOP_BITS)
|
||||
#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE-1) + ((TILELOOP_SIZE-1) << MapLogX()))
|
||||
#define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS)
|
||||
#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE-1) + ((TILELOOP_SIZE-1) << TILE_X_BITS))
|
||||
#define TILELOOP_CHKMASK (((1 << (TILE_X_BITS - TILELOOP_BITS))-1) << TILELOOP_BITS)
|
||||
|
||||
void RunTileLoop(void)
|
||||
void RunTileLoop()
|
||||
{
|
||||
TileIndex tile;
|
||||
uint tile;
|
||||
uint count;
|
||||
|
||||
tile = _cur_tileloop_tile;
|
||||
|
||||
assert( (tile & ~TILELOOP_ASSERTMASK) == 0);
|
||||
count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE);
|
||||
count = (TILES_X/TILELOOP_SIZE) * (TILES_Y/TILELOOP_SIZE);
|
||||
do {
|
||||
_tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile);
|
||||
_tile_type_procs[GET_TILETYPE(tile)]->tile_loop_proc(tile);
|
||||
|
||||
if (TileX(tile) < MapSizeX() - TILELOOP_SIZE) {
|
||||
if ( GET_TILE_X(tile) < TILES_X - TILELOOP_SIZE) {
|
||||
tile += TILELOOP_SIZE; /* no overflow */
|
||||
} else {
|
||||
tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE - 1) + TileDiffXY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */
|
||||
tile = TILE_MASK(tile - TILELOOP_SIZE * (TILES_X/TILELOOP_SIZE-1) + TILE_XY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */
|
||||
}
|
||||
} while (--count);
|
||||
assert( (tile & ~TILELOOP_ASSERTMASK) == 0);
|
||||
|
||||
tile += 9;
|
||||
if (tile & TILELOOP_CHKMASK)
|
||||
tile = (tile + MapSizeX()) & TILELOOP_ASSERTMASK;
|
||||
tile = (tile + TILES_X) & TILELOOP_ASSERTMASK;
|
||||
_cur_tileloop_tile = tile;
|
||||
}
|
||||
|
||||
void InitializeLandscape(void)
|
||||
void InitializeLandscape()
|
||||
{
|
||||
uint map_size;
|
||||
uint i;
|
||||
uint map_size = MapSize();
|
||||
int i;
|
||||
|
||||
memset(_map_owner, OWNER_NONE, map_size);
|
||||
memset(_map2, 0, map_size);
|
||||
memset(_map3_lo, 0, map_size);
|
||||
memset(_map3_hi, 0, map_size);
|
||||
memset(_map_extra_bits, 0, map_size / 4);
|
||||
memset(_map_type_and_height, MP_WATER << 4, map_size);
|
||||
|
||||
map_size = MapSize();
|
||||
for (i = 0; i < map_size; i++) {
|
||||
_m[i].type_height = MP_CLEAR << 4;
|
||||
_m[i].m1 = OWNER_NONE;
|
||||
_m[i].m2 = 0;
|
||||
_m[i].m3 = 0;
|
||||
_m[i].m4 = 0;
|
||||
_m[i].m5 = 3;
|
||||
_m[i].extra = 0;
|
||||
}
|
||||
for(i=0; i!=TILES_Y-1; i++)
|
||||
memset(_map_type_and_height + i*TILES_X, 0, TILES_X-1);
|
||||
|
||||
// create void tiles at the border
|
||||
for (i = 0; i < MapMaxY(); ++i)
|
||||
SetTileType(i * MapSizeX() + MapMaxX(), MP_VOID);
|
||||
for (i = 0; i < MapSizeX(); ++i)
|
||||
SetTileType(MapSizeX() * MapMaxY() + i, MP_VOID);
|
||||
memset(_map5, 3, map_size);
|
||||
}
|
||||
|
||||
void ConvertGroundTilesIntoWaterTiles(void)
|
||||
void ConvertGroundTilesIntoWaterTiles()
|
||||
{
|
||||
TileIndex tile = 0;
|
||||
uint h;
|
||||
uint tile = 0;
|
||||
int h;
|
||||
|
||||
for (tile = 0; tile < MapSize(); ++tile) {
|
||||
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
|
||||
SetTileType(tile, MP_WATER);
|
||||
_m[tile].m5 = 0;
|
||||
SetTileOwner(tile, OWNER_WATER);
|
||||
while(true) {
|
||||
if (IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
|
||||
_map_type_and_height[tile] = MP_WATER << 4;
|
||||
_map5[tile] = 0;
|
||||
_map_owner[tile] = OWNER_WATER;
|
||||
}
|
||||
tile++;
|
||||
if (GET_TILE_X(tile) == TILE_X_MAX) {
|
||||
tile += TILE_XY(-TILE_X_MAX, 1);
|
||||
if (GET_TILE_Y(tile) == TILE_Y_MAX)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,192 +522,182 @@ static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 };
|
||||
static void GenerateTerrain(int type, int flag)
|
||||
{
|
||||
uint32 r;
|
||||
uint x;
|
||||
uint y;
|
||||
uint w;
|
||||
uint h;
|
||||
const Sprite* template;
|
||||
const byte *p;
|
||||
Tile* tile;
|
||||
int x,y;
|
||||
int w,h;
|
||||
byte *p,*tile;
|
||||
byte direction;
|
||||
|
||||
r = Random();
|
||||
template = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845);
|
||||
p = GetSpritePtr((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845);
|
||||
|
||||
x = r & MapMaxX();
|
||||
y = (r >> MapLogX()) & MapMaxY();
|
||||
x = r & TILE_X_MAX;
|
||||
y = (r >> TILE_X_BITS) & TILE_Y_MAX;
|
||||
|
||||
|
||||
if (x < 2 || y < 2)
|
||||
return;
|
||||
|
||||
direction = GB(r, 22, 2);
|
||||
if (direction & 1) {
|
||||
w = template->height;
|
||||
h = template->width;
|
||||
} else {
|
||||
w = template->width;
|
||||
h = template->height;
|
||||
}
|
||||
p = template->data;
|
||||
direction = (byte)(r >> 22) & 3;
|
||||
w = p[2];
|
||||
h = p[1];
|
||||
if (direction & 1) { w = p[1]; h = p[2]; }
|
||||
p += 8;
|
||||
|
||||
if (flag & 4) {
|
||||
uint xw = x * MapSizeY();
|
||||
uint yw = y * MapSizeX();
|
||||
uint bias = (MapSizeX() + MapSizeY()) * 16;
|
||||
|
||||
switch (flag & 3) {
|
||||
case 0:
|
||||
if (xw + yw > MapSize() - bias) return;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (yw < xw + bias) return;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (xw + yw < MapSize() + bias) return;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (xw < yw + bias) return;
|
||||
break;
|
||||
if (!(flag & 2)) {
|
||||
if (!(flag & 1)) {
|
||||
if (x + y > 190)
|
||||
return;
|
||||
} else {
|
||||
if (y < 30 + x)
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!(flag & 1)) {
|
||||
if (x + y < 256)
|
||||
return;
|
||||
} else {
|
||||
if (x < 30 + y)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x + w >= MapMaxX() - 1)
|
||||
if (x + w >= TILE_X_MAX-1)
|
||||
return;
|
||||
|
||||
if (y + h >= MapMaxY() - 1)
|
||||
if (y + h >= TILE_Y_MAX-1)
|
||||
return;
|
||||
|
||||
tile = &_m[TileXY(x, y)];
|
||||
tile = &_map_type_and_height[TILE_XY(x,y)];
|
||||
|
||||
switch (direction) {
|
||||
case 0:
|
||||
if (direction == 0) {
|
||||
do {
|
||||
int w_cur = w;
|
||||
byte *tile_cur = tile;
|
||||
do {
|
||||
Tile* tile_cur = tile;
|
||||
uint w_cur;
|
||||
|
||||
for (w_cur = w; w_cur != 0; --w_cur) {
|
||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
||||
p++;
|
||||
tile_cur++;
|
||||
}
|
||||
tile += TileDiffXY(0, 1);
|
||||
} while (--h != 0);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (*p >= *tile_cur) *tile_cur = *p;
|
||||
p++;
|
||||
tile_cur++;
|
||||
} while (--w_cur != 0);
|
||||
tile += TILE_XY(0,1);
|
||||
} while (--h != 0);
|
||||
} else if (direction == 1) {
|
||||
do {
|
||||
int h_cur = h;
|
||||
byte *tile_cur = tile;
|
||||
do {
|
||||
Tile* tile_cur = tile;
|
||||
uint h_cur;
|
||||
|
||||
for (h_cur = h; h_cur != 0; --h_cur) {
|
||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
||||
p++;
|
||||
tile_cur += TileDiffXY(0, 1);
|
||||
}
|
||||
tile++;
|
||||
} while (--w != 0);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
tile += TileDiffXY(w - 1, 0);
|
||||
if (*p >= *tile_cur) *tile_cur = *p;
|
||||
p++;
|
||||
tile_cur+=TILE_XY(0,1);
|
||||
} while (--h_cur != 0);
|
||||
tile++;
|
||||
} while (--w != 0);
|
||||
} else if (direction == 2) {
|
||||
tile += w - 1;
|
||||
do {
|
||||
int w_cur = w;
|
||||
byte *tile_cur = tile;
|
||||
do {
|
||||
Tile* tile_cur = tile;
|
||||
uint w_cur;
|
||||
|
||||
for (w_cur = w; w_cur != 0; --w_cur) {
|
||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
||||
p++;
|
||||
tile_cur--;
|
||||
}
|
||||
tile += TileDiffXY(0, 1);
|
||||
} while (--h != 0);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
tile += TileDiffXY(0, h - 1);
|
||||
if (*p >= *tile_cur) *tile_cur = *p;
|
||||
p++;
|
||||
tile_cur--;
|
||||
} while (--w_cur != 0);
|
||||
tile += TILE_XY(0,1);
|
||||
} while (--h != 0);
|
||||
} else {
|
||||
tile += (h - 1) * TILE_XY(0,1);
|
||||
do {
|
||||
int h_cur = h;
|
||||
byte *tile_cur = tile;
|
||||
do {
|
||||
Tile* tile_cur = tile;
|
||||
uint h_cur;
|
||||
|
||||
for (h_cur = h; h_cur != 0; --h_cur) {
|
||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
||||
p++;
|
||||
tile_cur -= TileDiffXY(0, 1);
|
||||
}
|
||||
tile++;
|
||||
} while (--w != 0);
|
||||
break;
|
||||
if (*p >= *tile_cur) *tile_cur = *p;
|
||||
p++;
|
||||
tile_cur-=TILE_XY(0,1);
|
||||
} while (--h_cur != 0);
|
||||
tile++;
|
||||
} while (--w != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "table/genland.h"
|
||||
|
||||
static void CreateDesertOrRainForest(void)
|
||||
static void CreateDesertOrRainForest()
|
||||
{
|
||||
TileIndex tile;
|
||||
const TileIndexDiffC *data;
|
||||
uint i;
|
||||
uint tile;
|
||||
const TileIndexDiff *data;
|
||||
byte mt;
|
||||
int i;
|
||||
|
||||
for (tile = 0; tile != MapSize(); ++tile) {
|
||||
for (data = _make_desert_or_rainforest_data;
|
||||
data != endof(_make_desert_or_rainforest_data); ++data) {
|
||||
TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data));
|
||||
if (TileHeight(t) >= 4 || IsTileType(t, MP_WATER)) break;
|
||||
}
|
||||
if (data == endof(_make_desert_or_rainforest_data))
|
||||
SetMapExtraBits(tile, 1);
|
||||
}
|
||||
tile = 0;
|
||||
do {
|
||||
data = _make_desert_or_rainforest_data;
|
||||
do {
|
||||
if ((i = *data++) == MDORD_LAST) {
|
||||
SetMapExtraBits(tile, 1);
|
||||
break;
|
||||
}
|
||||
mt = _map_type_and_height[TILE_MASK(tile + i)];
|
||||
} while ((mt & 0xC) == 0 && (mt >> 4) != MP_WATER);
|
||||
} while (++tile != TILES_X*TILES_Y);
|
||||
|
||||
for (i = 0; i != 256; i++)
|
||||
for(i=0; i!=256; i++)
|
||||
RunTileLoop();
|
||||
|
||||
for (tile = 0; tile != MapSize(); ++tile) {
|
||||
for (data = _make_desert_or_rainforest_data;
|
||||
data != endof(_make_desert_or_rainforest_data); ++data) {
|
||||
TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data));
|
||||
if (IsTileType(t, MP_CLEAR) && (_m[t].m5 & 0x1c) == 0x14) break;
|
||||
}
|
||||
if (data == endof(_make_desert_or_rainforest_data))
|
||||
SetMapExtraBits(tile, 2);
|
||||
}
|
||||
tile = 0;
|
||||
do {
|
||||
data = _make_desert_or_rainforest_data;
|
||||
do {
|
||||
if ((i = *data++) == MDORD_LAST) {
|
||||
SetMapExtraBits(tile, 2);
|
||||
break;
|
||||
}
|
||||
} while ( !IS_TILETYPE(TILE_MASK(tile+i), MP_CLEAR) || (_map5[TILE_MASK(tile + i)]&0x1C) != 0x14);
|
||||
} while (++tile != TILES_X*TILES_Y);
|
||||
}
|
||||
|
||||
void GenerateLandscape(void)
|
||||
void GenerateLandscape()
|
||||
{
|
||||
uint i;
|
||||
uint flag;
|
||||
int i,flag;
|
||||
uint32 r;
|
||||
|
||||
if (_opt.landscape == LT_HILLY) {
|
||||
for (i = ScaleByMapSize((Random() & 0x7F) + 950); i != 0; --i)
|
||||
i = ((Random() & 0x7F) + 950) * LANDSCAPE_SIZE_FACTOR;
|
||||
do {
|
||||
GenerateTerrain(2, 0);
|
||||
} while (--i);
|
||||
|
||||
r = Random();
|
||||
flag = GB(r, 0, 2) | 4;
|
||||
for (i = ScaleByMapSize(GB(r, 16, 7) + 450); i != 0; --i)
|
||||
flag = (r & 3) | 4;
|
||||
i = (((r >> 16) & 0x7F) + 450) * LANDSCAPE_SIZE_FACTOR;
|
||||
do {
|
||||
GenerateTerrain(4, flag);
|
||||
} while (--i);
|
||||
} else if (_opt.landscape == LT_DESERT) {
|
||||
for (i = ScaleByMapSize((Random()&0x7F) + 170); i != 0; --i)
|
||||
i = ((Random()&0x7F) + 170) * LANDSCAPE_SIZE_FACTOR;
|
||||
do {
|
||||
GenerateTerrain(0, 0);
|
||||
} while (--i);
|
||||
|
||||
r = Random();
|
||||
flag = GB(r, 0, 2) | 4;
|
||||
for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i)
|
||||
flag = (r & 3) | 4;
|
||||
i = (((r >> 16) & 0xFF) + 1700) * LANDSCAPE_SIZE_FACTOR;
|
||||
do {
|
||||
GenerateTerrain(0, flag);
|
||||
} while (--i);
|
||||
|
||||
flag ^= 2;
|
||||
|
||||
for (i = ScaleByMapSize((Random() & 0x7F) + 410); i != 0; --i)
|
||||
i = ((Random() & 0x7F) + 410) * LANDSCAPE_SIZE_FACTOR;
|
||||
do {
|
||||
GenerateTerrain(3, flag);
|
||||
} while (--i);
|
||||
} else {
|
||||
i = ScaleByMapSize((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100);
|
||||
for (; i != 0; --i)
|
||||
i = ((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes)*256 + 100) * LANDSCAPE_SIZE_FACTOR;
|
||||
do {
|
||||
GenerateTerrain(_opt.diff.terrain_type, 0);
|
||||
} while (--i);
|
||||
}
|
||||
|
||||
ConvertGroundTilesIntoWaterTiles();
|
||||
@@ -686,15 +706,15 @@ void GenerateLandscape(void)
|
||||
CreateDesertOrRainForest();
|
||||
}
|
||||
|
||||
void OnTick_Town(void);
|
||||
void OnTick_Trees(void);
|
||||
void OnTick_Station(void);
|
||||
void OnTick_Industry(void);
|
||||
void OnTick_Town();
|
||||
void OnTick_Trees();
|
||||
void OnTick_Station();
|
||||
void OnTick_Industry();
|
||||
|
||||
void OnTick_Players(void);
|
||||
void OnTick_Train(void);
|
||||
void OnTick_Players();
|
||||
void OnTick_Train();
|
||||
|
||||
void CallLandscapeTick(void)
|
||||
void CallLandscapeTick()
|
||||
{
|
||||
OnTick_Town();
|
||||
OnTick_Trees();
|
||||
@@ -710,13 +730,32 @@ TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng)
|
||||
int rn = rng;
|
||||
uint32 r = Random();
|
||||
|
||||
return TILE_MASK(TileXY(
|
||||
TileX(a) + (GB(r, 0, 8) * rn * 2 >> 8) - rn,
|
||||
TileY(a) + (GB(r, 8, 8) * rn * 2 >> 8) - rn
|
||||
));
|
||||
return TILE_XY(
|
||||
GET_TILE_X(a) + ((byte)r * rn * 2 >> 8) - rn,
|
||||
GET_TILE_Y(a) + ((byte)(r>>8) * rn * 2 >> 8) - rn
|
||||
);
|
||||
}
|
||||
|
||||
bool IsValidTile(TileIndex tile)
|
||||
// This function checks if we add addx/addy to tile, if we
|
||||
// do wrap around the edges. For example, tile = (10,2) and
|
||||
// addx = +3 and addy = -4. This function will now return
|
||||
// TILE_WRAPPED, because the y is wrapped. This is needed in
|
||||
// for example, farmland. When the tile is not wrapped,
|
||||
// the result will be tile + TILE_XY(addx, addy)
|
||||
uint TileAddWrap(TileIndex tile, int addx, int addy)
|
||||
{
|
||||
return (tile < MapSizeX() * MapMaxY() && TileX(tile) != MapMaxX());
|
||||
int x, y;
|
||||
x = GET_TILE_X(tile) + addx;
|
||||
y = GET_TILE_Y(tile) + addy;
|
||||
|
||||
// Are we about to wrap?
|
||||
if (x > 0 && x < TILE_X_MAX && y > 0 && y < TILE_Y_MAX)
|
||||
return tile + TILE_XY(addx, addy);
|
||||
|
||||
return TILE_WRAPPED;
|
||||
}
|
||||
|
||||
bool IsValidTile(uint tile)
|
||||
{
|
||||
return (tile < TILES_X * TILE_Y_MAX && GET_TILE_X(tile) != TILE_X_MAX);
|
||||
}
|
||||
|
||||
+2539
-2576
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2538
-2578
File diff suppressed because it is too large
Load Diff
+2539
-2634
File diff suppressed because it is too large
Load Diff
+2510
-2578
File diff suppressed because it is too large
Load Diff
+2539
-2577
File diff suppressed because it is too large
Load Diff
+2539
-2576
File diff suppressed because it is too large
Load Diff
-2801
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user