[AStyle] : on most cpp files.
This commit is contained in:
parent
4ec2ba35af
commit
720bc8c831
24 changed files with 156 additions and 133 deletions
|
@ -390,8 +390,8 @@ void COrder_Attack::MoveToTarget(CUnit &unit)
|
|||
return;
|
||||
}
|
||||
// Attacking wall or ground.
|
||||
if (((goal && goal->Type && goal->Type->Wall) || ((!goal)
|
||||
&& (Map.WallOnMap(this->goalPos) || this->Action == UnitActionAttackGround)))
|
||||
if (((goal && goal->Type && goal->Type->Wall)
|
||||
|| (!goal && (Map.WallOnMap(this->goalPos) || this->Action == UnitActionAttackGround)))
|
||||
&& unit.MapDistanceTo(this->goalPos) <= unit.Stats->Variables[ATTACKRANGE_INDEX].Max) {
|
||||
// Reached wall or ground, now attacking it
|
||||
unit.State = 0;
|
||||
|
|
|
@ -57,8 +57,9 @@ static SDL_TimerID timer = NULL;
|
|||
**/
|
||||
static Uint32 OssoKeepBacklightAlive(Uint32 interval, void *)
|
||||
{
|
||||
if (!osso)
|
||||
if (!osso) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
osso_display_state_on(osso);
|
||||
osso_display_blanking_pause(osso);
|
||||
|
@ -79,9 +80,10 @@ static void OssoInitialize(void)
|
|||
} else {
|
||||
application = (char *)calloc(FullGameName.size() + 15, 1);
|
||||
strcpy(application, "org.stratagus.");
|
||||
for (int i = 0; i < FullGameName.size(); i++)
|
||||
for (int i = 0; i < FullGameName.size(); i++) {
|
||||
application[i + 14] = tolower(FullGameName[i]);
|
||||
}
|
||||
}
|
||||
|
||||
osso = osso_initialize(application, VERSION, TRUE, NULL);
|
||||
|
||||
|
|
|
@ -231,8 +231,8 @@ bool UnitTypeCanBeAt(const CUnitType &type, const Vec2i &pos)
|
|||
|
||||
for (int addy = 0; addy < type.TileHeight; ++addy) {
|
||||
for (int addx = 0; addx < type.TileWidth; ++addx) {
|
||||
if (!(Map.Info.IsPointOnMap(pos.x + addx, pos.y + addy)
|
||||
&& !Map.CheckMask(pos.x + addx + index, mask))) {
|
||||
if (Map.Info.IsPointOnMap(pos.x + addx, pos.y + addy) == false
|
||||
|| Map.CheckMask(pos.x + addx + index, mask) == true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,7 +324,6 @@ int SpawnMissile::Cast(CUnit &caster, const SpellType *, CUnit *target, const Ve
|
|||
missile->SourceUnit = &caster;
|
||||
}
|
||||
missile->TargetUnit = target;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1420,8 +1420,9 @@ void CButtonPanel::DoClicked(int button)
|
|||
UI.StatusLine.Clear();
|
||||
ClearCosts();
|
||||
} else if (Selected[0]->Player->CheckLimits(type) == -3)
|
||||
if (GameSounds.NotEnoughFood[Selected[0]->Player->Race].Sound)
|
||||
if (GameSounds.NotEnoughFood[Selected[0]->Player->Race].Sound) {
|
||||
PlayGameSound(GameSounds.NotEnoughFood[Selected[0]->Player->Race].Sound, MaxSampleVolume);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ButtonUpgradeTo: {
|
||||
|
|
|
@ -720,7 +720,8 @@ static void DrawInformations(const CUnit &unit, const CUnitType &type, int x, in
|
|||
//
|
||||
if (NumSelected == 1 && unit.Selected) {
|
||||
const PixelPos center = {x + type.TileWidth *PixelTileSize.x / 2,
|
||||
y + type.TileHeight * PixelTileSize.y / 2};
|
||||
y + type.TileHeight *PixelTileSize.y / 2
|
||||
};
|
||||
|
||||
if (Preference.ShowSightRange) {
|
||||
const int value = stats.Variables[SIGHTRANGE_INDEX].Max;
|
||||
|
|
|
@ -40,43 +40,50 @@ static proto_AttachConsole * func_AttachConsole = NULL;
|
|||
static proto_NtQueryObject *func_NtQueryObject = NULL;
|
||||
|
||||
/// Check if HANDLE is attached to console
|
||||
static int WINAPI_CheckIfConsoleHandle(HANDLE handle) {
|
||||
static int WINAPI_CheckIfConsoleHandle(HANDLE handle)
|
||||
{
|
||||
|
||||
wchar_t filename[MAX_PATH];
|
||||
unsigned long int length = 0;
|
||||
|
||||
// Try to get filename of HANDLE
|
||||
if ( func_NtQueryObject )
|
||||
if (func_NtQueryObject) {
|
||||
func_NtQueryObject(handle, 1, filename, MAX_PATH, &length);
|
||||
}
|
||||
|
||||
// Filename start at position 8
|
||||
if ( length > 8 )
|
||||
if (length > 8) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Try to reopen FILE* from WINAPI HANDLE
|
||||
static void WINAPI_ReopenFileFromHandle(HANDLE handle, FILE * file, const char * mode) {
|
||||
static void WINAPI_ReopenFileFromHandle(HANDLE handle, FILE *file, const char *mode)
|
||||
{
|
||||
|
||||
int fd;
|
||||
FILE *newfile;
|
||||
|
||||
if ( ! handle || handle == INVALID_HANDLE_VALUE )
|
||||
if (! handle || handle == INVALID_HANDLE_VALUE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get file descriptor from HANDLE
|
||||
fd = _open_osfhandle((intptr_t)handle, O_TEXT);
|
||||
|
||||
if ( fd < 0 )
|
||||
if (fd < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get C structure FILE* from file descriptior
|
||||
newfile = _fdopen(fd, mode);
|
||||
|
||||
if ( ! newfile )
|
||||
if (! newfile) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Close current file
|
||||
fclose(file);
|
||||
|
@ -97,27 +104,31 @@ static void WINAPI_ReopenFileFromHandle(HANDLE handle, FILE * file, const char *
|
|||
}
|
||||
|
||||
/// Try to set std HANDLE from FILE*
|
||||
static void WINAPI_SetStdHandleFromFile(int type, FILE * file) {
|
||||
static void WINAPI_SetStdHandleFromFile(int type, FILE *file)
|
||||
{
|
||||
|
||||
int fd;
|
||||
HANDLE handle;
|
||||
|
||||
fd = _fileno(file);
|
||||
|
||||
if ( fd < 0 )
|
||||
if (fd < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
handle = (HANDLE)_get_osfhandle(fd);
|
||||
|
||||
if ( ! handle || handle == INVALID_HANDLE_VALUE )
|
||||
if (! handle || handle == INVALID_HANDLE_VALUE) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetStdHandle(type, handle);
|
||||
|
||||
}
|
||||
|
||||
/// Try attach console of parent process for std input/output in Windows NT, 2000, XP or new
|
||||
static void WINAPI_AttachConsole(void) {
|
||||
static void WINAPI_AttachConsole(void)
|
||||
{
|
||||
|
||||
OSVERSIONINFO osvi;
|
||||
int hasVersion;
|
||||
|
@ -132,29 +143,34 @@ static void WINAPI_AttachConsole(void) {
|
|||
|
||||
hasVersion = GetVersionEx(&osvi);
|
||||
|
||||
if ( ! hasVersion )
|
||||
if (! hasVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
version = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
|
||||
|
||||
// We need Windows 2000 or new
|
||||
if ( version < 0x0500 )
|
||||
if (version < 0x0500) {
|
||||
return;
|
||||
}
|
||||
|
||||
lib_kernel32 = LoadLibrary("kernel32.dll");
|
||||
|
||||
if ( ! lib_kernel32 )
|
||||
if (! lib_kernel32) {
|
||||
return;
|
||||
}
|
||||
|
||||
func_AttachConsole = (proto_AttachConsole *)GetProcAddress(lib_kernel32, "AttachConsole");
|
||||
|
||||
if ( ! func_AttachConsole )
|
||||
if (! func_AttachConsole) {
|
||||
return;
|
||||
}
|
||||
|
||||
lib_ntdll = LoadLibrary("ntdll.dll");
|
||||
|
||||
if ( lib_ntdll )
|
||||
if (lib_ntdll) {
|
||||
func_NtQueryObject = (proto_NtQueryObject *)GetProcAddress(lib_ntdll, "NtQueryObject");
|
||||
}
|
||||
|
||||
// Ignore if HANDLE is not attached console
|
||||
reopen_stdin = WINAPI_CheckIfConsoleHandle(GetStdHandle(STD_INPUT_HANDLE));
|
||||
|
@ -163,23 +179,27 @@ static void WINAPI_AttachConsole(void) {
|
|||
|
||||
attached = func_AttachConsole(-1);
|
||||
|
||||
if ( ! attached )
|
||||
if (! attached) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( reopen_stdin )
|
||||
if (reopen_stdin) {
|
||||
WINAPI_ReopenFileFromHandle(GetStdHandle(STD_INPUT_HANDLE), stdin, "r");
|
||||
else
|
||||
} else {
|
||||
WINAPI_SetStdHandleFromFile(STD_INPUT_HANDLE, stdin);
|
||||
}
|
||||
|
||||
if ( reopen_stdout )
|
||||
if (reopen_stdout) {
|
||||
WINAPI_ReopenFileFromHandle(GetStdHandle(STD_OUTPUT_HANDLE), stdout, "w");
|
||||
else
|
||||
} else {
|
||||
WINAPI_SetStdHandleFromFile(STD_OUTPUT_HANDLE, stdout);
|
||||
}
|
||||
|
||||
if ( reopen_stderr )
|
||||
if (reopen_stderr) {
|
||||
WINAPI_ReopenFileFromHandle(GetStdHandle(STD_ERROR_HANDLE), stderr, "w");
|
||||
else
|
||||
} else {
|
||||
WINAPI_SetStdHandleFromFile(STD_ERROR_HANDLE, stderr);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
std::cin.clear();
|
||||
|
|
Loading…
Reference in a new issue