cast int64 to smaller types (trunk only)

The devteam feedback was to place casts in the code
in question.

This puts explicit casts on some code that was being
compiled into 'int64' then stuffed into smaller types with
VC2005.
This commit is contained in:
nethack.allison
2006-07-11 12:38:16 +00:00
parent 7394b0a353
commit 96c6163019
11 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -212,7 +212,7 @@ register boolean mod;
if (otmp && *name) if (otmp && *name)
for (a = artilist+1; a->otyp; a++) for (a = artilist+1; a->otyp; a++)
if (a->otyp == otmp->otyp && !strcmp(a->name, name)) { if (a->otyp == otmp->otyp && !strcmp(a->name, name)) {
register int m = a - artilist; register int m = (int)(a - artilist);
otmp->oartifact = (char)(mod ? m : 0); otmp->oartifact = (char)(mod ? m : 0);
otmp->age = 0; otmp->age = 0;
if(otmp->otyp == RIN_INCREASE_DAMAGE) if(otmp->otyp == RIN_INCREASE_DAMAGE)
+1 -1
View File
@@ -327,7 +327,7 @@ char *defquery;
char *dop = index(disclosure_options, category); char *dop = index(disclosure_options, category);
if (dop && defquery) { if (dop && defquery) {
idx = dop - disclosure_options; idx = (int)(dop - disclosure_options);
if (idx < 0 || idx > (NUM_DISCLOSURE_OPTIONS - 1)) { if (idx < 0 || idx > (NUM_DISCLOSURE_OPTIONS - 1)) {
impossible( impossible(
"should_query_disclose_option: bad disclosure index %d %c", "should_query_disclose_option: bad disclosure index %d %c",
+1 -1
View File
@@ -957,7 +957,7 @@ topologize(croom)
register struct mkroom *croom; register struct mkroom *croom;
#endif #endif
{ {
register int x, y, roomno = (croom - rooms) + ROOMOFFSET; register int x, y, roomno = (int)((croom - rooms) + ROOMOFFSET);
register int lowx = croom->lx, lowy = croom->ly; register int lowx = croom->lx, lowy = croom->ly;
register int hix = croom->hx, hiy = croom->hy; register int hix = croom->hx, hiy = croom->hy;
#ifdef SPECIALIZATION #ifdef SPECIALIZATION
+1 -1
View File
@@ -534,7 +534,7 @@ register const char *s;
char *ep = getenv("SPLEVTYPE"); /* not nh_getenv */ char *ep = getenv("SPLEVTYPE"); /* not nh_getenv */
if (ep) { if (ep) {
/* rindex always succeeds due to code in prior block */ /* rindex always succeeds due to code in prior block */
int len = (rindex(protofile, '-') - protofile) + 1; int len = (int)((rindex(protofile, '-') - protofile) + 1);
while (ep && *ep) { while (ep && *ep) {
if (!strncmp(ep, protofile, len)) { if (!strncmp(ep, protofile, len)) {
+3 -3
View File
@@ -227,7 +227,7 @@ struct mkroom *sroom;
struct monst *mon; struct monst *mon;
register int sx,sy,i; register int sx,sy,i;
int sh, tx, ty, goldlim, type = sroom->rtype; int sh, tx, ty, goldlim, type = sroom->rtype;
int rmno = (sroom - rooms) + ROOMOFFSET; int rmno = (int)((sroom - rooms) + ROOMOFFSET);
coord mm; coord mm;
#ifdef GCC_WARN #ifdef GCC_WARN
@@ -518,7 +518,7 @@ mktemple()
* In temples, shrines are blessed altars * In temples, shrines are blessed altars
* located in the center of the room * located in the center of the room
*/ */
shrine_spot = shrine_pos((sroom - rooms) + ROOMOFFSET); shrine_spot = shrine_pos((int)((sroom - rooms) + ROOMOFFSET));
lev = &levl[shrine_spot->x][shrine_spot->y]; lev = &levl[shrine_spot->x][shrine_spot->y];
lev->typ = ALTAR; lev->typ = ALTAR;
lev->altarmask = induced_align(80); lev->altarmask = induced_align(80);
@@ -596,7 +596,7 @@ coord *c;
int i; int i;
if (croom->irregular) { if (croom->irregular) {
i = (croom - rooms) + ROOMOFFSET; i = (int)((croom - rooms) + ROOMOFFSET);
while(try_cnt++ < 100) { while(try_cnt++ < 100) {
c->x = somex(croom); c->x = somex(croom);
+2 -2
View File
@@ -2500,9 +2500,9 @@ struct monst *mon;
struct obj *m_armr = which_armor(mon, W_ARM); struct obj *m_armr = which_armor(mon, W_ARM);
if (m_armr && Is_dragon_scales(m_armr)) if (m_armr && Is_dragon_scales(m_armr))
mndx = Dragon_scales_to_pm(m_armr) - mons; mndx = (int)(Dragon_scales_to_pm(m_armr) - mons);
else if (m_armr && Is_dragon_mail(m_armr)) else if (m_armr && Is_dragon_mail(m_armr))
mndx = Dragon_mail_to_pm(m_armr) - mons; mndx = (int)(Dragon_mail_to_pm(m_armr) - mons);
} }
break; break;
} }
+3 -3
View File
@@ -702,7 +702,7 @@ char *tp;
cp++; cp++;
if (*cp == 'x' || *cp == 'X') if (*cp == 'x' || *cp == 'X')
for (++cp; (dp = index(hex, *cp)) && (dcount++ < 2); cp++) for (++cp; (dp = index(hex, *cp)) && (dcount++ < 2); cp++)
cval = (cval * 16) + (dp - hex) / 2; cval = (int)((cval * 16) + (dp - hex) / 2);
else if (*cp == 'o' || *cp == 'O') else if (*cp == 'o' || *cp == 'O')
for (++cp; (index("01234567",*cp)) && (dcount++ < 3); cp++) for (++cp; (index("01234567",*cp)) && (dcount++ < 3); cp++)
cval = (cval * 8) + (*cp - '0'); cval = (cval * 8) + (*cp - '0');
@@ -1933,7 +1933,7 @@ goodfruit:
if (c == 'k') c = 'v'; /* killed -> vanquished */ if (c == 'k') c = 'v'; /* killed -> vanquished */
dop = index(disclosure_options, c); dop = index(disclosure_options, c);
if (dop) { if (dop) {
idx = dop - disclosure_options; idx = (int)(dop - disclosure_options);
if (idx < 0 || idx > NUM_DISCLOSURE_OPTIONS - 1) { if (idx < 0 || idx > NUM_DISCLOSURE_OPTIONS - 1) {
impossible("bad disclosure index %d %c", impossible("bad disclosure index %d %c",
idx, c); idx, c);
@@ -2538,7 +2538,7 @@ map_menu_cmd(ch)
{ {
char *found = index(mapped_menu_cmds, ch); char *found = index(mapped_menu_cmds, ch);
if (found) { if (found) {
int idx = found - mapped_menu_cmds; int idx = (int)(found - mapped_menu_cmds);
ch = mapped_menu_op[idx]; ch = mapped_menu_op[idx];
} }
return ch; return ch;
+1 -1
View File
@@ -223,7 +223,7 @@ boolean sanctum; /* is it the seat of the high priest? */
priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST], priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST],
sx + 1, sy, MM_EPRI); sx + 1, sy, MM_EPRI);
if (priest) { if (priest) {
EPRI(priest)->shroom = (sroom - rooms) + ROOMOFFSET; EPRI(priest)->shroom = (schar)((sroom - rooms) + ROOMOFFSET);
EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask); EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask);
EPRI(priest)->shrpos.x = sx; EPRI(priest)->shrpos.x = sx;
EPRI(priest)->shrpos.y = sy; EPRI(priest)->shrpos.y = sy;
+4 -4
View File
@@ -370,7 +370,7 @@ int sx, sy;
mtmp->mappearance = STRANGE_OBJECT; mtmp->mappearance = STRANGE_OBJECT;
} }
} else { } else {
atype = get_shop_item(shp - shtypes); atype = get_shop_item((int)(shp - shtypes));
if (atype == VEGETARIAN_CLASS) if (atype == VEGETARIAN_CLASS)
mkveggy_at(sx, sy); mkveggy_at(sx, sy);
else if (atype < 0) else if (atype < 0)
@@ -486,7 +486,7 @@ struct mkroom *sroom;
/* check that the shopkeeper placement is sane */ /* check that the shopkeeper placement is sane */
if(sroom->irregular) { if(sroom->irregular) {
int rmno = (sroom - rooms) + ROOMOFFSET; int rmno = (int)((sroom - rooms) + ROOMOFFSET);
if (isok(sx-1,sy) && !levl[sx-1][sy].edge && if (isok(sx-1,sy) && !levl[sx-1][sy].edge &&
(int) levl[sx-1][sy].roomno == rmno) sx--; (int) levl[sx-1][sy].roomno == rmno) sx--;
else if (isok(sx+1,sy) && !levl[sx+1][sy].edge && else if (isok(sx+1,sy) && !levl[sx+1][sy].edge &&
@@ -534,7 +534,7 @@ struct mkroom *sroom;
set_malign(shk); set_malign(shk);
shk->msleeping = 0; shk->msleeping = 0;
shk->mtrapseen = ~0; /* we know all the traps already */ shk->mtrapseen = ~0; /* we know all the traps already */
ESHK(shk)->shoproom = (sroom - rooms) + ROOMOFFSET; ESHK(shk)->shoproom = (schar)((sroom - rooms) + ROOMOFFSET);
sroom->resident = shk; sroom->resident = shk;
ESHK(shk)->shoptype = sroom->rtype; ESHK(shk)->shoptype = sroom->rtype;
assign_level(&(ESHK(shk)->shoplevel), &u.uz); assign_level(&(ESHK(shk)->shoplevel), &u.uz);
@@ -574,7 +574,7 @@ register struct mkroom *sroom;
*/ */
register int sx, sy, sh; register int sx, sy, sh;
char buf[BUFSZ]; char buf[BUFSZ];
int rmno = (sroom - rooms) + ROOMOFFSET; int rmno = (int)((sroom - rooms) + ROOMOFFSET);
const struct shclass *shp = &shtypes[shp_indx]; const struct shclass *shp = &shtypes[shp_indx];
/* first, try to place a shopkeeper in the room */ /* first, try to place a shopkeeper in the room */
+1 -1
View File
@@ -224,7 +224,7 @@ dosounds()
return; return;
} }
if (tended_shop(sroom) && if (tended_shop(sroom) &&
!index(u.ushops, ROOM_INDEX(sroom) + ROOMOFFSET)) { !index(u.ushops, (int)(ROOM_INDEX(sroom) + ROOMOFFSET))) {
static const char * const shop_msg[3] = { static const char * const shop_msg[3] = {
"someone cursing shoplifters.", "someone cursing shoplifters.",
"the chime of a cash register.", "the chime of a cash register.",
+1 -1
View File
@@ -227,7 +227,7 @@ nh_timeout()
for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++) for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++)
if((upp->intrinsic & TIMEOUT) && !(--upp->intrinsic & TIMEOUT)) { if((upp->intrinsic & TIMEOUT) && !(--upp->intrinsic & TIMEOUT)) {
kptr = find_delayed_killer(upp - u.uprops); kptr = find_delayed_killer((int)(upp - u.uprops));
switch(upp - u.uprops){ switch(upp - u.uprops){
case STONED: case STONED:
if (kptr && kptr->name[0]) { if (kptr && kptr->name[0]) {