(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother

This commit is contained in:
truelight 2006-08-22 16:38:50 +00:00
parent c0f352670a
commit b34d77ca3f
8 changed files with 144 additions and 143 deletions

View File

@ -1103,17 +1103,17 @@ static uint16 _last_sign_idx;
static int CDECL SignNameSorter(const void *a, const void *b) static int CDECL SignNameSorter(const void *a, const void *b)
{ {
char buf1[64]; char buf1[64];
SignStruct *ss; Sign *si;
const uint16 cmp1 = *(const uint16 *)a; const SignID cmp1 = *(const SignID *)a;
const uint16 cmp2 = *(const uint16 *)b; const SignID cmp2 = *(const SignID *)b;
ss = GetSign(cmp1); si = GetSign(cmp1);
GetString(buf1, ss->str); GetString(buf1, si->str);
if (cmp2 != _last_sign_idx) { if (cmp2 != _last_sign_idx) {
_last_sign_idx = cmp2; _last_sign_idx = cmp2;
ss = GetSign(cmp2); si = GetSign(cmp2);
GetString(_bufcache, ss->str); GetString(_bufcache, si->str);
} }
return strcmp(buf1, _bufcache); // sort by name return strcmp(buf1, _bufcache); // sort by name
@ -1121,7 +1121,7 @@ static int CDECL SignNameSorter(const void *a, const void *b)
static void GlobalSortSignList(void) static void GlobalSortSignList(void)
{ {
const SignStruct *ss; const Sign *si;
uint32 n = 0; uint32 n = 0;
_num_sign_sort = 0; _num_sign_sort = 0;
@ -1131,8 +1131,8 @@ static void GlobalSortSignList(void)
if (_sign_sort == NULL) if (_sign_sort == NULL)
error("Could not allocate memory for the sign-sorting-list"); error("Could not allocate memory for the sign-sorting-list");
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
_sign_sort[n++] = ss->index; _sign_sort[n++] = si->index;
_num_sign_sort++; _num_sign_sort++;
} }
@ -1163,17 +1163,18 @@ static void SignListWndProc(Window *w, WindowEvent *e)
return; return;
} }
{ const SignStruct *ss; {
const Sign *si;
uint16 i; uint16 i;
/* Start drawing the signs */ /* Start drawing the signs */
for (i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) { for (i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) {
ss = GetSign(_sign_sort[i]); si = GetSign(_sign_sort[i]);
if (ss->owner != OWNER_NONE) if (si->owner != OWNER_NONE)
DrawPlayerIcon(ss->owner, 4, y + 1); DrawPlayerIcon(si->owner, 4, y + 1);
DrawString(22, y, ss->str, 8); DrawString(22, y, si->str, 8);
y += 10; y += 10;
} }
} }
@ -1183,7 +1184,7 @@ static void SignListWndProc(Window *w, WindowEvent *e)
switch (e->click.widget) { switch (e->click.widget) {
case 3: { case 3: {
uint32 id_v = (e->click.pt.y - 15) / 10; uint32 id_v = (e->click.pt.y - 15) / 10;
SignStruct *ss; const Sign *si;
if (id_v >= w->vscroll.cap) if (id_v >= w->vscroll.cap)
return; return;
@ -1193,8 +1194,8 @@ static void SignListWndProc(Window *w, WindowEvent *e)
if (id_v >= w->vscroll.count) if (id_v >= w->vscroll.count)
return; return;
ss = GetSign(_sign_sort[id_v]); si = GetSign(_sign_sort[id_v]);
ScrollMainWindowToTile(TileVirtXY(ss->x, ss->y)); ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
} break; } break;
} }
} break; } break;

View File

@ -346,11 +346,11 @@ void ShowNetworkNeedCompanyPassword(void)
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
void ShowRenameSignWindow(const SignStruct *ss) void ShowRenameSignWindow(const Sign *si)
{ {
_rename_id = ss->index; _rename_id = si->index;
_rename_what = 0; _rename_what = 0;
ShowQueryString(ss->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, 1, 0, CS_ALPHANUMERAL); ShowQueryString(si->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, 1, 0, CS_ALPHANUMERAL);
} }
void ShowRenameWaypointWindow(const Waypoint *wp) void ShowRenameWaypointWindow(const Waypoint *wp)

View File

@ -1233,10 +1233,10 @@ static bool LoadOldVehicle(LoadgameState *ls, int num)
} }
static const OldChunks sign_chunk[] = { static const OldChunks sign_chunk[] = {
OCL_SVAR( OC_UINT16, SignStruct, str ), OCL_SVAR( OC_UINT16, Sign, str ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,SignStruct, x ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,Sign, x ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,SignStruct, y ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,Sign, y ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I8, SignStruct, z ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I8, Sign, z ),
OCL_NULL( 6 ), // Width of sign, no longer in use OCL_NULL( 6 ), // Width of sign, no longer in use

View File

@ -1091,9 +1091,9 @@ static void UpdateVoidTiles(void)
// since savegame version 6.0 each sign has an "owner", signs without owner (from old games are set to 255) // since savegame version 6.0 each sign has an "owner", signs without owner (from old games are set to 255)
static void UpdateSignOwner(void) static void UpdateSignOwner(void)
{ {
SignStruct *ss; Sign *si;
FOR_ALL_SIGNS(ss) ss->owner = OWNER_NONE; FOR_ALL_SIGNS(si) si->owner = OWNER_NONE;
} }
extern void UpdateOldAircraft( void ); extern void UpdateOldAircraft( void );

View File

@ -49,6 +49,7 @@ typedef uint32 PalSpriteID; ///< The number of a sprite plus all the mapping bit
typedef uint32 CursorID; typedef uint32 CursorID;
typedef uint16 EngineID; ///< All enginenumbers should be of this type typedef uint16 EngineID; ///< All enginenumbers should be of this type
typedef uint16 EngineRenewID; typedef uint16 EngineRenewID;
typedef uint16 SignID;
typedef uint16 UnitID; ///< All unitnumber stuff is of this type (or anyway, should be) typedef uint16 UnitID; ///< All unitnumber stuff is of this type (or anyway, should be)
typedef uint32 WindowNumber; typedef uint32 WindowNumber;

122
signs.c
View File

@ -10,7 +10,7 @@
#include "command.h" #include "command.h"
#include "variables.h" #include "variables.h"
static SignStruct *_new_sign_struct; static Sign *_new_sign;
enum { enum {
/* Max signs: 64000 (4 * 16000) */ /* Max signs: 64000 (4 * 16000) */
@ -23,26 +23,26 @@ enum {
*/ */
static void SignPoolNewBlock(uint start_item) static void SignPoolNewBlock(uint start_item)
{ {
SignStruct *ss; Sign *si;
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. /* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
* TODO - This is just a temporary stage, this will be removed. */ * TODO - This is just a temporary stage, this will be removed. */
for (ss = GetSign(start_item); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) ss->index = start_item++; for (si = GetSign(start_item); si != NULL; si = (si->index + 1 < GetSignPoolSize()) ? GetSign(si->index + 1) : NULL) si->index = start_item++;
} }
/* Initialize the sign-pool */ /* Initialize the sign-pool */
MemoryPool _sign_pool = { "Signs", SIGN_POOL_MAX_BLOCKS, SIGN_POOL_BLOCK_SIZE_BITS, sizeof(SignStruct), &SignPoolNewBlock, NULL, 0, 0, NULL }; MemoryPool _sign_pool = { "Signs", SIGN_POOL_MAX_BLOCKS, SIGN_POOL_BLOCK_SIZE_BITS, sizeof(Sign), &SignPoolNewBlock, NULL, 0, 0, NULL };
/** /**
* *
* Update the coordinate of one sign * Update the coordinate of one sign
* *
*/ */
static void UpdateSignVirtCoords(SignStruct *ss) static void UpdateSignVirtCoords(Sign *si)
{ {
Point pt = RemapCoords(ss->x, ss->y, ss->z); Point pt = RemapCoords(si->x, si->y, si->z);
SetDParam(0, ss->str); SetDParam(0, si->str);
UpdateViewportSignPos(&ss->sign, pt.x, pt.y - 6, STR_2806); UpdateViewportSignPos(&si->sign, pt.x, pt.y - 6, STR_2806);
} }
/** /**
@ -52,9 +52,9 @@ static void UpdateSignVirtCoords(SignStruct *ss)
*/ */
void UpdateAllSignVirtCoords(void) void UpdateAllSignVirtCoords(void)
{ {
SignStruct *ss; Sign *si;
FOR_ALL_SIGNS(ss) UpdateSignVirtCoords(ss); FOR_ALL_SIGNS(si) UpdateSignVirtCoords(si);
} }
@ -62,15 +62,15 @@ void UpdateAllSignVirtCoords(void)
* *
* Marks the region of a sign as dirty * Marks the region of a sign as dirty
* *
* @param ss Pointer to the SignStruct * @param si Pointer to the Sign
*/ */
static void MarkSignDirty(SignStruct *ss) static void MarkSignDirty(Sign *si)
{ {
MarkAllViewportsDirty( MarkAllViewportsDirty(
ss->sign.left - 6, si->sign.left - 6,
ss->sign.top - 3, si->sign.top - 3,
ss->sign.left + ss->sign.width_1 * 4 + 12, si->sign.left + si->sign.width_1 * 4 + 12,
ss->sign.top + 45); si->sign.top + 45);
} }
/** /**
@ -79,20 +79,20 @@ static void MarkSignDirty(SignStruct *ss)
* *
* @return The pointer to the new sign, or NULL if there is no more free space * @return The pointer to the new sign, or NULL if there is no more free space
*/ */
static SignStruct *AllocateSign(void) static Sign *AllocateSign(void)
{ {
SignStruct *ss; Sign *si;
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. /* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
* TODO - This is just a temporary stage, this will be removed. */ * TODO - This is just a temporary stage, this will be removed. */
for (ss = GetSign(0); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) { for (si = GetSign(0); si != NULL; si = (si->index + 1 < GetSignPoolSize()) ? GetSign(si->index + 1) : NULL) {
if (!IsValidSign(ss)) { if (!IsValidSign(si)) {
uint index = ss->index; uint index = si->index;
memset(ss, 0, sizeof(SignStruct)); memset(si, 0, sizeof(Sign));
ss->index = index; si->index = index;
return ss; return si;
} }
} }
@ -112,27 +112,27 @@ static SignStruct *AllocateSign(void)
*/ */
int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{ {
SignStruct *ss; Sign *si;
/* Try to locate a new sign */ /* Try to locate a new sign */
ss = AllocateSign(); si = AllocateSign();
if (ss == NULL) return_cmd_error(STR_2808_TOO_MANY_SIGNS); if (si == NULL) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
/* When we execute, really make the sign */ /* When we execute, really make the sign */
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
int x = TileX(tile) * TILE_SIZE; int x = TileX(tile) * TILE_SIZE;
int y = TileY(tile) * TILE_SIZE; int y = TileY(tile) * TILE_SIZE;
ss->str = STR_280A_SIGN; si->str = STR_280A_SIGN;
ss->x = x; si->x = x;
ss->y = y; si->y = y;
ss->owner = _current_player; // owner of the sign; just eyecandy si->owner = _current_player; // owner of the sign; just eyecandy
ss->z = GetSlopeZ(x,y); si->z = GetSlopeZ(x,y);
UpdateSignVirtCoords(ss); UpdateSignVirtCoords(si);
MarkSignDirty(ss); MarkSignDirty(si);
InvalidateWindow(WC_SIGN_LIST, 0); InvalidateWindow(WC_SIGN_LIST, 0);
_sign_sort_dirty = true; _sign_sort_dirty = true;
_new_sign_struct = ss; _new_sign = si;
} }
return 0; return 0;
@ -157,18 +157,18 @@ int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (str == 0) return CMD_ERROR; if (str == 0) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
SignStruct *ss = GetSign(p1); Sign *si = GetSign(p1);
/* Delete the old name */ /* Delete the old name */
DeleteName(ss->str); DeleteName(si->str);
/* Assign the new one */ /* Assign the new one */
ss->str = str; si->str = str;
ss->owner = _current_player; si->owner = _current_player;
/* Update; mark sign dirty twice, because it can either becom longer, or shorter */ /* Update; mark sign dirty twice, because it can either becom longer, or shorter */
MarkSignDirty(ss); MarkSignDirty(si);
UpdateSignVirtCoords(ss); UpdateSignVirtCoords(si);
MarkSignDirty(ss); MarkSignDirty(si);
InvalidateWindow(WC_SIGN_LIST, 0); InvalidateWindow(WC_SIGN_LIST, 0);
_sign_sort_dirty = true; _sign_sort_dirty = true;
} else { } else {
@ -177,13 +177,13 @@ int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} }
} else { /* Delete sign */ } else { /* Delete sign */
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
SignStruct *ss = GetSign(p1); Sign *si = GetSign(p1);
/* Delete the name */ /* Delete the name */
DeleteName(ss->str); DeleteName(si->str);
ss->str = 0; si->str = 0;
MarkSignDirty(ss); MarkSignDirty(si);
InvalidateWindow(WC_SIGN_LIST, 0); InvalidateWindow(WC_SIGN_LIST, 0);
_sign_sort_dirty = true; _sign_sort_dirty = true;
} }
@ -200,7 +200,7 @@ int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
{ {
if (success) { if (success) {
ShowRenameSignWindow(_new_sign_struct); ShowRenameSignWindow(_new_sign);
ResetObjectToPlace(); ResetObjectToPlace();
} }
} }
@ -228,13 +228,13 @@ void InitializeSigns(void)
} }
static const SaveLoad _sign_desc[] = { static const SaveLoad _sign_desc[] = {
SLE_VAR(SignStruct, str, SLE_UINT16), SLE_VAR(Sign, str, SLE_UINT16),
SLE_CONDVAR(SignStruct, x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), SLE_CONDVAR(Sign, x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
SLE_CONDVAR(SignStruct, y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), SLE_CONDVAR(Sign, y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
SLE_CONDVAR(SignStruct, x, SLE_INT32, 5, SL_MAX_VERSION), SLE_CONDVAR(Sign, x, SLE_INT32, 5, SL_MAX_VERSION),
SLE_CONDVAR(SignStruct, y, SLE_INT32, 5, SL_MAX_VERSION), SLE_CONDVAR(Sign, y, SLE_INT32, 5, SL_MAX_VERSION),
SLE_CONDVAR(SignStruct, owner, SLE_UINT8, 6, SL_MAX_VERSION), SLE_CONDVAR(Sign, owner, SLE_UINT8, 6, SL_MAX_VERSION),
SLE_VAR(SignStruct, z, SLE_UINT8), SLE_VAR(Sign, z, SLE_UINT8),
SLE_END() SLE_END()
}; };
@ -245,11 +245,11 @@ static const SaveLoad _sign_desc[] = {
*/ */
static void Save_SIGN(void) static void Save_SIGN(void)
{ {
SignStruct *ss; Sign *si;
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
SlSetArrayIndex(ss->index); SlSetArrayIndex(si->index);
SlObject(ss, _sign_desc); SlObject(si, _sign_desc);
} }
} }
@ -262,13 +262,13 @@ static void Load_SIGN(void)
{ {
int index; int index;
while ((index = SlIterateArray()) != -1) { while ((index = SlIterateArray()) != -1) {
SignStruct *ss; Sign *si;
if (!AddBlockIfNeeded(&_sign_pool, index)) if (!AddBlockIfNeeded(&_sign_pool, index))
error("Signs: failed loading savegame: too many signs"); error("Signs: failed loading savegame: too many signs");
ss = GetSign(index); si = GetSign(index);
SlObject(ss, _sign_desc); SlObject(si, _sign_desc);
} }
_sign_sort_dirty = true; _sign_sort_dirty = true;

21
signs.h
View File

@ -5,26 +5,25 @@
#include "pool.h" #include "pool.h"
typedef struct SignStruct { typedef struct Sign {
StringID str; StringID str;
ViewportSign sign; ViewportSign sign;
int32 x; int32 x;
int32 y; int32 y;
byte z; byte z;
PlayerID owner; // placed by this player. Anyone can delete them though. PlayerID owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games.
// OWNER_NONE for gray signs from old games.
uint16 index; SignID index;
} SignStruct; } Sign;
extern MemoryPool _sign_pool; extern MemoryPool _sign_pool;
/** /**
* Get the pointer to the sign with index 'index' * Get the pointer to the sign with index 'index'
*/ */
static inline SignStruct *GetSign(uint index) static inline Sign *GetSign(SignID index)
{ {
return (SignStruct*)GetItemFromPool(&_sign_pool, index); return (Sign *)GetItemFromPool(&_sign_pool, index);
} }
/** /**
@ -43,21 +42,21 @@ static inline bool IsSignIndex(uint index)
/** /**
* Check if a Sign really exists. * Check if a Sign really exists.
*/ */
static inline bool IsValidSign(const SignStruct* ss) static inline bool IsValidSign(const Sign *si)
{ {
return ss->str != STR_NULL; return si->str != STR_NULL;
} }
#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) if (IsValidSign(ss)) #define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) if (IsValidSign(ss))
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
VARDEF bool _sign_sort_dirty; VARDEF bool _sign_sort_dirty;
VARDEF uint16 *_sign_sort; VARDEF SignID *_sign_sort;
void UpdateAllSignVirtCoords(void); void UpdateAllSignVirtCoords(void);
void PlaceProc_Sign(TileIndex tile); void PlaceProc_Sign(TileIndex tile);
/* misc.c */ /* misc.c */
void ShowRenameSignWindow(const SignStruct *ss); void ShowRenameSignWindow(const Sign *si);
#endif /* SIGNS_H */ #endif /* SIGNS_H */

View File

@ -883,7 +883,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
static void ViewportAddSigns(DrawPixelInfo *dpi) static void ViewportAddSigns(DrawPixelInfo *dpi)
{ {
SignStruct *ss; Sign *si;
int left, top, right, bottom; int left, top, right, bottom;
StringSpriteToDraw *sstd; StringSpriteToDraw *sstd;
@ -896,32 +896,32 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
bottom = top + dpi->height; bottom = top + dpi->height;
if (dpi->zoom < 1) { if (dpi->zoom < 1) {
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
if (bottom > ss->sign.top && if (bottom > si->sign.top &&
top < ss->sign.top + 12 && top < si->sign.top + 12 &&
right > ss->sign.left && right > si->sign.left &&
left < ss->sign.left + ss->sign.width_1) { left < si->sign.left + si->sign.width_1) {
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0); sstd=AddStringToDraw(si->sign.left + 1, si->sign.top + 1, STR_2806, si->str, 0, 0);
if (sstd != NULL) { if (sstd != NULL) {
sstd->width = ss->sign.width_1; sstd->width = si->sign.width_1;
sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner]; sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner];
} }
} }
} }
} else if (dpi->zoom == 1) { } else if (dpi->zoom == 1) {
right += 2; right += 2;
bottom += 2; bottom += 2;
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
if (bottom > ss->sign.top && if (bottom > si->sign.top &&
top < ss->sign.top + 24 && top < si->sign.top + 24 &&
right > ss->sign.left && right > si->sign.left &&
left < ss->sign.left + ss->sign.width_1*2) { left < si->sign.left + si->sign.width_1 * 2) {
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0); sstd=AddStringToDraw(si->sign.left + 1, si->sign.top + 1, STR_2806, si->str, 0, 0);
if (sstd != NULL) { if (sstd != NULL) {
sstd->width = ss->sign.width_1; sstd->width = si->sign.width_1;
sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner]; sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner];
} }
} }
} }
@ -929,16 +929,16 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
right += 4; right += 4;
bottom += 5; bottom += 5;
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
if (bottom > ss->sign.top && if (bottom > si->sign.top &&
top < ss->sign.top + 24 && top < si->sign.top + 24 &&
right > ss->sign.left && right > si->sign.left &&
left < ss->sign.left + ss->sign.width_2*4) { left < si->sign.left + si->sign.width_2 * 4) {
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2002, ss->str, 0, 0); sstd=AddStringToDraw(si->sign.left + 1, si->sign.top + 1, STR_2002, si->str, 0, 0);
if (sstd != NULL) { if (sstd != NULL) {
sstd->width = ss->sign.width_2 | 0x8000; sstd->width = si->sign.width_2 | 0x8000;
sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner]; sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner];
} }
} }
} }
@ -1563,7 +1563,7 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
static bool CheckClickOnSign(const ViewPort *vp, int x, int y) static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
{ {
const SignStruct *ss; const Sign *si;
if (!(_display_opt & DO_SHOW_SIGNS)) return false; if (!(_display_opt & DO_SHOW_SIGNS)) return false;
@ -1571,36 +1571,36 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
x = x - vp->left + vp->virtual_left; x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top; y = y - vp->top + vp->virtual_top;
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
if (y >= ss->sign.top && if (y >= si->sign.top &&
y < ss->sign.top + 12 && y < si->sign.top + 12 &&
x >= ss->sign.left && x >= si->sign.left &&
x < ss->sign.left + ss->sign.width_1) { x < si->sign.left + si->sign.width_1) {
ShowRenameSignWindow(ss); ShowRenameSignWindow(si);
return true; return true;
} }
} }
} else if (vp->zoom == 1) { } else if (vp->zoom == 1) {
x = (x - vp->left + 1) * 2 + vp->virtual_left; x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top; y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
if (y >= ss->sign.top && if (y >= si->sign.top &&
y < ss->sign.top + 24 && y < si->sign.top + 24 &&
x >= ss->sign.left && x >= si->sign.left &&
x < ss->sign.left + ss->sign.width_1 * 2) { x < si->sign.left + si->sign.width_1 * 2) {
ShowRenameSignWindow(ss); ShowRenameSignWindow(si);
return true; return true;
} }
} }
} else { } else {
x = (x - vp->left + 3) * 4 + vp->virtual_left; x = (x - vp->left + 3) * 4 + vp->virtual_left;
y = (y - vp->top + 3) * 4 + vp->virtual_top; y = (y - vp->top + 3) * 4 + vp->virtual_top;
FOR_ALL_SIGNS(ss) { FOR_ALL_SIGNS(si) {
if (y >= ss->sign.top && if (y >= si->sign.top &&
y < ss->sign.top + 24 && y < si->sign.top + 24 &&
x >= ss->sign.left && x >= si->sign.left &&
x < ss->sign.left + ss->sign.width_2 * 4) { x < si->sign.left + si->sign.width_2 * 4) {
ShowRenameSignWindow(ss); ShowRenameSignWindow(si);
return true; return true;
} }
} }