Skip to content

Commit

Permalink
cast int64 to smaller types (trunk only)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nethack.allison committed Jul 11, 2006
1 parent 7394b0a commit 96c6163
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/artifact.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ register boolean mod;
if (otmp && *name)
for (a = artilist+1; a->otyp; a++)
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->age = 0;
if(otmp->otyp == RIN_INCREASE_DAMAGE)
Expand Down
2 changes: 1 addition & 1 deletion src/end.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ char *defquery;
char *dop = index(disclosure_options, category);

if (dop && defquery) {
idx = dop - disclosure_options;
idx = (int)(dop - disclosure_options);
if (idx < 0 || idx > (NUM_DISCLOSURE_OPTIONS - 1)) {
impossible(
"should_query_disclose_option: bad disclosure index %d %c",
Expand Down
2 changes: 1 addition & 1 deletion src/mklev.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ topologize(croom)
register struct mkroom *croom;
#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 hix = croom->hx, hiy = croom->hy;
#ifdef SPECIALIZATION
Expand Down
2 changes: 1 addition & 1 deletion src/mkmaze.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ register const char *s;
char *ep = getenv("SPLEVTYPE"); /* not nh_getenv */
if (ep) {
/* 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) {
if (!strncmp(ep, protofile, len)) {
Expand Down
6 changes: 3 additions & 3 deletions src/mkroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct mkroom *sroom;
struct monst *mon;
register int sx,sy,i;
int sh, tx, ty, goldlim, type = sroom->rtype;
int rmno = (sroom - rooms) + ROOMOFFSET;
int rmno = (int)((sroom - rooms) + ROOMOFFSET);
coord mm;

#ifdef GCC_WARN
Expand Down Expand Up @@ -518,7 +518,7 @@ mktemple()
* In temples, shrines are blessed altars
* 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->typ = ALTAR;
lev->altarmask = induced_align(80);
Expand Down Expand Up @@ -596,7 +596,7 @@ coord *c;
int i;

if (croom->irregular) {
i = (croom - rooms) + ROOMOFFSET;
i = (int)((croom - rooms) + ROOMOFFSET);

while(try_cnt++ < 100) {
c->x = somex(croom);
Expand Down
4 changes: 2 additions & 2 deletions src/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2500,9 +2500,9 @@ struct monst *mon;
struct obj *m_armr = which_armor(mon, W_ARM);

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))
mndx = Dragon_mail_to_pm(m_armr) - mons;
mndx = (int)(Dragon_mail_to_pm(m_armr) - mons);
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ char *tp;
cp++;
if (*cp == 'x' || *cp == 'X')
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')
for (++cp; (index("01234567",*cp)) && (dcount++ < 3); cp++)
cval = (cval * 8) + (*cp - '0');
Expand Down Expand Up @@ -1933,7 +1933,7 @@ boolean tinitial, tfrom_file;
if (c == 'k') c = 'v'; /* killed -> vanquished */
dop = index(disclosure_options, c);
if (dop) {
idx = dop - disclosure_options;
idx = (int)(dop - disclosure_options);
if (idx < 0 || idx > NUM_DISCLOSURE_OPTIONS - 1) {
impossible("bad disclosure index %d %c",
idx, c);
Expand Down Expand Up @@ -2538,7 +2538,7 @@ map_menu_cmd(ch)
{
char *found = index(mapped_menu_cmds, ch);
if (found) {
int idx = found - mapped_menu_cmds;
int idx = (int)(found - mapped_menu_cmds);
ch = mapped_menu_op[idx];
}
return ch;
Expand Down
2 changes: 1 addition & 1 deletion src/priest.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ boolean sanctum; /* is it the seat of the high priest? */
priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST],
sx + 1, sy, MM_EPRI);
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)->shrpos.x = sx;
EPRI(priest)->shrpos.y = sy;
Expand Down
8 changes: 4 additions & 4 deletions src/shknam.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ int sx, sy;
mtmp->mappearance = STRANGE_OBJECT;
}
} else {
atype = get_shop_item(shp - shtypes);
atype = get_shop_item((int)(shp - shtypes));
if (atype == VEGETARIAN_CLASS)
mkveggy_at(sx, sy);
else if (atype < 0)
Expand Down Expand Up @@ -486,7 +486,7 @@ struct mkroom *sroom;

/* check that the shopkeeper placement is sane */
if(sroom->irregular) {
int rmno = (sroom - rooms) + ROOMOFFSET;
int rmno = (int)((sroom - rooms) + ROOMOFFSET);
if (isok(sx-1,sy) && !levl[sx-1][sy].edge &&
(int) levl[sx-1][sy].roomno == rmno) sx--;
else if (isok(sx+1,sy) && !levl[sx+1][sy].edge &&
Expand Down Expand Up @@ -534,7 +534,7 @@ struct mkroom *sroom;
set_malign(shk);
shk->msleeping = 0;
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;
ESHK(shk)->shoptype = sroom->rtype;
assign_level(&(ESHK(shk)->shoplevel), &u.uz);
Expand Down Expand Up @@ -574,7 +574,7 @@ register struct mkroom *sroom;
*/
register int sx, sy, sh;
char buf[BUFSZ];
int rmno = (sroom - rooms) + ROOMOFFSET;
int rmno = (int)((sroom - rooms) + ROOMOFFSET);
const struct shclass *shp = &shtypes[shp_indx];

/* first, try to place a shopkeeper in the room */
Expand Down
2 changes: 1 addition & 1 deletion src/sounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ dosounds()
return;
}
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] = {
"someone cursing shoplifters.",
"the chime of a cash register.",
Expand Down
2 changes: 1 addition & 1 deletion src/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ nh_timeout()

for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++)
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){
case STONED:
if (kptr && kptr->name[0]) {
Expand Down

0 comments on commit 96c6163

Please sign in to comment.