mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r17228) -Codechange: some coding style fixes
This commit is contained in:
parent
0188ebad56
commit
7fb95e2c2b
@ -198,7 +198,7 @@ SQInteger AIInfo::AddSetting(HSQUIRRELVM vm)
|
|||||||
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
||||||
config.hard_value = res;
|
config.hard_value = res;
|
||||||
items |= 0x040;
|
items |= 0x040;
|
||||||
} else if (strcmp(key, "random_deviation") == 0) {
|
} else if (strcmp(key, "random_deviation") == 0) {
|
||||||
SQInteger res;
|
SQInteger res;
|
||||||
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
||||||
config.random_deviation = res;
|
config.random_deviation = res;
|
||||||
|
@ -489,13 +489,19 @@ void AIAbstractList::Sort(SorterType sorter, bool ascending)
|
|||||||
delete this->sorter;
|
delete this->sorter;
|
||||||
switch (sorter) {
|
switch (sorter) {
|
||||||
case SORT_BY_ITEM:
|
case SORT_BY_ITEM:
|
||||||
if (ascending) this->sorter = new AIAbstractListSorterItemAscending(this);
|
if (ascending) {
|
||||||
else this->sorter = new AIAbstractListSorterItemDescending(this);
|
this->sorter = new AIAbstractListSorterItemAscending(this);
|
||||||
|
} else {
|
||||||
|
this->sorter = new AIAbstractListSorterItemDescending(this);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SORT_BY_VALUE:
|
case SORT_BY_VALUE:
|
||||||
if (ascending) this->sorter = new AIAbstractListSorterValueAscending(this);
|
if (ascending) {
|
||||||
else this->sorter = new AIAbstractListSorterValueDescending(this);
|
this->sorter = new AIAbstractListSorterValueAscending(this);
|
||||||
|
} else {
|
||||||
|
this->sorter = new AIAbstractListSorterValueDescending(this);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -363,8 +363,11 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt
|
|||||||
src = dst - scroll_y * this->anim_buf_width;
|
src = dst - scroll_y * this->anim_buf_width;
|
||||||
|
|
||||||
/* Adjust left & width */
|
/* Adjust left & width */
|
||||||
if (scroll_x >= 0) dst += scroll_x;
|
if (scroll_x >= 0) {
|
||||||
else src -= scroll_x;
|
dst += scroll_x;
|
||||||
|
} else {
|
||||||
|
src -= scroll_x;
|
||||||
|
}
|
||||||
|
|
||||||
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
|
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
|
||||||
uint th = height - scroll_y;
|
uint th = height - scroll_y;
|
||||||
@ -379,8 +382,11 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt
|
|||||||
src = dst - scroll_y * this->anim_buf_width;
|
src = dst - scroll_y * this->anim_buf_width;
|
||||||
|
|
||||||
/* Adjust left & width */
|
/* Adjust left & width */
|
||||||
if (scroll_x >= 0) dst += scroll_x;
|
if (scroll_x >= 0) {
|
||||||
else src -= scroll_x;
|
dst += scroll_x;
|
||||||
|
} else {
|
||||||
|
src -= scroll_x;
|
||||||
|
}
|
||||||
|
|
||||||
/* the y-displacement may be 0 therefore we have to use memmove,
|
/* the y-displacement may be 0 therefore we have to use memmove,
|
||||||
* because source and destination may overlap */
|
* because source and destination may overlap */
|
||||||
|
@ -69,7 +69,8 @@ static void debug_print(const char *dbg, const char *buf)
|
|||||||
|
|
||||||
snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf);
|
snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf);
|
||||||
send(_debug_socket, buf2, (int)strlen(buf2), 0);
|
send(_debug_socket, buf2, (int)strlen(buf2), 0);
|
||||||
} else
|
return;
|
||||||
|
}
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
if (strcmp(dbg, "desync") != 0) {
|
if (strcmp(dbg, "desync") != 0) {
|
||||||
#if defined(WINCE)
|
#if defined(WINCE)
|
||||||
|
@ -152,7 +152,7 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh
|
|||||||
|
|
||||||
if (wagon == NULL) {
|
if (wagon == NULL) {
|
||||||
if (head != NULL) wagon = head->Last();
|
if (head != NULL) wagon = head->Last();
|
||||||
} else {
|
} else {
|
||||||
wagon = wagon->Previous();
|
wagon = wagon->Previous();
|
||||||
if (wagon == NULL) return;
|
if (wagon == NULL) return;
|
||||||
}
|
}
|
||||||
|
@ -102,11 +102,14 @@ const char *FiosBrowseTo(const FiosItem *item)
|
|||||||
s[0] = '\0'; // Remove last path separator character, so we can go up one level.
|
s[0] = '\0'; // Remove last path separator character, so we can go up one level.
|
||||||
}
|
}
|
||||||
s = strrchr(path, PATHSEPCHAR);
|
s = strrchr(path, PATHSEPCHAR);
|
||||||
if (s != NULL) s[1] = '\0'; // go up a directory
|
if (s != NULL) {
|
||||||
|
s[1] = '\0'; // go up a directory
|
||||||
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
|
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
|
||||||
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
|
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
|
||||||
else if ((s = strrchr(path, ':')) != NULL) s[1] = '\0';
|
} else if ((s = strrchr(path, ':')) != NULL) {
|
||||||
|
s[1] = '\0';
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +185,7 @@ inline void CBinaryHeapT<Titem_>::RemoveByIdx(int idx)
|
|||||||
}
|
}
|
||||||
/* move parent to the proper place */
|
/* move parent to the proper place */
|
||||||
if (m_size > 0) m_items[gap] = &last;
|
if (m_size > 0) m_items[gap] = &last;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assert(idx == m_size);
|
assert(idx == m_size);
|
||||||
m_size--;
|
m_size--;
|
||||||
}
|
}
|
||||||
|
@ -240,8 +240,11 @@ public:
|
|||||||
{
|
{
|
||||||
if (MaxRawSize() > 0 && num_bytes > 0) {
|
if (MaxRawSize() > 0 && num_bytes > 0) {
|
||||||
assert(num_bytes <= RawSize());
|
assert(num_bytes <= RawSize());
|
||||||
if (num_bytes < RawSize()) RawSizeRef() -= num_bytes;
|
if (num_bytes < RawSize()) {
|
||||||
else RawSizeRef() = 0;
|
RawSizeRef() -= num_bytes;
|
||||||
|
} else {
|
||||||
|
RawSizeRef() = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3397,10 +3397,10 @@ static void FeatureNewName(byte *buf, size_t len)
|
|||||||
* B veh-type see action 0 (as 00..07, + 0A
|
* B veh-type see action 0 (as 00..07, + 0A
|
||||||
* But IF veh-type = 48, then generic text
|
* But IF veh-type = 48, then generic text
|
||||||
* B language-id If bit 6 is set, This is the extended language scheme,
|
* B language-id If bit 6 is set, This is the extended language scheme,
|
||||||
with up to 64 language.
|
* with up to 64 language.
|
||||||
Otherwise, it is a mapping where set bits have meaning
|
* Otherwise, it is a mapping where set bits have meaning
|
||||||
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish
|
* 0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish
|
||||||
Bit 7 set means this is a generic text, not a vehicle one (or else)
|
* Bit 7 set means this is a generic text, not a vehicle one (or else)
|
||||||
* B num-veh number of vehicles which are getting a new name
|
* B num-veh number of vehicles which are getting a new name
|
||||||
* B/W offset number of the first vehicle that gets a new name
|
* B/W offset number of the first vehicle that gets a new name
|
||||||
* Byte : ID of vehicle to change
|
* Byte : ID of vehicle to change
|
||||||
|
@ -1028,8 +1028,7 @@ struct MessageOptionsWindow : Window {
|
|||||||
Dimension d = {0, 0};
|
Dimension d = {0, 0};
|
||||||
for (const StringID *str = message_opt; *str != INVALID_STRING_ID; str++) d = maxdim(d, GetStringBoundingBox(*str));
|
for (const StringID *str = message_opt; *str != INVALID_STRING_ID; str++) d = maxdim(d, GetStringBoundingBox(*str));
|
||||||
size->width = d.width + padding.width + MOS_BUTTON_SPACE; // A bit extra for better looks.
|
size->width = d.width + padding.width + MOS_BUTTON_SPACE; // A bit extra for better looks.
|
||||||
}
|
} else if (widget == WIDGET_NEWSOPT_SOUNDTICKER) {
|
||||||
else if (widget == WIDGET_NEWSOPT_SOUNDTICKER) {
|
|
||||||
size->width += MOS_BUTTON_SPACE; // A bit extra for better looks.
|
size->width += MOS_BUTTON_SPACE; // A bit extra for better looks.
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -138,10 +138,7 @@ static inline bool NPFGetFlag(const AyStarNode *node, NPFNodeFlag flag)
|
|||||||
*/
|
*/
|
||||||
static inline void NPFSetFlag(AyStarNode *node, NPFNodeFlag flag, bool value)
|
static inline void NPFSetFlag(AyStarNode *node, NPFNodeFlag flag, bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
SB(node->user_data[NPF_NODE_FLAGS], flag, 1, value);
|
||||||
SetBit(node->user_data[NPF_NODE_FLAGS], flag);
|
|
||||||
else
|
|
||||||
ClrBit(node->user_data[NPF_NODE_FLAGS], flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* NPF_H */
|
#endif /* NPF_H */
|
||||||
|
@ -491,16 +491,16 @@ static void ReadTTDPatchFlags()
|
|||||||
/* TTDPatch misuses _old_map3 for flags.. read them! */
|
/* TTDPatch misuses _old_map3 for flags.. read them! */
|
||||||
_old_vehicle_multiplier = _old_map3[0];
|
_old_vehicle_multiplier = _old_map3[0];
|
||||||
/* Somehow.... there was an error in some savegames, so 0 becomes 1
|
/* Somehow.... there was an error in some savegames, so 0 becomes 1
|
||||||
and 1 becomes 2. The rest of the values are okay */
|
* and 1 becomes 2. The rest of the values are okay */
|
||||||
if (_old_vehicle_multiplier < 2) _old_vehicle_multiplier++;
|
if (_old_vehicle_multiplier < 2) _old_vehicle_multiplier++;
|
||||||
|
|
||||||
_old_vehicle_names = MallocT<StringID>(_old_vehicle_multiplier * 850);
|
_old_vehicle_names = MallocT<StringID>(_old_vehicle_multiplier * 850);
|
||||||
|
|
||||||
/* TTDPatch increases the Vehicle-part in the middle of the game,
|
/* TTDPatch increases the Vehicle-part in the middle of the game,
|
||||||
so if the multipler is anything else but 1, the assert fails..
|
* so if the multipler is anything else but 1, the assert fails..
|
||||||
bump the assert value so it doesn't!
|
* bump the assert value so it doesn't!
|
||||||
(1 multipler == 850 vehicles
|
* (1 multipler == 850 vehicles
|
||||||
1 vehicle == 128 bytes */
|
* 1 vehicle == 128 bytes */
|
||||||
_bump_assert_value = (_old_vehicle_multiplier - 1) * 850 * 128;
|
_bump_assert_value = (_old_vehicle_multiplier - 1) * 850 * 128;
|
||||||
|
|
||||||
for (uint i = 0; i < 17; i++) { // check tile 0, too
|
for (uint i = 0; i < 17; i++) { // check tile 0, too
|
||||||
|
@ -134,8 +134,7 @@ static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
|
|||||||
const char *VideoDriver_Dedicated::Start(const char * const *parm)
|
const char *VideoDriver_Dedicated::Start(const char * const *parm)
|
||||||
{
|
{
|
||||||
int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
|
int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
|
||||||
if (bpp == 0) _dedicated_video_mem = NULL;
|
_dedicated_video_mem = (bpp == 0) ? NULL : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));
|
||||||
else _dedicated_video_mem = MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));
|
|
||||||
|
|
||||||
_screen.width = _screen.pitch = _cur_resolution.width;
|
_screen.width = _screen.pitch = _cur_resolution.width;
|
||||||
_screen.height = _cur_resolution.height;
|
_screen.height = _cur_resolution.height;
|
||||||
|
Loading…
Reference in New Issue
Block a user