Changeset 87

Show
Ignore:
Timestamp:
04/27/07 12:49:31 (1 year ago)
Author:
takkaria
Message:

Last commit 'til next week. Just clearing out my local changes before taking a (short) break from code and admin.

  • Use stdbool.h when HAVE_STDBOOL_H is defined.
  • Use uint8_t for byte when available
  • Fix signedness comparisons (util.c, object1.c)
  • Only include <limits.h> once (Kenneth Boyd)
  • Split timeout decrements into its own function, and remove duplicated code (thanks to Kenneth Boyd for pointing this out)
  • Fix warnings in ui.h
  • Fix dependencies for Makefile.inc
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/Makefile.inc

    r79 r87  
    1212 
    1313# Note dependencies 
    14 $(BASEOBJS): $(INCS) 
     14$(BASEOBJS): $(HEADERS) 
    1515$(ZOBJS): $(HDRS) 
    1616BASEOBJS += $(ZOBJS) 
  • trunk/src/dungeon.c

    r73 r87  
    600600} 
    601601 
     602/* 
     603 * Helper for process_world -- decrement p_ptr->timed[] fields. 
     604 */ 
     605static void decrease_timeouts(void) 
     606{ 
     607        int i; 
     608        int timed_list[] = 
     609        { 
     610                TMD_IMAGE, TMD_BLIND, TMD_SINVIS, TMD_SINFRA, TMD_PARALYZED, 
     611                TMD_CONFUSED, TMD_AFRAID, TMD_FAST, TMD_SLOW, TMD_PROTEVIL, 
     612                TMD_INVULN, TMD_HERO, TMD_SHERO, TMD_BLESSED, TMD_SHIELD, 
     613                TMD_OPP_ACID, TMD_OPP_ELEC, TMD_OPP_FIRE, TMD_OPP_COLD, TMD_OPP_POIS 
     614        }; 
     615 
     616        /* Decrement all effects that can be done simply */ 
     617        for (i = 0; i < (int)N_ELEMENTS(timed_list); i++) 
     618        { 
     619                int effect = timed_list[i]; 
     620 
     621                /* Decrement the effect */ 
     622                if (p_ptr->timed[effect]) 
     623                        dec_timed(effect, 1); 
     624        } 
     625 
     626 
     627        /*** Deal with the rest ***/ 
     628 
     629        /* Poison */ 
     630        if (p_ptr->timed[TMD_POISONED]) 
     631        { 
     632                int adjust = (adj_con_fix[p_ptr->stat_ind[A_CON]] + 1); 
     633 
     634                /* Apply some healing */ 
     635                dec_timed(TMD_POISONED, adjust); 
     636        } 
     637 
     638        /* Stun */ 
     639        if (p_ptr->timed[TMD_STUN]) 
     640        { 
     641                int adjust = (adj_con_fix[p_ptr->stat_ind[A_CON]] + 1); 
     642 
     643                /* Apply some healing */ 
     644                dec_timed(TMD_STUN, adjust); 
     645        } 
     646 
     647        /* Cut */ 
     648        if (p_ptr->timed[TMD_CUT]) 
     649        { 
     650                int adjust = (adj_con_fix[p_ptr->stat_ind[A_CON]] + 1); 
     651 
     652                /* Hack -- Truly "mortal" wound */ 
     653                if (p_ptr->timed[TMD_CUT] > 1000) adjust = 0; 
     654 
     655                /* Apply some healing */ 
     656                dec_timed(TMD_CUT, adjust); 
     657        } 
     658 
     659        return; 
     660} 
     661 
    602662 
    603663/* 
     
    639699                        /* Day breaks */ 
    640700                        if (dawn) 
    641                         { 
    642                                 /* Message */ 
    643701                                msg_print("The sun has risen."); 
    644                         } 
    645702 
    646703                        /* Night falls */ 
    647704                        else 
    648                         { 
    649                                 /* Message */ 
    650705                                msg_print("The sun has fallen."); 
    651                         } 
    652706 
    653707                        /* Illuminate */ 
     
    730784                /* Mortal wound or Deep Gash */ 
    731785                if (p_ptr->timed[TMD_CUT] > 200) 
    732                 { 
    733786                        i = 3; 
    734                 } 
    735787 
    736788                /* Severe cut */ 
    737789                else if (p_ptr->timed[TMD_CUT] > 100) 
    738                 { 
    739790                        i = 2; 
    740                 } 
    741791 
    742792                /* Other cuts */ 
    743793                else 
    744                 { 
    745794                        i = 1; 
    746                 } 
    747795 
    748796                /* Take damage */ 
     
    862910        /*** Timeout Various Things ***/ 
    863911 
    864         /* Hack -- Hallucinating */ 
    865         if (p_ptr->timed[TMD_IMAGE]) 
    866         { 
    867                 (void)dec_timed(TMD_IMAGE, 1); 
    868         } 
    869  
    870         /* Blindness */ 
    871         if (p_ptr->timed[TMD_BLIND]) 
    872         { 
    873                 (void)dec_timed(TMD_BLIND, 1); 
    874         } 
    875  
    876         /* Times see-invisible */ 
    877         if (p_ptr->timed[TMD_SINVIS]) 
    878         { 
    879                 (void)dec_timed(TMD_SINVIS, 1); 
    880         } 
    881  
    882         /* Timed infra-vision */ 
    883         if (p_ptr->timed[TMD_SINFRA]) 
    884         { 
    885                 (void)dec_timed(TMD_SINFRA, 1); 
    886         } 
    887  
    888         /* Paralysis */ 
    889         if (p_ptr->timed[TMD_PARALYZED]) 
    890         { 
    891                 (void)dec_timed(TMD_PARALYZED, 1); 
    892         } 
    893  
    894         /* Confusion */ 
    895         if (p_ptr->timed[TMD_CONFUSED]) 
    896         { 
    897                 (void)dec_timed(TMD_CONFUSED, 1); 
    898         } 
    899  
    900         /* Afraid */ 
    901         if (p_ptr->timed[TMD_AFRAID]) 
    902         { 
    903                 (void)dec_timed(TMD_AFRAID, 1); 
    904         } 
    905  
    906         /* Fast */ 
    907         if (p_ptr->timed[TMD_FAST]) 
    908         { 
    909                 (void)dec_timed(TMD_FAST, 1); 
    910         } 
    911  
    912         /* Slow */ 
    913         if (p_ptr->timed[TMD_SLOW]) 
    914         { 
    915                 (void)dec_timed(TMD_SLOW, 1); 
    916         } 
    917  
    918         /* Protection from evil */ 
    919         if (p_ptr->timed[TMD_PROTEVIL]) 
    920         { 
    921                 (void)dec_timed(TMD_PROTEVIL, 1); 
    922         } 
    923  
    924         /* Invulnerability */ 
    925         if (p_ptr->timed[TMD_INVULN]) 
    926         { 
    927                 (void)dec_timed(TMD_INVULN, 1); 
    928         } 
    929  
    930         /* Heroism */ 
    931         if (p_ptr->timed[TMD_HERO]) 
    932         { 
    933                 (void)dec_timed(TMD_HERO, 1); 
    934         } 
    935  
    936         /* Super Heroism */ 
    937         if (p_ptr->timed[TMD_SHERO]) 
    938         { 
    939                 (void)dec_timed(TMD_SHERO, 1); 
    940         } 
    941  
    942         /* Blessed */ 
    943         if (p_ptr->timed[TMD_BLESSED]) 
    944         { 
    945                 (void)dec_timed(TMD_BLESSED, 1); 
    946         } 
    947  
    948         /* Shield */ 
    949         if (p_ptr->timed[TMD_SHIELD]) 
    950         { 
    951                 (void)dec_timed(TMD_SHIELD, 1); 
    952         } 
    953  
    954         /* Oppose Acid */ 
    955         if (p_ptr->timed[TMD_OPP_ACID]) 
    956         { 
    957                 (void)dec_timed(TMD_OPP_ACID, 1); 
    958         } 
    959  
    960         /* Oppose Lightning */ 
    961         if (p_ptr->timed[TMD_OPP_ELEC]) 
    962         { 
    963                 (void)dec_timed(TMD_OPP_ELEC, 1); 
    964         } 
    965  
    966         /* Oppose Fire */ 
    967         if (p_ptr->timed[TMD_OPP_FIRE]) 
    968         { 
    969                 (void)dec_timed(TMD_OPP_FIRE, 1); 
    970         } 
    971  
    972         /* Oppose Cold */ 
    973         if (p_ptr->timed[TMD_OPP_COLD]) 
    974         { 
    975                 (void)dec_timed(TMD_OPP_COLD, 1); 
    976         } 
    977  
    978         /* Oppose Poison */ 
    979         if (p_ptr->timed[TMD_OPP_POIS]) 
    980         { 
    981                 (void)dec_timed(TMD_OPP_POIS, 1); 
    982         } 
    983  
    984  
    985         /*** Poison and Stun and Cut ***/ 
    986  
    987         /* Poison */ 
    988         if (p_ptr->timed[TMD_POISONED]) 
    989         { 
    990                 int adjust = (adj_con_fix[p_ptr->stat_ind[A_CON]] + 1); 
    991  
    992                 /* Apply some healing */ 
    993                 (void)dec_timed(TMD_POISONED, adjust); 
    994         } 
    995  
    996         /* Stun */ 
    997         if (p_ptr->timed[TMD_STUN]) 
    998         { 
    999                 int adjust = (adj_con_fix[p_ptr->stat_ind[A_CON]] + 1); 
    1000  
    1001                 /* Apply some healing */ 
    1002                 (void)dec_timed(TMD_STUN, adjust); 
    1003         } 
    1004  
    1005         /* Cut */ 
    1006         if (p_ptr->timed[TMD_CUT]) 
    1007         { 
    1008                 int adjust = (adj_con_fix[p_ptr->stat_ind[A_CON]] + 1); 
    1009  
    1010                 /* Hack -- Truly "mortal" wound */ 
    1011                 if (p_ptr->timed[TMD_CUT] > 1000) adjust = 0; 
    1012  
    1013                 /* Apply some healing */ 
    1014                 (void)dec_timed(TMD_CUT, adjust); 
    1015         } 
     912        decrease_timeouts(); 
    1016913 
    1017914 
  • trunk/src/h-basic.h

    r82 r87  
    8585typedef const char *cptr; 
    8686typedef int errr; 
    87 typedef unsigned char byte; 
    88 typedef char bool; 
     87 
     88 
     89#if defined(HAVE_STDBOOL_H) 
     90 
     91  #include <stdbool.h> 
     92 
     93  #define TRUE  true 
     94  #define FALSE false 
     95 
     96#else 
     97 
     98  typedef char bool; 
     99 
     100  #undef TRUE 
     101  #undef FALSE 
     102 
     103  #define TRUE   1 
     104  #define FALSE  0 
     105 
     106#endif 
    89107 
    90108 
     
    95113  #include <stdint.h> 
    96114 
     115  typedef uint8_t byte; 
     116 
    97117  typedef uint16_t u16b; 
    98118  typedef int16_t s16b; 
     
    104124 
    105125  /* Try hacks instead (not guaranteed to work) */ 
     126  typedef unsigned char byte; 
    106127  typedef signed short s16b; 
    107128  typedef unsigned short u16b; 
     
    128149 
    129150 
    130 /* Define "TRUE" and "FALSE" */ 
    131 #undef TRUE 
    132 #undef FALSE 
    133  
    134 #define TRUE    1 
    135 #define FALSE   0 
    136  
    137  
    138151 
    139152/*** Basic math macros ***/ 
  • trunk/src/h-config.h

    r44 r87  
    1313 * should not be defined by the user. 
    1414 */ 
    15  
    16 #include <limits.h> 
    1715 
    1816 
  • trunk/src/main-gcu.c

    r82 r87  
    5858 */ 
    5959#ifdef USE_NCURSES 
     60# if defined(HAVE_STDBOOL_H) 
     61#  define NCURSES_ENABLE_STDBOOL_H 0 
     62# endif 
     63 
    6064# include <ncurses.h> 
    6165#else 
  • trunk/src/object1.c

    r82 r87  
    170170 
    171171                wordlen = make_word(RANDNAME_SCROLL, 2, 8, end, 24); 
    172                 while (titlelen + wordlen < (sizeof(scroll_adj[0]) - 1)) 
     172                while (titlelen + wordlen < (int)(sizeof(scroll_adj[0]) - 1)) 
    173173                { 
    174174                        end[wordlen] = ' '; 
  • trunk/src/ui.h

    r72 r87  
    141141typedef struct menu_skin menu_skin; 
    142142typedef struct menu_iter menu_iter; 
    143 typedef enum skin_id skin_id; 
    144 typedef enum menu_iter_id menu_iter_id; 
     143 
    145144 
    146145/* 
     
    230229 
    231230/* Identifier for the type of menu layout to use */ 
    232 enum skin_id { 
     231typedef enum 
     232
    233233        /* Skins */ 
    234234        MN_SCROLL       = 0x0000, /* Ordinary scrollable single-column list */ 
     
    237237        MN_KEY_ONLY = 0x0004, /* No display */ 
    238238        MN_USER         = 0x0005  /* Anonymous, user defined. */ 
    239 }
     239} skin_id
    240240 
    241241/* Class functions for menu layout */ 
     
    254254 
    255255/* Identifiers for canned row iterator implementations */ 
    256 enum menu_iter_id { 
     256typedef enum 
     257
    257258        MN_ACT          = 0x1, /* selectable menu with per-row flags (see below) */ 
    258259        MN_EVT          = 0x2, /* simple event action list */ 
    259260        MN_STRING       = 0x3  /* display an array of strings for selection */ 
    260 }; 
     261} menu_iter_id; 
     262 
    261263 
    262264/* Class functions for menu row-level accessor functions */ 
  • trunk/src/util.c

    r69 r87  
    381381                case '#': 
    382382                        /* Read key code */ 
    383                         for (j = 0; *str && (*str != '\r') && (j < sizeof(key_code) - 1); j++) 
     383                        for (j = 0; *str && (*str != '\r') && (j < (int)sizeof(key_code) - 1); j++) 
    384384                                key_code[j] = *str++; 
    385385                        key_code[j] = '\0';