mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
This commit is contained in:
parent
e640900e8a
commit
b290268645
|
@ -9,7 +9,8 @@
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
|
|
||||||
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file) {
|
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
|
||||||
|
{
|
||||||
buffer->pos = -1;
|
buffer->pos = -1;
|
||||||
buffer->file = file;
|
buffer->file = file;
|
||||||
buffer->read = 0;
|
buffer->read = 0;
|
||||||
|
|
|
@ -12,46 +12,42 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/** Main call of the endian_check program
|
/**
|
||||||
|
* Main call of the endian_check program
|
||||||
* @param argc argument count
|
* @param argc argument count
|
||||||
* @param argv arguments themselves
|
* @param argv arguments themselves
|
||||||
* @return exit code */
|
* @return exit code
|
||||||
int main (int argc, char *argv[]) {
|
*/
|
||||||
unsigned char EndianTest[2] = { 1, 0 };
|
int main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
unsigned char endian_test[2] = { 1, 0 };
|
||||||
int force_BE = 0, force_LE = 0, force_PREPROCESSOR = 0;
|
int force_BE = 0, force_LE = 0, force_PREPROCESSOR = 0;
|
||||||
|
|
||||||
if (argc > 1 && strcmp(argv[1], "BE") == 0)
|
if (argc > 1 && strcmp(argv[1], "BE") == 0) force_BE = 1;
|
||||||
force_BE = 1;
|
if (argc > 1 && strcmp(argv[1], "LE") == 0) force_LE = 1;
|
||||||
if (argc > 1 && strcmp(argv[1], "LE") == 0)
|
if (argc > 1 && strcmp(argv[1], "PREPROCESSOR") == 0) force_PREPROCESSOR = 1;
|
||||||
force_LE = 1;
|
|
||||||
if (argc > 1 && strcmp(argv[1], "PREPROCESSOR") == 0)
|
|
||||||
force_PREPROCESSOR = 1;
|
|
||||||
|
|
||||||
printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n");
|
printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n");
|
||||||
|
|
||||||
if (force_LE == 1) {
|
if (force_LE == 1) {
|
||||||
printf("#define TTD_LITTLE_ENDIAN\n");
|
printf("#define TTD_LITTLE_ENDIAN\n");
|
||||||
} else {
|
} else if (force_BE == 1) {
|
||||||
if (force_BE == 1) {
|
|
||||||
printf("#define TTD_BIG_ENDIAN\n");
|
printf("#define TTD_BIG_ENDIAN\n");
|
||||||
} else {
|
} else if (force_PREPROCESSOR == 1) {
|
||||||
if (force_PREPROCESSOR == 1) {
|
/* Support for universal binaries on OSX
|
||||||
/** adding support for universal binaries on OSX
|
|
||||||
* Universal binaries supports both PPC and x86
|
* 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 */
|
* 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("#ifdef __BIG_ENDIAN__\n");
|
||||||
printf("#define TTD_BIG_ENDIAN\n");
|
printf("#define TTD_BIG_ENDIAN\n");
|
||||||
printf("#else\n");
|
printf("#else\n");
|
||||||
printf("#define TTD_LITTLE_ENDIAN\n");
|
printf("#define TTD_LITTLE_ENDIAN\n");
|
||||||
printf("#endif\n");
|
printf("#endif\n");
|
||||||
} else {
|
} else if (*(short*)endian_test == 1 ) {
|
||||||
if ( *(short *) EndianTest == 1 )
|
|
||||||
printf("#define TTD_LITTLE_ENDIAN\n");
|
printf("#define TTD_LITTLE_ENDIAN\n");
|
||||||
else
|
} else {
|
||||||
printf("#define TTD_BIG_ENDIAN\n");
|
printf("#define TTD_BIG_ENDIAN\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("#endif\n");
|
printf("#endif\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -786,7 +786,8 @@ static void DrawStationCoverageText(const AcceptedCargo accepts,
|
||||||
DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144);
|
DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) {
|
void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad)
|
||||||
|
{
|
||||||
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
|
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
|
||||||
AcceptedCargo accepts;
|
AcceptedCargo accepts;
|
||||||
if (tile < MapSize()) {
|
if (tile < MapSize()) {
|
||||||
|
|
|
@ -87,7 +87,8 @@ static const StringID _players_dropdown[] = {
|
||||||
|
|
||||||
static StringID _language_dropdown[NETLANG_COUNT + 1] = {STR_NULL};
|
static StringID _language_dropdown[NETLANG_COUNT + 1] = {STR_NULL};
|
||||||
|
|
||||||
void SortNetworkLanguages() {
|
void SortNetworkLanguages()
|
||||||
|
{
|
||||||
/* Init the strings */
|
/* Init the strings */
|
||||||
if (_language_dropdown[0] == STR_NULL) {
|
if (_language_dropdown[0] == STR_NULL) {
|
||||||
for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i;
|
for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i;
|
||||||
|
@ -1133,7 +1134,8 @@ static void ClientList_None(byte client_no)
|
||||||
|
|
||||||
|
|
||||||
// Help, a action is clicked! What do we do?
|
// Help, a action is clicked! What do we do?
|
||||||
static void HandleClientListPopupClick(byte index, byte clientno) {
|
static void HandleClientListPopupClick(byte index, byte clientno)
|
||||||
|
{
|
||||||
// A click on the Popup of the ClientList.. handle the command
|
// A click on the Popup of the ClientList.. handle the command
|
||||||
if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) {
|
if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) {
|
||||||
_clientlist_proc[index](clientno);
|
_clientlist_proc[index](clientno);
|
||||||
|
@ -1166,7 +1168,8 @@ static bool CheckClientListHeight(Window *w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds the amount of actions in the popup and set the height correct
|
// Finds the amount of actions in the popup and set the height correct
|
||||||
static uint ClientListPopupHeigth() {
|
static uint ClientListPopupHeight()
|
||||||
|
{
|
||||||
int i, num = 0;
|
int i, num = 0;
|
||||||
|
|
||||||
// Find the amount of actions
|
// Find the amount of actions
|
||||||
|
@ -1236,7 +1239,7 @@ static Window *PopupClientList(Window *w, int client_no, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the height */
|
/* Calculate the height */
|
||||||
h = ClientListPopupHeigth();
|
h = ClientListPopupHeight();
|
||||||
|
|
||||||
// Allocate the popup
|
// Allocate the popup
|
||||||
w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
|
w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
|
||||||
|
@ -1486,7 +1489,7 @@ void ShowJoinStatusWindow()
|
||||||
|
|
||||||
static void SendChat(const char *buf, DestType type, int dest)
|
static void SendChat(const char *buf, DestType type, int dest)
|
||||||
{
|
{
|
||||||
if (buf[0] == '\0') return;
|
if (StrEmpty(buf)) return;
|
||||||
if (!_network_server) {
|
if (!_network_server) {
|
||||||
SEND_COMMAND(PACKET_CLIENT_CHAT)((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf);
|
SEND_COMMAND(PACKET_CLIENT_CHAT)((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -270,7 +270,8 @@ static void SlWriteSimpleGamma(uint i)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return how many bytes used to encode a gamma value */
|
/** Return how many bytes used to encode a gamma value */
|
||||||
static inline uint SlGetGammaLength(uint i) {
|
static inline uint SlGetGammaLength(uint i)
|
||||||
|
{
|
||||||
return 1 + (i >= (1 << 7)) + (i >= (1 << 14)) + (i >= (1 << 21));
|
return 1 + (i >= (1 << 7)) + (i >= (1 << 14)) + (i >= (1 << 21));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,8 @@ void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
* @param len Length measured in 1/8ths of a standard wagon.
|
* @param len Length measured in 1/8ths of a standard wagon.
|
||||||
* @return Number of pixels across.
|
* @return Number of pixels across.
|
||||||
*/
|
*/
|
||||||
int WagonLengthToPixels(int len) {
|
int WagonLengthToPixels(int len)
|
||||||
|
{
|
||||||
return (len * _traininfo_vehicle_width) / 8;
|
return (len * _traininfo_vehicle_width) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2480,7 +2480,8 @@ CommandCost CmdChangeServiceInt(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
|
|
||||||
static Rect _old_vehicle_coords;
|
static Rect _old_vehicle_coords;
|
||||||
|
|
||||||
void BeginVehicleMove(Vehicle *v) {
|
void BeginVehicleMove(Vehicle *v)
|
||||||
|
{
|
||||||
_old_vehicle_coords.left = v->left_coord;
|
_old_vehicle_coords.left = v->left_coord;
|
||||||
_old_vehicle_coords.top = v->top_coord;
|
_old_vehicle_coords.top = v->top_coord;
|
||||||
_old_vehicle_coords.right = v->right_coord;
|
_old_vehicle_coords.right = v->right_coord;
|
||||||
|
|
|
@ -134,7 +134,8 @@ static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitViewports() {
|
void InitViewports()
|
||||||
|
{
|
||||||
memset(_viewports, 0, sizeof(_viewports));
|
memset(_viewports, 0, sizeof(_viewports));
|
||||||
_active_viewports = 0;
|
_active_viewports = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,8 @@ struct DebugFileInfo {
|
||||||
|
|
||||||
static uint32 *_crc_table;
|
static uint32 *_crc_table;
|
||||||
|
|
||||||
static void MakeCRCTable(uint32 *table) {
|
static void MakeCRCTable(uint32 *table)
|
||||||
|
{
|
||||||
uint32 crc, poly = 0xEDB88320L;
|
uint32 crc, poly = 0xEDB88320L;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -126,7 +127,8 @@ static void MakeCRCTable(uint32 *table) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32 CalcCRC(byte *data, uint size, uint32 crc) {
|
static uint32 CalcCRC(byte *data, uint size, uint32 crc)
|
||||||
|
{
|
||||||
for (; size > 0; size--) {
|
for (; size > 0; size--) {
|
||||||
crc = ((crc >> 8) & 0x00FFFFFF) ^ _crc_table[(crc ^ *data++) & 0xFF];
|
crc = ((crc >> 8) & 0x00FFFFFF) ^ _crc_table[(crc ^ *data++) & 0xFF];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue