Changeset - r14126:f23988064e74
[Not reviewed]
master
0 16 0
rubidium - 14 years ago 2010-01-01 18:45:40
rubidium@openttd.org
(svn r18683) -Fix: it's not an other
16 files changed with 19 insertions and 19 deletions:
0 comments (0 inline, 0 general)
changelog.txt
Show inline comments
 
@@ -2336,49 +2336,49 @@ 0.3.5 (2004-12-24)
 
- Feature: [Big Endian computers, which are mac and MorphOS]: are able to load savegames by TTD(Patch)
 
- Add: 'l' openes the landscaping toolbar globally
 
- Add: Make the town sometimes build streets on slopes
 
- Add: Manpage
 
- Add: New checkpoint grahpics
 
- Add: SHIFT+DEL now deletes all non-vital windows (only status bar and main bar remain)
 
- Add: Windows now shows revision, release information in title bar
 
- Add: Windows snap at each other
 
- Add: Spanish, Catalan and Icelandic
 
- Change: [OSX] Moved data and lang folders inside OpenTTD. This got rid of the package system too, making installing/updating easier
 
- Fix: [OSX] Music is now on by default again
 
- Fix: [OSX] Made error opens the console
 
- Fix: [SDL] Added a confirmation dialog when quitting the game
 
- Fix: A train can leave and enter the same depot at the same time, then the trai simply got stuck
 
- Fix: Crash when making png screenshot with odd resolution
 
- Fix: Directories in *nix are now sorted alphabetically in ascending order
 
- Fix: Do not consider a road station as street when growing the town
 
- Fix: Engines from other climates do not appear any more when never_expire_vehicles is enabled
 
- Fix: Game options (like drive side) are not taken from the scenario when using 'new game' command
 
- Fix: Order checker now correctly detects station with invalid facilities
 
- Fix: Polished GUI in a lot of ways
 
- Fix: Saving or loading a map doesnt pauses the game anymore
 
- Fix: Some bridge part is not displayed transparent in transparent mode
 
- Fix: Starting with -r option allows all resolutions
 
- Fix: The pathfinder no longer sees rail with an other owner as a possible route
 
- Fix: The pathfinder no longer sees rail with another owner as a possible route
 
- Fix: Unable to select other screenshot format in Game Option
 
- Fix: Unwanted town renaming
 
- Fix: Vehicles slow down under bridge if the track is on a foundation
 
- Fix: You can no longer change name of waypoints whom are owned by somebody else
 
- Fix: Shares are now also sold when a company goes bankrupt [SF#1090313]
 
- Fix: It is no longer possible to crash trains of other companies by building a depot close to a station. (even more: trains do no longer enter tiles that do not belong to his owner) [SF#1087701]
 
- Fix: Crashed trains are not reported to have too few orders any more [SF#1087403]
 
- Fix: Backup-order-list was not closed with an OT_NOTHING, [SF#1086375]
 
- Fix: Docks now have a button to display the catchment area [SF#1085255]
 
- Fix: Invisible trains. Weird macros and MSVC optimizing do not always mix [SF#1070274]
 
- Fix: Number of passangers and mail in exclusive test offer window is swapped [SF#1068269]
 
- Fix: Pause key pauses the game [SF#1066504]
 
- Fix: Resetting file name after deleting a file [SF#1066121]
 
- Fix: Code error in win32.c Thanks Shai [SF#1066114]
 
- Fix: Windows can be placed behind toolbar [SF#1065247]
 
- Fix: Editor Map-Menu wrong String [SF#1064742]
 
- Fix: Always report a bus/lorry station as unpassable [SF#1058809]
 
- Fix: Refit train window stays open [SF#1053397]
 
- Fix: Incorrect Tooltip in Road Vehicle List [SF#1050993]
 
- Fix: Monorail and Maglev sounds are swapped [SF#1048596]
 
- Fix: Flooded wagons in depots do not keep constantly exploding any more [SF#1040119]
 
- Fix: Bug about lowering tracks built on slopes [SF#1035303]
 
- Fix: 'Allow goto depot' turned off, no checkpoints in orders [SF#1035066]
 
- Fix: Place sign and blue message box [SF#1034318]
docs/32bpp.txt
Show inline comments
 
@@ -6,31 +6,31 @@ posibility to override the graphics with
 
replacement of grf or newgrf, but simply an addition. If you want to use 32bpp
 
graphics of a newgrf, you do need the newgrf itself too (with 8bpp graphics).
 

	
 

	
 
The Format
 
----------
 

	
 
32bpp images are stored in PNG. They should go in:
 
  data/sprites/<grfname>/<SpriteID>.png
 

	
 
For example, a grfname would be 'openttd' (without .grf, lowercase), and the
 
SpriteID 3, to override the 3rd sprite in openttd.grf with a 32bpp version.
 

	
 
The format of this PNG can be almost anything, but we advise to use RGBA
 
format. Alpha-channel is fully supported.
 

	
 
As the core of OpenTTD is 8bpp, and because you of course want company colours
 
in your images, you will need to add a mask for every sprite that needs colour
 
remapping. The name is simular as above, only you have to put a 'm' behind the
 
SpriteID. This image should be a 8bpp palette image, where the palette is the
 
OpenTTD palette. Upon load of the PNG, the mask is loaded too, and overrides
 
the RGB (not the Alpha) of the original PNG image, and replacing it with a
 
8bpp color remapped and converted to 32bpp.
 

	
 
An other thing that OpenTTD needs in your png, is 2 tEXt chunks: x_offs and
 
Another thing that OpenTTD needs in your png, is 2 tEXt chunks: x_offs and
 
y_offs. This to define the x- and y-offset, of course. Use the tool we supply
 
to add this information. Sadly enough most graphical editors trashes those
 
chunks upon save, so you have to readd it every time you save your image.
 

	
 
Your images should be the same as the grf, in size.
 

	
src/ai/api/ai_abstractlist.hpp
Show inline comments
 
@@ -120,49 +120,49 @@ public:
 
	 * @return the value that belongs to this item.
 
	 */
 
	int32 GetValue(int32 item);
 

	
 
	/**
 
	 * Set a value of an item directly.
 
	 * @param item the item to set the value for.
 
	 * @param value the value to give to the item
 
	 * @return true if we could set the item to value, false otherwise.
 
	 * @note Changing values of items while looping through a list might cause
 
	 *  entries to be skipped. Be very careful with such operations.
 
	 */
 
	bool SetValue(int32 item, int32 value);
 

	
 
	/**
 
	 * Sort this list by the given sorter and direction.
 
	 * @param sorter    the type of sorter to use
 
	 * @param ascending if true, lowest value is on top, else at bottom.
 
	 * @note the current item stays at the same place.
 
	 * @see SORT_ASCENDING SORT_DESCENDING
 
	 */
 
	void Sort(SorterType sorter, bool ascending);
 

	
 
	/**
 
	 * Add one list to an other one.
 
	 * Add one list to another one.
 
	 * @param list The list that will be added to the caller.
 
	 * @post The list to be added ('list') stays unmodified.
 
	 * @note All added items keep their value as it was in 'list'.
 
	 * @note If the item already exists inside the caller, the value of the
 
	 *  list that is added is set on the item.
 
	 */
 
	void AddList(AIAbstractList *list);
 

	
 
	/**
 
	 * Removes all items with a higher value than 'value'.
 
	 * @param value the value above which all items are removed.
 
	 */
 
	void RemoveAboveValue(int32 value);
 

	
 
	/**
 
	 * Removes all items with a lower value than 'value'.
 
	 * @param value the value below which all items are removed.
 
	 */
 
	void RemoveBelowValue(int32 value);
 

	
 
	/**
 
	 * Removes all items with a value above start and below end.
 
	 * @param start the lower bound of the to be removed values (exclusive).
 
	 * @param end   the upper bound of the to be removed valuens (exclusive).
src/ai/api/ai_tunnel.hpp
Show inline comments
 
@@ -15,49 +15,49 @@
 
#include "ai_object.hpp"
 
#include "ai_vehicle.hpp"
 

	
 
/**
 
 * Class that handles all tunnel related functions.
 
 */
 
class AITunnel : public AIObject {
 
public:
 
	static const char *GetClassName() { return "AITunnel"; }
 

	
 
	/**
 
	 * All tunnel related errors.
 
	 */
 
	enum ErrorMessages {
 

	
 
		/** Base for bridge related errors */
 
		ERR_TUNNEL_BASE = AIError::ERR_CAT_TUNNEL << AIError::ERR_CAT_BIT_SIZE,
 

	
 
		/** Can't build tunnels on water */
 
		ERR_TUNNEL_CANNOT_BUILD_ON_WATER,            // [STR_ERROR_CAN_T_BUILD_ON_WATER]
 

	
 
		/** The start tile must slope either North, South, West or East */
 
		ERR_TUNNEL_START_SITE_UNSUITABLE,            // [STR_ERROR_SITE_UNSUITABLE_FOR_TUNNEL]
 

	
 
		/** An other tunnel is in the way */
 
		/** Another tunnel is in the way */
 
		ERR_TUNNEL_ANOTHER_TUNNEL_IN_THE_WAY,        // [STR_ERROR_ANOTHER_TUNNEL_IN_THE_WAY]
 

	
 
		/** Unable to excavate land at the end to create the tunnel's exit */
 
		ERR_TUNNEL_END_SITE_UNSUITABLE,              // [STR_ERROR_UNABLE_TO_EXCAVATE_LAND]
 
	};
 

	
 
	/**
 
	 * Check whether the tile is an entrance to a tunnel.
 
	 * @param tile The tile to check.
 
	 * @pre AIMap::IsValidTile(tile).
 
	 * @return True if and only if the tile is the beginning or end of a tunnel.
 
	 */
 
	static bool IsTunnelTile(TileIndex tile);
 

	
 
	/**
 
	 * Get the tile that exits on the other end of a (would be) tunnel starting
 
	 *  at tile. If there is no 'simple' inclined slope at the start tile,
 
	 *  this function will return AIMap::TILE_INVALID.
 
	 * @param tile The tile that is an entrance to a tunnel or the tile where you may want to build a tunnel.
 
	 * @pre AIMap::IsValidTile(tile).
 
	 * @return The TileIndex that is the other end of the (would be) tunnel, or
 
	 *  AIMap::TILE_INVALID if no other end was found (can't build tunnel).
 
	 * @note Even if this function returns a valid tile, that is no guarantee
 
	 *  that building a tunnel will succeed. Use BuildTunnel in AITestMode to
src/debug.h
Show inline comments
 
@@ -51,47 +51,47 @@
 
#endif /* NO_DEBUG_MESSAGES */
 

	
 
void SetDebugString(const char *s);
 
const char *GetDebugString();
 

	
 
/* Used for profiling
 
 *
 
 * Usage:
 
 * TIC();
 
 *   --Do your code--
 
 * TOC("A name", 1);
 
 *
 
 * When you run the TIC() / TOC() multiple times, you can increase the '1'
 
 *  to only display average stats every N values. Some things to know:
 
 *
 
 * for (int i = 0; i < 5; i++) {
 
 *   TIC();
 
 *     --Do yuor code--
 
 *   TOC("A name", 5);
 
 * }
 
 *
 
 * Is the correct usage for multiple TIC() / TOC() calls.
 
 *
 
 * TIC() / TOC() creates it's own block, so make sure not the mangle
 
 *  it with an other block.
 
 *  it with another block.
 
 **/
 
#define TIC() {\
 
	extern uint64 ottd_rdtsc();\
 
	uint64 _xxx_ = ottd_rdtsc();\
 
	static uint64 __sum__ = 0;\
 
	static uint32 __i__ = 0;
 

	
 
#define TOC(str, count)\
 
	__sum__ += ottd_rdtsc() - _xxx_;\
 
	if (++__i__ == count) {\
 
		DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, __sum__, __sum__/(double)__i__);\
 
		__i__ = 0;\
 
		__sum__ = 0;\
 
	}\
 
}
 

	
 
void ShowInfo(const char *str);
 
void CDECL ShowInfoF(const char *str, ...) WARN_FORMAT(1, 2);
 

	
 
const char *GetLogPrefix();
 

	
 
#endif /* DEBUG_H */
src/economy.cpp
Show inline comments
 
@@ -283,63 +283,63 @@ int UpdateCompanyRatingAndValue(Company 
 

	
 
	SetWindowDirty(WC_PERFORMANCE_DETAIL, 0);
 
	return score;
 
}
 

	
 
/*  use INVALID_OWNER as new_owner to delete the company. */
 
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
 
{
 
	Town *t;
 
	CompanyID old = _current_company;
 

	
 
	assert(old_owner != new_owner);
 

	
 
	{
 
		Company *c;
 
		uint i;
 

	
 
		/* See if the old_owner had shares in other companies */
 
		_current_company = old_owner;
 
		FOR_ALL_COMPANIES(c) {
 
			for (i = 0; i < 4; i++) {
 
				if (c->share_owners[i] == old_owner) {
 
					/* Sell his shares */
 
					CommandCost res = DoCommand(0, c->index, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
 
					/* Because we are in a DoCommand, we can't just execute an other one and
 
					/* Because we are in a DoCommand, we can't just execute another one and
 
					 *  expect the money to be removed. We need to do it ourself! */
 
					SubtractMoneyFromCompany(res);
 
				}
 
			}
 
		}
 

	
 
		/* Sell all the shares that people have on this company */
 
		c = Company::Get(old_owner);
 
		for (i = 0; i < 4; i++) {
 
			_current_company = c->share_owners[i];
 
			if (_current_company != INVALID_OWNER) {
 
				/* Sell the shares */
 
				CommandCost res = DoCommand(0, old_owner, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
 
				/* Because we are in a DoCommand, we can't just execute an other one and
 
				/* Because we are in a DoCommand, we can't just execute another one and
 
				 *  expect the money to be removed. We need to do it ourself! */
 
				SubtractMoneyFromCompany(res);
 
			}
 
		}
 
	}
 

	
 
	_current_company = old_owner;
 

	
 
	/* Temporarily increase the company's money, to be sure that
 
	 * removing his/her property doesn't fail because of lack of money.
 
	 * Not too drastically though, because it could overflow */
 
	if (new_owner == INVALID_OWNER) {
 
		Company::Get(old_owner)->money = UINT64_MAX >> 2; // jackpot ;p
 
	}
 

	
 
	Subsidy *s;
 
	FOR_ALL_SUBSIDIES(s) {
 
		if (s->awarded == old_owner) {
 
			if (new_owner == INVALID_OWNER) {
 
				delete s;
 
			} else {
 
				s->awarded = new_owner;
 
			}
 
		}
src/map_func.h
Show inline comments
 
@@ -217,49 +217,49 @@ static inline uint TileY(TileIndex tile)
 
	return tile >> MapLogX();
 
}
 

	
 
/**
 
 * Return the offset between to tiles from a TileIndexDiffC struct.
 
 *
 
 * This function works like #TileDiffXY(int, int) and returns the
 
 * difference between two tiles.
 
 *
 
 * @param tidc The coordinate of the offset as TileIndexDiffC
 
 * @return The difference between two tiles.
 
 * @see TileDiffXY(int, int)
 
 */
 
static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
 
{
 
	return (tidc.y << MapLogX()) + tidc.x;
 
}
 

	
 

	
 
#ifndef _DEBUG
 
	/**
 
	 * Adds to tiles together.
 
	 *
 
	 * @param x One tile
 
	 * @param y An other tile to add
 
	 * @param y Another tile to add
 
	 * @return The resulting tile(index)
 
	 */
 
	#define TILE_ADD(x,y) ((x) + (y))
 
#else
 
	extern TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
 
		const char *exp, const char *file, int line);
 
	#define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
 
#endif
 

	
 
/**
 
 * Adds a given offset to a tile.
 
 *
 
 * @param tile The tile to add an offset on it
 
 * @param x The x offset to add to the tile
 
 * @param y The y offset to add to the tile
 
 */
 
#define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y))
 

	
 
/**
 
 * Adds an offset to a tile and check if we are still on the map.
 
 */
 
TileIndex TileAddWrap(TileIndex tile, int addx, int addy);
 

	
 
/**
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -362,49 +362,49 @@ struct NetworkChatWindow : public QueryS
 
	void ChatTabCompletion()
 
	{
 
		static char _chat_tab_completion_buf[NETWORK_CHAT_LENGTH];
 
		assert(this->edit_str_size == lengthof(_chat_tab_completion_buf));
 

	
 
		Textbuf *tb = &this->text;
 
		size_t len, tb_len;
 
		uint item;
 
		char *tb_buf, *pre_buf;
 
		const char *cur_name;
 
		bool second_scan = false;
 

	
 
		item = 0;
 

	
 
		/* Copy the buffer so we can modify it without damaging the real data */
 
		pre_buf = (_chat_tab_completion_active) ? strdup(_chat_tab_completion_buf) : strdup(tb->buf);
 

	
 
		tb_buf  = ChatTabCompletionFindText(pre_buf);
 
		tb_len  = strlen(tb_buf);
 

	
 
		while ((cur_name = ChatTabCompletionNextItem(&item)) != NULL) {
 
			item++;
 

	
 
			if (_chat_tab_completion_active) {
 
				/* We are pressing TAB again on the same name, is there an other name
 
				/* We are pressing TAB again on the same name, is there another name
 
				 *  that starts with this? */
 
				if (!second_scan) {
 
					size_t offset;
 
					size_t length;
 

	
 
					/* If we are completing at the begin of the line, skip the ': ' we added */
 
					if (tb_buf == pre_buf) {
 
						offset = 0;
 
						length = (tb->size - 1) - 2;
 
					} else {
 
						/* Else, find the place we are completing at */
 
						offset = strlen(pre_buf) + 1;
 
						length = (tb->size - 1) - offset;
 
					}
 

	
 
					/* Compare if we have a match */
 
					if (strlen(cur_name) == length && strncmp(cur_name, tb->buf + offset, length) == 0) second_scan = true;
 

	
 
					continue;
 
				}
 

	
 
				/* Now any match we make on _chat_tab_completion_buf after this, is perfect */
 
			}
 

	
src/order_cmd.cpp
Show inline comments
 
@@ -168,49 +168,49 @@ Order::Order(uint32 packed)
 
}
 

	
 
/**
 
 *
 
 * Updates the widgets of a vehicle which contains the order-data
 
 *
 
 */
 
void InvalidateVehicleOrder(const Vehicle *v, int data)
 
{
 
	SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 

	
 
	if (data != 0) {
 
		/* Calls SetDirty() too */
 
		InvalidateWindowData(WC_VEHICLE_ORDERS,    v->index, data);
 
		InvalidateWindowData(WC_VEHICLE_TIMETABLE, v->index, data);
 
		return;
 
	}
 

	
 
	SetWindowDirty(WC_VEHICLE_ORDERS,    v->index);
 
	SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
 
}
 

	
 
/**
 
 *
 
 * Assign data to an order (from an other order)
 
 * Assign data to an order (from another order)
 
 *   This function makes sure that the index is maintained correctly
 
 *
 
 */
 
void Order::AssignOrder(const Order &other)
 
{
 
	this->type  = other.type;
 
	this->flags = other.flags;
 
	this->dest  = other.dest;
 

	
 
	this->refit_cargo   = other.refit_cargo;
 
	this->refit_subtype = other.refit_subtype;
 

	
 
	this->wait_time   = other.wait_time;
 
	this->travel_time = other.travel_time;
 
}
 

	
 
void OrderList::Initialize(Order *chain, Vehicle *v)
 
{
 
	this->first = chain;
 
	this->first_shared = v;
 

	
 
	this->num_orders = 0;
 
	this->num_vehicles = 1;
 
	this->timetable_duration = 0;
 
@@ -1089,49 +1089,49 @@ CommandCost CmdModifyOrder(TileIndex til
 
		Vehicle *u = v->FirstShared();
 
		DeleteOrderWarnings(u);
 
		for (; u != NULL; u = u->NextShared()) {
 
			/* Toggle u->current_order "Full load" flag if it changed.
 
			 * However, as the same flag is used for depot orders, check
 
			 * whether we are not going to a depot as there are three
 
			 * cases where the full load flag can be active and only
 
			 * one case where the flag is used for depot orders. In the
 
			 * other cases for the OrderTypeByte the flags are not used,
 
			 * so do not care and those orders should not be active
 
			 * when this function is called.
 
			 */
 
			if (sel_ord == u->cur_order_index &&
 
					(u->current_order.IsType(OT_GOTO_STATION) || u->current_order.IsType(OT_LOADING)) &&
 
					u->current_order.GetLoadType() != order->GetLoadType()) {
 
				u->current_order.SetLoadType(order->GetLoadType());
 
			}
 
			InvalidateVehicleOrder(u, -2);
 
		}
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
/** Clone/share/copy an order-list of an other vehicle.
 
/** Clone/share/copy an order-list of another vehicle.
 
 * @param tile unused
 
 * @param flags operation to perform
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit  0-15) - destination vehicle to clone orders to (p1 & 0xFFFF)
 
 * - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)
 
 * @param p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	VehicleID veh_src = GB(p1, 16, 16);
 
	VehicleID veh_dst = GB(p1,  0, 16);
 

	
 
	Vehicle *dst = Vehicle::GetIfValid(veh_dst);
 

	
 
	if (dst == NULL || !CheckOwnership(dst->owner)) return CMD_ERROR;
 

	
 
	switch (p2) {
 
		case CO_SHARE: {
 
			Vehicle *src = Vehicle::GetIfValid(veh_src);
 

	
 
			/* Sanity checks */
 
			if (src == NULL || !CheckOwnership(src->owner) || dst->type != src->type || dst == src) {
src/pathfinder/npf/aystar.cpp
Show inline comments
 
@@ -272,35 +272,35 @@ int AyStarMain_Main(AyStar *aystar)
 
/*
 
 * Adds a node from where to start an algorithm. Multiple nodes can be added
 
 * 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.
 
 */
 
static void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g)
 
{
 
#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);
 
#endif
 
	AyStarMain_OpenList_Add(aystar, NULL, start_node, 0, g);
 
}
 

	
 
void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets)
 
{
 
	/* Allocated the Hash for the OpenList and ClosedList */
 
	init_Hash(&aystar->OpenListHash, hash, num_buckets);
 
	init_Hash(&aystar->ClosedListHash, hash, num_buckets);
 

	
 
	/* Set up our sorting queue
 
	 *  BinaryHeap allocates a block of 1024 nodes
 
	 *  When thatone gets full it reserves an otherone, till this number
 
	 *  When that one gets full it reserves another one, till this number
 
	 *  That is why it can stay this high */
 
	init_BinaryHeap(&aystar->OpenListQueue, 102400);
 

	
 
	aystar->addstart  = AyStarMain_AddStartNode;
 
	aystar->main      = AyStarMain_Main;
 
	aystar->loop      = AyStarMain_Loop;
 
	aystar->free      = AyStarMain_Free;
 
	aystar->clear     = AyStarMain_Clear;
 
	aystar->checktile = AyStarMain_CheckTile;
 
}
src/saveload/oldloader.h
Show inline comments
 
@@ -103,37 +103,37 @@ extern uint _bump_assert_value;
 
byte ReadByte(LoadgameState *ls);
 
bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks);
 

	
 
bool LoadTTDMain(LoadgameState *ls);
 
bool LoadTTOMain(LoadgameState *ls);
 

	
 
static inline uint16 ReadUint16(LoadgameState *ls)
 
{
 
	byte x = ReadByte(ls);
 
	return x | ReadByte(ls) << 8;
 
}
 

	
 
static inline uint32 ReadUint32(LoadgameState *ls)
 
{
 
	uint16 x = ReadUint16(ls);
 
	return x | ReadUint16(ls) << 16;
 
}
 

	
 
/* Help:
 
 *  - OCL_SVAR: load 'type' to offset 'offset' in a struct of type 'base', which must also
 
 *       be given via base in LoadChunk() as real pointer
 
 *  - OCL_VAR: load 'type' to a global var
 
 *  - OCL_END: every struct must end with this
 
 *  - OCL_NULL: read 'amount' of bytes and send them to /dev/null or something
 
 *  - OCL_CHUNK: load an other proc to load a part of the savegame, 'amount' times
 
 *  - OCL_CHUNK: load another proc to load a part of the savegame, 'amount' times
 
 *  - OCL_ASSERT: to check if we are really at the place we expect to be.. because old savegames are too binary to be sure ;)
 
 */
 
#define OCL_SVAR(type, base, offset)         { type,                 1,    NULL, (uint)cpp_offsetof(base, offset), NULL }
 
#define OCL_VAR(type, amount, pointer)       { type,            amount, pointer,    0,                             NULL }
 
#define OCL_END()                            { OC_END,               0,    NULL,    0,                             NULL }
 
#define OCL_CNULL(type, amount)              { OC_NULL | type,  amount,    NULL,    0,                             NULL }
 
#define OCL_CCHUNK(type, amount, proc)       { OC_CHUNK | type, amount,    NULL,    0,                             proc }
 
#define OCL_ASSERT(type, size)               { OC_ASSERT | type,     1,    NULL, size,                             NULL }
 
#define OCL_NULL(amount)        OCL_CNULL((OldChunkType)0, amount)
 
#define OCL_CHUNK(amount, proc) OCL_CCHUNK((OldChunkType)0, amount, proc)
 

	
 
#endif /* OLDLOADER_H */
src/saveload/order_sl.cpp
Show inline comments
 
@@ -110,50 +110,50 @@ const SaveLoad *GetOrderDescription()
 
		     SLE_END()
 
	};
 

	
 
	return _order_desc;
 
}
 

	
 
static void Save_ORDR()
 
{
 
	Order *order;
 

	
 
	FOR_ALL_ORDERS(order) {
 
		SlSetArrayIndex(order->index);
 
		SlObject(order, GetOrderDescription());
 
	}
 
}
 

	
 
static void Load_ORDR()
 
{
 
	if (CheckSavegameVersionOldStyle(5, 2)) {
 
		/* Version older than 5.2 did not have a ->next pointer. Convert them
 
		 * (in the old days, the orderlist was 5000 items big) */
 
		size_t len = SlGetFieldLength();
 

	
 
		if (CheckSavegameVersion(5)) {
 
			/* Pre-version 5 had an other layout for orders
 
			    (uint16 instead of uint32) */
 
			/* Pre-version 5 had another layout for orders
 
			 * (uint16 instead of uint32) */
 
			len /= sizeof(uint16);
 
			uint16 *orders = MallocT<uint16>(len + 1);
 

	
 
			SlArray(orders, len, SLE_UINT16);
 

	
 
			for (size_t i = 0; i < len; ++i) {
 
				Order *o = new (i) Order();
 
				o->AssignOrder(UnpackVersion4Order(orders[i]));
 
			}
 

	
 
			free(orders);
 
		} else if (CheckSavegameVersionOldStyle(5, 2)) {
 
			len /= sizeof(uint32);
 
			uint32 *orders = MallocT<uint32>(len + 1);
 

	
 
			SlArray(orders, len, SLE_UINT32);
 

	
 
			for (size_t i = 0; i < len; ++i) {
 
				new (i) Order(orders[i]);
 
			}
 

	
 
			free(orders);
 
		}
 

	
src/screenshot.cpp
Show inline comments
 
@@ -332,49 +332,49 @@ struct PcxHeader {
 
	byte bpp;
 
	uint32 unused;
 
	uint16 xmax, ymax;
 
	uint16 hdpi, vdpi;
 
	byte pal_small[16 * 3];
 
	byte reserved;
 
	byte planes;
 
	uint16 pitch;
 
	uint16 cpal;
 
	uint16 width;
 
	uint16 height;
 
	byte filler[54];
 
};
 
assert_compile(sizeof(PcxHeader) == 128);
 

	
 
static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
 
{
 
	FILE *f;
 
	uint maxlines;
 
	uint y;
 
	PcxHeader pcx;
 
	bool success;
 

	
 
	if (pixelformat == 32) {
 
		DEBUG(misc, 0, "Can't convert a 32bpp screenshot to PCX format. Please pick an other format.");
 
		DEBUG(misc, 0, "Can't convert a 32bpp screenshot to PCX format. Please pick another format.");
 
		return false;
 
	}
 
	if (pixelformat != 8 || w == 0)
 
		return false;
 

	
 
	f = fopen(name, "wb");
 
	if (f == NULL) return false;
 

	
 
	memset(&pcx, 0, sizeof(pcx));
 

	
 
	/* setup pcx header */
 
	pcx.manufacturer = 10;
 
	pcx.version = 5;
 
	pcx.rle = 1;
 
	pcx.bpp = 8;
 
	pcx.xmax = TO_LE16(w - 1);
 
	pcx.ymax = TO_LE16(h - 1);
 
	pcx.hdpi = TO_LE16(320);
 
	pcx.vdpi = TO_LE16(320);
 

	
 
	pcx.planes = 1;
 
	pcx.cpal = TO_LE16(1);
 
	pcx.width = pcx.pitch = TO_LE16(w);
 
	pcx.height = TO_LE16(h);
src/script/squirrel_std.hpp
Show inline comments
 
@@ -16,48 +16,48 @@
 
/* Which idiotic system makes 'require' a macro? :s Oh well.... */
 
#undef require
 
#endif /* __APPLE__ */
 

	
 
/**
 
 * By default we want to give a set of standard commands to a SQ script.
 
 * Most of them are easy wrappers around internal functions. Of course we
 
 *  could just as easy include things like the stdmath of SQ, but of those
 
 *  functions we are sure they work on all our supported targets.
 
 */
 
class SquirrelStd {
 
public:
 

	
 
	/**
 
	 * Get the lowest of two integers.
 
	 */
 
	static SQInteger min(HSQUIRRELVM vm);
 

	
 
	/**
 
	 * Get the highest of two integers.
 
	 */
 
	static SQInteger max(HSQUIRRELVM vm);
 

	
 
	/**
 
	 * Load an other file on runtime.
 
	 * Load another file on runtime.
 
	 * @note This is always loaded on the root-level, no matter where you call this.
 
	 * @note The filename is always relative from the script it is called from. Absolute calls are NOT allowed!
 
	 */
 
	static SQInteger require(HSQUIRRELVM vm);
 

	
 
	/**
 
	 * Enable/disable stack trace showing for handled exceptions.
 
	 */
 
	static SQInteger notifyallexceptions(HSQUIRRELVM vm);
 
};
 

	
 
/**
 
 * Register all standard functions we want to give to a script.
 
 */
 
void squirrel_register_std(Squirrel *engine);
 

	
 
/**
 
 * Register all standard functions that are available on first startup.
 
 * @note this set is very limited, and is only ment to load other scripts and things like that.
 
 */
 
void squirrel_register_global_std(Squirrel *engine);
 

	
 
#endif /* SQUIRREL_STD_HPP */
src/spriteloader/grf.cpp
Show inline comments
 
@@ -73,49 +73,49 @@ bool SpriteLoaderGrf::LoadSprite(SpriteL
 
			num -= size;
 
			if (num < 0) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
 
			for (; size > 0; size--) {
 
				*dest = FioReadByte();
 
				dest++;
 
			}
 
		} else {
 
			/* Copy bytes from earlier in the sprite */
 
			const uint data_offset = ((code & 7) << 8) | FioReadByte();
 
			if (dest - data_offset < dest_orig) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
 
			int size = -(code >> 3);
 
			num -= size;
 
			if (num < 0) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
 
			for (; size > 0; size--) {
 
				*dest = *(dest - data_offset);
 
				dest++;
 
			}
 
		}
 
	}
 

	
 
	if (num != 0) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
 

	
 
	sprite->AllocateData(sprite->width * sprite->height);
 

	
 
	/* When there are transparency pixels, this format has an other trick.. decode it */
 
	/* When there are transparency pixels, this format has another trick.. decode it */
 
	if (type & 0x08) {
 
		for (int y = 0; y < sprite->height; y++) {
 
			bool last_item = false;
 
			/* Look up in the header-table where the real data is stored for this row */
 
			int offset = (dest_orig[y * 2 + 1] << 8) | dest_orig[y * 2];
 

	
 
			/* Go to that row */
 
			dest = dest_orig + offset;
 

	
 
			do {
 
				if (dest + 2 > dest_orig + dest_size) {
 
					free(sprite->data);
 
					return WarnCorruptSprite(file_slot, file_pos, __LINE__);
 
				}
 

	
 
				SpriteLoader::CommonPixel *data;
 
				/* Read the header:
 
				 *  0 .. 14  - length
 
				 *  15       - last_item
 
				 *  16 .. 31 - transparency bytes */
 
				last_item  = ((*dest) & 0x80) != 0;
 
				int length =  (*dest++) & 0x7F;
 
				int skip   =   *dest++;
 

	
src/viewport.cpp
Show inline comments
 
@@ -1165,49 +1165,49 @@ void ViewportSign::UpdatePosition(int ce
 

	
 
	this->top = top;
 

	
 
	char buffer[DRAW_STRING_BUFFER];
 

	
 
	GetString(buffer, str, lastof(buffer));
 
	this->width_normal = VPSM_LEFT + Align(GetStringBoundingBox(buffer).width, 2) + VPSM_RIGHT;
 
	this->center = center;
 

	
 
	/* zoomed out version */
 
	_cur_fontsize = FS_SMALL;
 
	this->width_small = VPSM_LEFT + Align(GetStringBoundingBox(buffer).width, 2) + VPSM_RIGHT;
 
	_cur_fontsize = FS_NORMAL;
 

	
 
	this->MarkDirty();
 
}
 

	
 
/**
 
 * Mark the sign dirty in all viewports.
 
 *
 
 * @ingroup dirty
 
 */
 
void ViewportSign::MarkDirty() const
 
{
 
	/* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
 
	/* We use ZOOM_LVL_MAX here, as every viewport can have another zoom,
 
	 *  and there is no way for us to know which is the biggest. So make the
 
	 *  biggest area dirty, and we are safe for sure.
 
	 * We also add 1 to make sure the whole thing is redrawn. */
 
	MarkAllViewportsDirty(
 
		this->center - ScaleByZoom(this->width_normal / 2 + 1, ZOOM_LVL_MAX),
 
		this->top    - ScaleByZoom(1, ZOOM_LVL_MAX),
 
		this->center + ScaleByZoom(this->width_normal / 2 + 1, ZOOM_LVL_MAX),
 
		this->top    + ScaleByZoom(VPSM_TOP + FONT_HEIGHT_NORMAL + VPSM_BOTTOM + 1, ZOOM_LVL_MAX));
 
}
 

	
 
static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv)
 
{
 
	const TileSpriteToDraw *tsend = tstdv->End();
 
	for (const TileSpriteToDraw *ts = tstdv->Begin(); ts != tsend; ++ts) {
 
		DrawSprite(ts->image, ts->pal, ts->x, ts->y, ts->sub);
 
	}
 
}
 

	
 
/** Sort parent sprites pointer array */
 
static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
 
{
 
	ParentSpriteToDraw **psdvend = psdv->End();
 
	ParentSpriteToDraw **psd = psdv->Begin();
 
	while (psd != psdvend) {
0 comments (0 inline, 0 general)