[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/ui button_checks.c icons.c
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src/ui button_checks.c icons.c |
Date: |
Mon, 29 Sep 2003 11:41:30 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/09/29 11:41:30
Modified files:
src/ui : button_checks.c icons.c
Log message:
Cleanup
Patches:
Index: stratagus/src/ui/button_checks.c
diff -u stratagus/src/ui/button_checks.c:1.10
stratagus/src/ui/button_checks.c:1.11
--- stratagus/src/ui/button_checks.c:1.10 Fri Aug 8 06:16:44 2003
+++ stratagus/src/ui/button_checks.c Mon Sep 29 11:41:28 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: button_checks.c,v 1.10 2003/08/08 10:16:44 martinxyz Exp $
+// $Id: button_checks.c,v 1.11 2003/09/29 15:41:28 jsalmon3 Exp $
//@{
@@ -69,7 +69,8 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckTrue(const Unit* unit __attribute__((unused)),const
ButtonAction* button __attribute__((unused)))
+global int ButtonCheckTrue(const Unit* unit __attribute__((unused)),
+ const ButtonAction* button __attribute__((unused)))
{
return 1;
}
@@ -82,7 +83,8 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckFalse(const Unit* unit __attribute__((unused)),const
ButtonAction* button __attribute__((unused)))
+global int ButtonCheckFalse(const Unit* unit __attribute__((unused)),
+ const ButtonAction* button __attribute__((unused)))
{
return 0;
}
@@ -94,9 +96,9 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckUpgrade(const Unit* unit,const ButtonAction* button)
+global int ButtonCheckUpgrade(const Unit* unit, const ButtonAction* button)
{
- return UpgradeIdentAllowed(unit->Player,button->AllowStr)=='R';
+ return UpgradeIdentAllowed(unit->Player, button->AllowStr) == 'R';
}
/**
@@ -106,17 +108,17 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckUnitsOr(const Unit* unit,const ButtonAction* button)
+global int ButtonCheckUnitsOr(const Unit* unit, const ButtonAction* button)
{
char* buf;
const char* s;
Player* player;
- player=unit->Player;
- buf=alloca(strlen(button->AllowStr)+1);
- strcpy(buf,button->AllowStr);
- for( s=strtok(buf,","); s; s=strtok(NULL,",") ) {
- if( HaveUnitTypeByIdent(player,s) ) {
+ player = unit->Player;
+ buf = alloca(strlen(button->AllowStr) + 1);
+ strcpy(buf, button->AllowStr);
+ for (s = strtok(buf, ","); s; s = strtok(NULL, ",")) {
+ if (HaveUnitTypeByIdent(player, s)) {
return 1;
}
}
@@ -130,17 +132,17 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckUnitsAnd(const Unit* unit,const ButtonAction* button)
+global int ButtonCheckUnitsAnd(const Unit* unit, const ButtonAction* button)
{
char* buf;
const char* s;
Player* player;
- player=unit->Player;
- buf=alloca(strlen(button->AllowStr)+1);
- strcpy(buf,button->AllowStr);
- for( s=strtok(buf,","); s; s=strtok(NULL,",") ) {
- if( !HaveUnitTypeByIdent(player,s) ) {
+ player = unit->Player;
+ buf = alloca(strlen(button->AllowStr) + 1);
+ strcpy(buf, button->AllowStr);
+ for (s = strtok(buf, ","); s; s = strtok(NULL, ",")) {
+ if (!HaveUnitTypeByIdent(player, s)) {
return 0;
}
}
@@ -157,9 +159,10 @@
**
** NOTE: this check could also be moved into intialisation.
*/
-global int ButtonCheckNetwork(const Unit* unit __attribute__((unused)),const
ButtonAction* button __attribute__((unused)))
+global int ButtonCheckNetwork(const Unit* unit __attribute__((unused)),
+ const ButtonAction* button __attribute__((unused)))
{
- return NetworkFildes!=-1;
+ return NetworkFildes != -1;
}
/**
@@ -171,9 +174,10 @@
**
** NOTE: this check could also be moved into intialisation.
*/
-global int ButtonCheckNoNetwork(const Unit* unit __attribute__((unused)),const
ButtonAction* button __attribute__((unused)))
+global int ButtonCheckNoNetwork(const Unit* unit __attribute__((unused)),
+ const ButtonAction* button __attribute__((unused)))
{
- return NetworkFildes==-1;
+ return NetworkFildes == -1;
}
/**
@@ -184,12 +188,13 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckNoWork(const Unit* unit,const ButtonAction* button
__attribute__((unused)))
+global int ButtonCheckNoWork(const Unit* unit,
+ const ButtonAction* button __attribute__((unused)))
{
- return unit->Type->Building
- && unit->Orders[0].Action != UnitActionTrain
- && unit->Orders[0].Action != UnitActionUpgradeTo
- && unit->Orders[0].Action != UnitActionResearch;
+ return unit->Type->Building &&
+ unit->Orders[0].Action != UnitActionTrain &&
+ unit->Orders[0].Action != UnitActionUpgradeTo &&
+ unit->Orders[0].Action != UnitActionResearch;
}
/**
@@ -199,11 +204,12 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckNoResearch(const Unit* unit,const ButtonAction* button
__attribute__((unused)))
+global int ButtonCheckNoResearch(const Unit* unit,
+ const ButtonAction* button __attribute__((unused)))
{
- return unit->Type->Building
- && unit->Orders[0].Action != UnitActionUpgradeTo
- && unit->Orders[0].Action != UnitActionResearch;
+ return unit->Type->Building &&
+ unit->Orders[0].Action != UnitActionUpgradeTo &&
+ unit->Orders[0].Action != UnitActionResearch;
}
/**
@@ -214,12 +220,12 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckUpgradeTo(const Unit* unit,const ButtonAction* button)
+global int ButtonCheckUpgradeTo(const Unit* unit, const ButtonAction* button)
{
- if ( unit->Orders[0].Action != UnitActionStill ) {
+ if (unit->Orders[0].Action != UnitActionStill) {
return 0;
}
- return CheckDependByIdent(unit->Player,button->ValueStr);
+ return CheckDependByIdent(unit->Player, button->ValueStr);
}
/**
@@ -229,7 +235,8 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckAttack(const Unit* unit,const ButtonAction* button
__attribute__((unused)))
+global int ButtonCheckAttack(const Unit* unit,
+ const ButtonAction* button __attribute__((unused)))
{
return unit->Type->CanAttack;
}
@@ -241,18 +248,18 @@
** @param button Pointer to button to check/enable.
** @return True if enabled.
*/
-global int ButtonCheckResearch(const Unit* unit,const ButtonAction* button)
+global int ButtonCheckResearch(const Unit* unit, const ButtonAction* button)
{
- if ( !ButtonCheckNoWork( unit, button ) ) { // don't show any if
working
+ if (!ButtonCheckNoWork(unit, button)) { // don't show any if working
return 0;
}
// check if allowed
- if ( !CheckDependByIdent( unit->Player, button->ValueStr ) ) {
+ if (!CheckDependByIdent(unit->Player, button->ValueStr)) {
return 0;
}
- if ( !strncmp( button->ValueStr,"upgrade-", 8 ) &&
- UpgradeIdentAllowed( unit->Player,button->ValueStr )!='A' ) {
+ if (!strncmp(button->ValueStr, "upgrade-", 8) &&
+ UpgradeIdentAllowed(unit->Player, button->ValueStr) != 'A') {
return 0;
}
return 1;
@@ -267,11 +274,11 @@
** @return True if enabled.
*/
global int ButtonCheckSingleResearch(const Unit* unit,
- const ButtonAction* button)
+ const ButtonAction* button)
{
- if( ButtonCheckResearch(unit,button) ) {
- if( !unit->Player->UpgradeTimers.Upgrades[
- UpgradeIdByIdent(button->ValueStr) ] ) {
+ if (ButtonCheckResearch(unit, button)) {
+ if (!unit->Player->UpgradeTimers.Upgrades[
+ UpgradeIdByIdent(button->ValueStr)]) {
return 1;
}
}
Index: stratagus/src/ui/icons.c
diff -u stratagus/src/ui/icons.c:1.45 stratagus/src/ui/icons.c:1.46
--- stratagus/src/ui/icons.c:1.45 Sun Aug 17 11:57:08 2003
+++ stratagus/src/ui/icons.c Mon Sep 29 11:41:29 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: icons.c,v 1.45 2003/08/17 15:57:08 n0body Exp $
+// $Id: icons.c,v 1.46 2003/09/29 15:41:29 jsalmon3 Exp $
//@{
@@ -76,9 +76,9 @@
#else
-local hashtable(IconFile*,31) IconFileHash;/// lookup table for icon file names
+local hashtable(IconFile*, 31) IconFileHash;/// lookup table for icon file
names
-local hashtable(Icon*,61) IconHash; /// lookup table for icon names
+local hashtable(Icon*, 61) IconHash; /// lookup table for icon names
#endif
@@ -98,8 +98,8 @@
** @param index Index into file.
** @param file Graphic file containing the icons.
*/
-local void AddIcon(const char *ident, const char *tileset,
- int index, int width, int height, const char *file)
+local void AddIcon(const char* ident, const char* tileset,
+ int index, int width, int height, const char* file)
{
void** ptr;
char* str;
@@ -116,7 +116,7 @@
iconfile = malloc(sizeof(IconFile));
iconfile->FileName = strdup(file);
iconfile->Sprite = NULL;
- *(IconFile **) hash_add(IconFileHash, iconfile->FileName) = iconfile;
+ *(IconFile**)hash_add(IconFileHash, iconfile->FileName) = iconfile;
}
//
@@ -127,7 +127,7 @@
} else {
str = strdup(ident);
}
- ptr = (void **)hash_find(IconHash, str);
+ ptr = (void**)hash_find(IconHash, str);
if (ptr && *ptr) {
DebugLevel0Fn("FIXME: Icon already defined `%s,%s'\n" _C_
ident _C_ tileset);
@@ -146,7 +146,7 @@
icon->Sprite = NULL;
- *(Icon **) hash_add(IconHash, str) = icon;
+ *(Icon**)hash_add(IconHash, str) = icon;
free(str);
}
Icons = realloc(Icons, sizeof(Icon *) * (NumIcons + 1));
@@ -166,9 +166,9 @@
// Add icons of the current tileset, with shortcut to hash.
//
for (i = 0; i < NumIcons; ++i) {
- if (Icons[i]->Tileset
- && !strcmp(Icons[i]->Tileset, TheMap.TerrainName)) {
- *(Icon **) hash_add(IconHash, Icons[i]->Ident) = Icons[i];
+ if (Icons[i]->Tileset &&
+ !strcmp(Icons[i]->Tileset, TheMap.TerrainName)) {
+ *(Icon**)hash_add(IconHash, Icons[i]->Ident) = Icons[i];
}
}
@@ -181,7 +181,7 @@
id = IconByIdent(IconAliases[i * 2 + 1]);
DebugCheck(id == NoIcon);
- *(Icon **) hash_add(IconHash, IconAliases[i * 2 + 0]) = id;
+ *(Icon**)hash_add(IconHash, IconAliases[i * 2 + 0]) = id;
}
}
@@ -199,7 +199,7 @@
for (i = 0; i < NumIcons; ++i) {
Icon* icon;
- icon=Icons[i];
+ icon = Icons[i];
// If tileset only fitting tileset.
if (!icon->Tileset || !strcmp(icon->Tileset, TheMap.TerrainName)) {
// File already loaded?
@@ -213,14 +213,14 @@
ShowLoadProgress("\tIcons %s\n", file);
icon->File->Sprite = LoadSprite(file,IconWidth,IconHeight);
#ifdef USE_OPENGL
- MakeTexture(icon->File->Sprite,icon->File->Sprite->Width,
- icon->File->Sprite->Height);
+ MakeTexture(icon->File->Sprite, icon->File->Sprite->Width,
+ icon->File->Sprite->Height);
#endif
}
icon->Sprite = icon->File->Sprite;
if (icon->Index >= (unsigned)icon->Sprite->NumFrames) {
- DebugLevel0Fn("Invalid icon index: %s - %d\n"
- _C_ icon->Ident _C_ icon->Index);
+ DebugLevel0Fn("Invalid icon index: %s - %d\n" _C_
+ icon->Ident _C_ icon->Index);
icon->Index = 0;
}
}
@@ -240,7 +240,7 @@
//
// Mapping the original icon numbers in puds to our internal strings
//
- if ((ptr = (void **)IconWcNames)) { // Free all old names
+ if ((ptr = (void**)IconWcNames)) { // Free all old names
while (*ptr) {
free(*ptr++);
}
@@ -270,7 +270,7 @@
free(Icons[i]->Ident);
- ptr = (void **)hash_find(IconFileHash, Icons[i]->File->FileName);
+ ptr = (void**)hash_find(IconFileHash, Icons[i]->File->FileName);
if (ptr && *ptr) {
table[n++] = *ptr;
*ptr = NULL;
@@ -340,7 +340,7 @@
*/
global const char* IdentOfIcon(const Icon* icon)
{
- DebugCheck( !icon );
+ DebugCheck(!icon);
return icon->Ident;
}
@@ -429,7 +429,7 @@
int i;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: icons $Id: icons.c,v 1.45 2003/08/17 15:57:08
n0body Exp $\n\n");
+ CLprintf(file, ";;; MODULE: icons $Id: icons.c,v 1.46 2003/09/29 15:41:29
jsalmon3 Exp $\n\n");
//
// Mapping the original icon numbers in puds to our internal strings
@@ -483,7 +483,9 @@
char* str;
int n;
- IfDebug( n = 0; );
+#ifdef DEBUG
+ n = 0;
+#endif
// Identifier
@@ -540,7 +542,9 @@
int height;
int index;
- IfDebug(index = width = height = 0;);
+#ifdef DEBUG
+ index = width = height = 0;
+#endif
filename = NULL;
tileset = NULL;
@@ -572,7 +576,7 @@
list = gh_cdr(list);
}
- DebugCheck( !filename || !width || !height);
+ DebugCheck(!filename || !width || !height);
AddIcon(ident, tileset, index, width, height, filename);
free(ident);
@@ -591,12 +595,12 @@
** @param alias Icon alias name.
** @param icon Original icon.
*/
-local SCM CclDefineIconAlias(SCM alias,SCM icon)
+local SCM CclDefineIconAlias(SCM alias, SCM icon)
{
- IconAliases=realloc(IconAliases,sizeof(char*)*2*(NumIconAliases+1));
- IconAliases[NumIconAliases*2+0]=gh_scm2newstr(alias,NULL);
- IconAliases[NumIconAliases*2+1]=gh_scm2newstr(icon,NULL);
- NumIconAliases++;
+ IconAliases = realloc(IconAliases, sizeof(char*) * 2 * (NumIconAliases +
1));
+ IconAliases[NumIconAliases * 2 + 0] = gh_scm2newstr(alias, NULL);
+ IconAliases[NumIconAliases * 2 + 1] = gh_scm2newstr(icon, NULL);
+ ++NumIconAliases;
return SCM_UNSPECIFIED;
}
@@ -611,8 +615,8 @@
int i;
char** cp;
- if( (cp=IconWcNames) ) { // Free all old names
- while( *cp ) {
+ if ((cp = IconWcNames)) { // Free all old names
+ while (*cp) {
free(*cp++);
}
free(IconWcNames);
@@ -621,13 +625,13 @@
//
// Get new table.
//
- i=gh_length(list);
- IconWcNames=cp=malloc((i+1)*sizeof(char*));
- while( i-- ) {
- *cp++=gh_scm2newstr(gh_car(list),NULL);
- list=gh_cdr(list);
+ i = gh_length(list);
+ IconWcNames = cp = malloc((i + 1) * sizeof(char*));
+ while (i--) {
+ *cp++ = gh_scm2newstr(gh_car(list), NULL);
+ list = gh_cdr(list);
}
- *cp=NULL;
+ *cp = NULL;
return SCM_UNSPECIFIED;
}
@@ -639,10 +643,10 @@
** @param width Width of icon.
** @param height Height of icon.
*/
-local SCM CclSetIconSize(SCM width,SCM height)
+local SCM CclSetIconSize(SCM width, SCM height)
{
- IconWidth=gh_scm2int(width);
- IconHeight=gh_scm2int(height);
+ IconWidth = gh_scm2int(width);
+ IconHeight = gh_scm2int(height);
return SCM_UNSPECIFIED;
}
@@ -654,7 +658,7 @@
*/
local SCM CclSetIconsPerRow(SCM icons)
{
- IconsPerRow=gh_scm2int(icons);
+ IconsPerRow = gh_scm2int(icons);
return SCM_UNSPECIFIED;
}
@@ -666,15 +670,15 @@
*/
global void IconCclRegister(void)
{
- gh_new_procedureN("define-old-icon",CclDefineOldIcon);
- gh_new_procedureN("define-icon",CclDefineIcon);
- gh_new_procedure2_0("define-icon-alias",CclDefineIconAlias);
+ gh_new_procedureN("define-old-icon", CclDefineOldIcon);
+ gh_new_procedureN("define-icon", CclDefineIcon);
+ gh_new_procedure2_0("define-icon-alias", CclDefineIconAlias);
- gh_new_procedureN("define-icon-wc-names",CclDefineIconWcNames);
+ gh_new_procedureN("define-icon-wc-names", CclDefineIconWcNames);
// FIXME: can be removed:
- gh_new_procedure2_0("set-icon-size!",CclSetIconSize);
- gh_new_procedure1_0("set-icons-per-row!",CclSetIconsPerRow);
+ gh_new_procedure2_0("set-icon-size!", CclSetIconSize);
+ gh_new_procedure1_0("set-icons-per-row!", CclSetIconsPerRow);
}
//@}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/ui button_checks.c icons.c,
Jimmy Salmon <=