Changeset - r200:f379a875a5a7
[Not reviewed]
master
0 7 0
truelight - 20 years ago 2004-09-11 09:40:19
truelight@openttd.org
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
-Fix: [1025836] Long bridges had negative value
-Fix: Typo in endian_check.c (Zr40)
7 files changed with 29 insertions and 27 deletions:
0 comments (0 inline, 0 general)
bridge_gui.c
Show inline comments
 
@@ -145,7 +145,9 @@ void ShowBuildBridgeWindow(uint start, u
 
			if (CheckBridge_Stuff(bridge_type, bridge_len)) {
 
				// bridge is accepted, add to list
 
				// add to terraforming & bulldozing costs the cost of the bridge itself (not computed with DC_QUERY_COST)
 
				_bridge.costs[j] = ret + (((tot_bridge_len * _price.build_bridge) * _bridge_type_price_mod[bridge_type]) >> 8);
 
				_bridge.costs[j] = ret + ((((int64)tot_bridge_len * (int64)_price.build_bridge) * (int64)_bridge_type_price_mod[bridge_type]) >> 8);
 
				if (_bridge.costs[j] < 0)
 
					printf("BLAAT!\n");
 
				_bridge.indexes[j] = bridge_type;
 
				j++;
 
			}
economy.c
Show inline comments
 
@@ -41,9 +41,9 @@ void UpdatePlayerHouse(Player *p, uint s
 
	MarkTileDirtyByTile(tile + TILE_XY(1,1));
 
}
 

	
 
uint32 CalculateCompanyValue(Player *p) {
 
int64 CalculateCompanyValue(Player *p) {
 
	byte owner = p->index;
 
	uint32 value;
 
	int64 value;
 

	
 
	{
 
		Station *st;
 
@@ -340,7 +340,7 @@ extern void DeletePlayerWindows(int pi);
 
static void PlayersCheckBankrupt(Player *p)
 
{
 
	int owner;
 
	uint32 val;
 
	int64 val;
 

	
 
	if (p->player_money >= 0) {
 
		p->quarters_of_bankrupcy = 0;
 
@@ -1313,7 +1313,7 @@ static void DoAcquireCompany(Player *p)
 
{
 
	Player *owner;
 
	int i,pi;
 
	int32 value;
 
	int64 value;
 

	
 
	SET_DPARAM16(0, p->name_1);
 
	SET_DPARAM32(1, p->name_2);
 
@@ -1347,7 +1347,7 @@ static void DoAcquireCompany(Player *p)
 
int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	int32 cost;
 
	int64 cost;
 
	byte *b;
 
	int i;
 

	
 
@@ -1375,7 +1375,7 @@ int32 CmdBuyShareInCompany(int x, int y,
 
int32 CmdSellShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	int32 cost;
 
	int64 cost;
 
	byte *b;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
endian_check.c
Show inline comments
 
@@ -2,7 +2,7 @@
 

	
 
// This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN
 
//  it does that by putting a 1 and a 0 in an array, and read it out as one
 
//  number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDINA
 
//  number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN
 
//
 
// After that it outputs the contents of an include files (endian.h)
 
//  that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes
lang/english.txt
Show inline comments
 
@@ -1932,7 +1932,7 @@ STR_RELOCATE_HQ						:{BLACK}Relocate HQ
 
STR_7073_WORLD_RECESSION_FINANCIAL		:{BIGFONT}{BLACK}World Recession!{}{}Financial experts fear worst as economy slumps!
 
STR_7074_RECESSION_OVER_UPTURN_IN		:{BIGFONT}{BLACK}Recession Over!{}{}Upturn in trade gives confidence to industries as economy strengthens!
 
STR_7075_TOGGLE_LARGE_SMALL_WINDOW		:{BLACK}Toggle large/small window size
 
STR_7076_COMPANY_VALUE					:{GOLD}Company value: {WHITE}{CURRENCY}
 
STR_7076_COMPANY_VALUE					:{GOLD}Company value: {WHITE}{CURRENCY64}
 
STR_7077_BUY_25_SHARE_IN_COMPANY		:{BLACK}Buy 25% share in company
 
STR_7078_SELL_25_SHARE_IN_COMPANY		:{BLACK}Sell 25% share in company
 
STR_7079_BUY_25_SHARE_IN_THIS_COMPANY	:{BLACK}Buy 25% share in this company
player.h
Show inline comments
 
@@ -8,7 +8,7 @@ typedef struct PlayerEconomyEntry {
 
	int32 expenses;
 
	int32 delivered_cargo;
 
	int32 performance_history;	// player score (scale 0-1000)
 
	int32 company_value;
 
	int64 company_value;
 
} PlayerEconomyEntry;
 

	
 
typedef struct AiBuildRec {
 
@@ -188,7 +188,7 @@ typedef struct Player {
 

	
 
void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player);
 
void GetNameOfOwner(byte owner, uint tile);
 
uint32 CalculateCompanyValue(Player *p);
 
int64 CalculateCompanyValue(Player *p);
 
void InvalidatePlayerWindows(Player *p);
 
void AiDoGameLoop(Player *p);
 
void UpdatePlayerMoney32(Player *p);
player_gui.c
Show inline comments
 
@@ -25,7 +25,7 @@ static void DrawPlayerEconomyStats(Playe
 
		for(i=0; i!=13; i++)
 
			DrawString(2, 27 + i*10, STR_7011_CONSTRUCTION + i, 0);
 
		DrawStringRightAligned(111, 27 + 10*13 + 2, STR_7020_TOTAL, 0);
 
	
 

	
 
		/* draw the price columns */
 
		year = _cur_year - 2;
 
		j = 3;
 
@@ -41,7 +41,7 @@ static void DrawPlayerEconomyStats(Playe
 
					cost = (*tbl)[i];
 
					if (cost != 0) {
 
						sum += cost;
 
						
 

	
 
						str = STR_701E;
 
						if (cost < 0) { cost = -cost; str++; }
 
						SET_DPARAM64(0, cost);
 
@@ -53,7 +53,7 @@ static void DrawPlayerEconomyStats(Playe
 
				if (sum < 0) { sum = -sum; str++; }
 
				SET_DPARAM64(0, sum);
 
				DrawStringRightAligned(x, 27 + 13*10 + 2, str, 0);
 
				
 

	
 
				GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215);
 
				x += 95;
 
			}
 
@@ -134,7 +134,7 @@ static void PlayerFinancesWndProc(Window
 
	switch(e->event) {
 
	case WE_PAINT: {
 
		Player *p = DEREF_PLAYER(w->window_number);
 
		
 

	
 
		w->disabled_state = p->current_loan != 0 ? 0 : (1 << 6);
 

	
 
		SET_DPARAM16(0, p->name_1);
 
@@ -241,7 +241,7 @@ static void SelectPlayerColorWndProc(Win
 
		WP(w,def_d).data_1 = used_colors;
 
		SetVScrollCount(w, num_free);
 
		DrawWindowWidgets(w);
 
		
 

	
 
		x = 2;
 
		y = 17;
 
		pos = w->vscroll.pos;
 
@@ -255,7 +255,7 @@ static void SelectPlayerColorWndProc(Win
 
			used_colors >>= 1;
 
		}
 
	} break;
 
		
 

	
 
	case WE_CLICK:
 
		if (e->click.widget == 2) {
 
			int item = (e->click.pt.y - 13) / 14;
 
@@ -266,7 +266,7 @@ static void SelectPlayerColorWndProc(Win
 
				return;
 
			item += w->vscroll.pos;
 
			used_colors = WP(w,def_d).data_1;
 
			
 

	
 
			for(i=0; i!=16; i++) {
 
				if (!(used_colors & 1) && --item < 0) {
 
					DoCommandP(0, w->window_number, i, NULL, CMD_SET_PLAYER_COLOR);
 
@@ -310,7 +310,7 @@ static void SelectPlayerFaceWndProc(Wind
 
	case WE_CLICK:
 
		switch(e->click.widget) {
 
		case 3: DeleteWindow(w); break;
 
		case 4: /* ok click */ 
 
		case 4: /* ok click */
 
			DoCommandP(0, w->window_number, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
 
			DeleteWindow(w);
 
			break;
 
@@ -394,7 +394,7 @@ static void DrawPlayerVehiclesAmount(int
 
	int y = 72;
 
	Vehicle *v;
 
	uint train,road,air,ship;
 
	
 

	
 
	DrawString(x, y, STR_7039_VEHICLES, 0);
 

	
 
	train = road = air = ship = 0;
 
@@ -445,9 +445,9 @@ static void DrawPlayerVehiclesAmount(int
 

	
 
static int GetAmountOwnedBy(Player *p, byte owner)
 
{
 
	return (p->share_owners[0] == owner) + 
 
				 (p->share_owners[1] == owner) + 
 
				 (p->share_owners[2] == owner) + 
 
	return (p->share_owners[0] == owner) +
 
				 (p->share_owners[1] == owner) +
 
				 (p->share_owners[2] == owner) +
 
				 (p->share_owners[3] == owner);
 
}
 

	
 
@@ -483,7 +483,7 @@ static void PlayerCompanyWndProc(Window 
 

	
 
		if (w->widget != _other_player_company_widgets)
 
					w->widget = (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets;
 
	
 

	
 
		SET_DPARAM16(0, p->name_1);
 
		SET_DPARAM32(1, p->name_2);
 
		SET_DPARAM16(2, GetPlayerNameString((byte)w->window_number, 3));
 
@@ -509,7 +509,7 @@ static void PlayerCompanyWndProc(Window 
 
		SET_DPARAM32(1, p->president_name_2);
 
		DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94);
 

	
 
		SET_DPARAM32(0, CalculateCompanyValue(p));
 
		SET_DPARAM64(0, CalculateCompanyValue(p));
 
		DrawString(110, 114, STR_7076_COMPANY_VALUE, 0);
 

	
 
		DrawCompanyOwnerText(p);
 
@@ -557,7 +557,7 @@ static void PlayerCompanyWndProc(Window 
 
				SetTileSelectSize(2, 2);
 
			} else {
 
				ScrollMainWindowToTile(tile);
 
			}	
 
			}
 
		} break;
 

	
 
		case 8: /* relocate HQ */
tunnelbridge_cmd.c
Show inline comments
 
@@ -383,7 +383,7 @@ not_valid_below:;
 
		if (_current_player < MAX_PLAYERS && !(_is_ai_player && !_patches.ainew_active))
 
			bridge_len = CalcBridgeLenCostFactor(bridge_len);
 

	
 
		cost += ((bridge_len * _price.build_bridge) * _bridge_type_price_mod[bridge_type]) >> 8;
 
		cost += (((int64)bridge_len * (int64)_price.build_bridge) * (int64)_bridge_type_price_mod[bridge_type]) >> 8;
 
	}
 

	
 
	return cost;
0 comments (0 inline, 0 general)