[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;
|
||||
|
|
|
@ -397,7 +397,7 @@ static int CclDefineAiHelper(lua_State *l)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static CAiType *GetAiTypesByName(const char* name)
|
||||
static CAiType *GetAiTypesByName(const char *name)
|
||||
{
|
||||
for (size_t i = 0; i < AiTypes.size(); ++i) {
|
||||
CAiType *ait = AiTypes[i];
|
||||
|
@ -425,7 +425,7 @@ static int CclDefineAi(lua_State *l)
|
|||
CAiType *aitype = new CAiType;
|
||||
|
||||
// AI Name
|
||||
const char* aiName = LuaToString(l, 1);
|
||||
const char *aiName = LuaToString(l, 1);
|
||||
aitype->Name = aiName;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -1273,7 +1273,7 @@ static int CclDefineAiPlayer(lua_State *l)
|
|||
++j;
|
||||
|
||||
if (!strcmp(value, "ai-type")) {
|
||||
const char* aiName = LuaToString(l, j + 1);
|
||||
const char *aiName = LuaToString(l, j + 1);
|
||||
CAiType *ait = GetAiTypesByName(aiName);
|
||||
if (ait == NULL) {
|
||||
lua_pushfstring(l, "ai-type not found: %s", aiName);
|
||||
|
@ -1299,7 +1299,7 @@ static int CclDefineAiPlayer(lua_State *l)
|
|||
|
||||
for (int k = 1; k < subargs; ++k) {
|
||||
lua_rawgeti(l, j + 1, k + 1);
|
||||
const char* value = LuaToString(l, -1);
|
||||
const char *value = LuaToString(l, -1);
|
||||
lua_pop(l, 1);
|
||||
++k;
|
||||
if (!strcmp(value, "complete")) {
|
||||
|
|
|
@ -99,7 +99,7 @@ static int ParseAnimFlags(CUnit &unit, const char *parseflag)
|
|||
const int destx = ParseAnimInt(&unit, this->destXStr.c_str());
|
||||
const int desty = ParseAnimInt(&unit, this->destYStr.c_str());
|
||||
const int flags = ParseAnimFlags(unit, this->flagsStr.c_str());
|
||||
const CUnit *goal = flags & ANIM_SM_RELTARGET ? unit.CurrentOrder()->GetGoal(): &unit;
|
||||
const CUnit *goal = flags & ANIM_SM_RELTARGET ? unit.CurrentOrder()->GetGoal() : &unit;
|
||||
PixelPos start;
|
||||
PixelPos dest;
|
||||
|
||||
|
|
|
@ -30,17 +30,17 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
/**
|
||||
** Need init function for beos.
|
||||
**
|
||||
** @param argc Number of command line argurments
|
||||
*/
|
||||
void beos_init(int argc, char** argv)
|
||||
{
|
||||
BPath path( argv[0] );
|
||||
path.GetParent( &path );
|
||||
chdir( path.Path() );
|
||||
}
|
||||
/**
|
||||
** Need init function for beos.
|
||||
**
|
||||
** @param argc Number of command line argurments
|
||||
*/
|
||||
void beos_init(int argc, char **argv)
|
||||
{
|
||||
BPath path(argv[0]);
|
||||
path.GetParent(&path);
|
||||
chdir(path.Path());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
static osso_context_t * osso = NULL;
|
||||
static osso_context_t *osso = NULL;
|
||||
static SDL_TimerID timer = NULL;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -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);
|
||||
|
@ -72,15 +73,16 @@ static Uint32 OssoKeepBacklightAlive(Uint32 interval, void *)
|
|||
**/
|
||||
static void OssoInitialize(void)
|
||||
{
|
||||
char * application;
|
||||
char *application;
|
||||
|
||||
if (FullGameName.empty()) {
|
||||
application = strdup("org.stratagus");
|
||||
} else {
|
||||
application = (char *)calloc(FullGameName.size() + 15, 1);
|
||||
strcpy(application, "org.stratagus.");
|
||||
for (int i = 0; i < FullGameName.size(); i++)
|
||||
application[i+14] = tolower(FullGameName[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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -839,12 +839,12 @@ static int CclSetPlayerData(lua_State *l)
|
|||
const std::string res = LuaToString(l, 3);
|
||||
const int resId = GetResourceIdByName(l, res.c_str());
|
||||
p->SetResource(resId, LuaToNumber(l, 4), true);
|
||||
// } else if (!strcmp(data, "UnitTypesCount")) {
|
||||
// } else if (!strcmp(data, "AiEnabled")) {
|
||||
// } else if (!strcmp(data, "TotalNumUnits")) {
|
||||
// } else if (!strcmp(data, "NumBuildings")) {
|
||||
// } else if (!strcmp(data, "Supply")) {
|
||||
// } else if (!strcmp(data, "Demand")) {
|
||||
// } else if (!strcmp(data, "UnitTypesCount")) {
|
||||
// } else if (!strcmp(data, "AiEnabled")) {
|
||||
// } else if (!strcmp(data, "TotalNumUnits")) {
|
||||
// } else if (!strcmp(data, "NumBuildings")) {
|
||||
// } else if (!strcmp(data, "Supply")) {
|
||||
// } else if (!strcmp(data, "Demand")) {
|
||||
} else if (!strcmp(data, "UnitLimit")) {
|
||||
p->UnitLimit = LuaToNumber(l, 3);
|
||||
} else if (!strcmp(data, "BuildingLimit")) {
|
||||
|
|
|
@ -324,7 +324,6 @@ int SpawnMissile::Cast(CUnit &caster, const SpellType *, CUnit *target, const Ve
|
|||
missile->SourceUnit = &caster;
|
||||
}
|
||||
missile->TargetUnit = target;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -352,7 +352,7 @@ int CPopupContentTypeCosts::GetWidth(const ButtonAction *button, int *Costs) con
|
|||
|
||||
for (unsigned int i = 1; i < MaxCosts; ++i) {
|
||||
if (Costs[i]) {
|
||||
if(UI.Resources[i].IconWidth != -1) {
|
||||
if (UI.Resources[i].IconWidth != -1) {
|
||||
popupWidth += (UI.Resources[i].IconWidth + 5);
|
||||
} else {
|
||||
const CGraphic *G = UI.Resources[i].G;
|
||||
|
@ -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: {
|
||||
|
|
|
@ -719,8 +719,9 @@ static void DrawInformations(const CUnit &unit, const CUnitType &type, int x, in
|
|||
// For debug draw sight, react and attack range!
|
||||
//
|
||||
if (NumSelected == 1 && unit.Selected) {
|
||||
const PixelPos center = {x + type.TileWidth * PixelTileSize.x / 2,
|
||||
y + type.TileHeight * PixelTileSize.y / 2};
|
||||
const PixelPos center = {x + type.TileWidth *PixelTileSize.x / 2,
|
||||
y + type.TileHeight *PixelTileSize.y / 2
|
||||
};
|
||||
|
||||
if (Preference.ShowSightRange) {
|
||||
const int value = stats.Variables[SIGHTRANGE_INDEX].Max;
|
||||
|
|
|
@ -56,7 +56,7 @@ void CUnitPtr::Reset()
|
|||
unit = NULL;
|
||||
}
|
||||
|
||||
CUnitPtr& CUnitPtr::operator= (CUnit *u)
|
||||
CUnitPtr &CUnitPtr::operator= (CUnit *u)
|
||||
{
|
||||
if (this->unit != u) {
|
||||
if (u) {
|
||||
|
|
|
@ -36,47 +36,54 @@ static HINSTANCE lib_ntdll = NULL;
|
|||
typedef int FAR WINAPI proto_AttachConsole(int);
|
||||
typedef int FAR WINAPI proto_NtQueryObject(HANDLE, int, void *, unsigned long int, unsigned long int *);
|
||||
|
||||
static proto_AttachConsole * func_AttachConsole = NULL;
|
||||
static proto_NtQueryObject * func_NtQueryObject = NULL;
|
||||
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;
|
||||
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);
|
||||
|
@ -87,7 +94,7 @@ static void WINAPI_ReopenFileFromHandle(HANDLE handle, FILE * file, const char *
|
|||
setvbuf(file, NULL, _IONBF, 0);
|
||||
|
||||
// If stdout/stderr write 2 empty lines to cmd console
|
||||
if ( ! fixmode && strcmp(mode, "w") == 0 ) {
|
||||
if (! fixmode && strcmp(mode, "w") == 0) {
|
||||
|
||||
fprintf(file, "\n\n");
|
||||
fixmode = 1;
|
||||
|
@ -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;
|
||||
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");
|
||||
func_AttachConsole = (proto_AttachConsole *)GetProcAddress(lib_kernel32, "AttachConsole");
|
||||
|
||||
if ( ! func_AttachConsole )
|
||||
if (! func_AttachConsole) {
|
||||
return;
|
||||
}
|
||||
|
||||
lib_ntdll = LoadLibrary("ntdll.dll");
|
||||
|
||||
if ( lib_ntdll )
|
||||
func_NtQueryObject = (proto_NtQueryObject*)GetProcAddress(lib_ntdll, "NtQueryObject");
|
||||
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