Skip to content

Commit

Permalink
Silencing compiler warnings; moved Necromancer spirit pickup to a sep…
Browse files Browse the repository at this point in the history
…arate function.
  • Loading branch information
elunna committed Oct 5, 2023
1 parent 3978375 commit 4bdab97
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 67 deletions.
2 changes: 1 addition & 1 deletion include/prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enum prop_types {
VULN_LOUD = 83,
BREATHLESS = 84,
STABLE = 85,
MAGIC_SENSE = 86,
MAGIC_SENSE = 86
};
#define LAST_PROP (MAGIC_SENSE)

Expand Down
70 changes: 38 additions & 32 deletions src/allmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ STATIC_DCL void NDECL(do_positionbar);
STATIC_DCL void FDECL(regen_hp, (int));
STATIC_DCL void FDECL(interrupt_multi, (const char *));
STATIC_DCL void FDECL(debug_fields, (const char *));
STATIC_DCL void NDECL(pickup_spirits);


#ifdef EXTRAINFO_FN
Expand Down Expand Up @@ -156,11 +157,10 @@ boolean resuming;
#endif
struct obj *pobj;
int moveamt = 0, wtcap = 0, change = 0;
boolean monscanmove = FALSE;

/* don't make it obvious when monsters will start speeding up */
int timeout_start = rnd(10000) + 25000;
int past_clock;
boolean monscanmove = FALSE;
boolean elf_regen = elf_can_regen();
boolean orc_regen = orc_can_regen();
boolean vamp_regen = vamp_can_regen();
Expand Down Expand Up @@ -557,36 +557,7 @@ boolean resuming;
}
}

char *p;
/* Autopickup spirits for Necromancer */
if (Role_if(PM_NECROMANCER)) {
struct obj *obj;
/* Carrying the necro quest arti triples the range */
int off = carrying_arti(ART_GREAT_DAGGER_OF_GLAURGNAA) ? 3 : 1;
/* Loop through the surrounding squares */
int x, y;
for (x = u.ux - off; x <= u.ux + off; x++) {
for (y = u.uy - off; y <= u.uy + off; y++) {
if (!isok(x, y) || !OBJ_AT(x, y))
continue;

/* count the objects here */
for (obj = level.objects[x][y]; obj; obj = obj->nexthere) {
if (obj->otyp == SPIRIT) {
/* Don't allow auto-pickup of spirits in shops unless
* the shop is abandoned. */
if (inside_shop(x, y) && *(p = in_rooms(x, y, SHOPBASE))
&& tended_shop(&rooms[*p - ROOMOFFSET]))
continue;

pickup_object(obj, obj->quan, TRUE);
newsym_force(x, y);
break;
}
}
}
}
}
pickup_spirits();

if (!u.uinvulnerable) {
if (Teleportation && !rn2(85)) {
Expand Down Expand Up @@ -1493,4 +1464,39 @@ wishluck()
return 0;
}

STATIC_OVL void
pickup_spirits()
{
char *p;
/* Autopickup spirits for Necromancer */
if (Role_if(PM_NECROMANCER)) {
struct obj *obj;
/* Carrying the necro quest arti triples the range */
int off = carrying_arti(ART_GREAT_DAGGER_OF_GLAURGNAA) ? 3 : 1;
/* Loop through the surrounding squares */
int x, y;
for (x = u.ux - off; x <= u.ux + off; x++) {
for (y = u.uy - off; y <= u.uy + off; y++) {
if (!isok(x, y) || !OBJ_AT(x, y))
continue;

/* count the objects here */
for (obj = level.objects[x][y]; obj; obj = obj->nexthere) {
if (obj->otyp == SPIRIT) {
/* Don't allow auto-pickup of spirits in shops unless
* the shop is abandoned. */
if (inside_shop(x, y) && *(p = in_rooms(x, y, SHOPBASE))
&& tended_shop(&rooms[*p - ROOMOFFSET]))
continue;

pickup_object(obj, obj->quan, TRUE);
newsym_force(x, y);
break;
}
}
}
}
}

}
/*allmain.c*/
70 changes: 37 additions & 33 deletions src/artifact.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ boolean allow_detrimental;
&& (j & (NON_WEP_PROPS | ITEM_OILSKIN)))
continue;

if ((otmp->oclass == ARMOR_CLASS && otmp->oclass == RING_CLASS)
if ((otmp->oclass == ARMOR_CLASS || otmp->oclass == RING_CLASS)
&& (j & ONLY_WEP_PROPS))
continue;

Expand Down Expand Up @@ -496,11 +496,12 @@ is_redundant_prop(otmp, prop)
struct obj *otmp;
int prop;
{
int i;
/* Alchemy smock is the king of exceptions */
if (otmp->otyp == ALCHEMY_SMOCK && (prop & (ITEM_ACID | ITEM_VENOM)))
return TRUE;

for (int i = 0; i < NUM_PROPERTIES; i++) {
for (i = 0; i < NUM_PROPERTIES; i++) {
if (otmp->otyp == prop_lookup[i].prop && (prop & prop_lookup[i].flag))
return TRUE;
}
Expand Down Expand Up @@ -3089,40 +3090,43 @@ int dieroll; /* needed for Magicbane and vorpal blades */
}

/* Origin can teleport/confuse enemies */
if (otmp->oartifact == ART_ORIGIN) {
if (realizes_damage) {
if (youdefend && !Antimagic && !rn2(5)) {
tele();
if (!rn2(3))
make_confused(HConfusion + d(3, 4), FALSE);
return TRUE;
} else if (!rn2(5) && !resists_magm(mdef)
&& !defended(mdef, AD_MAGM)) {
if (*dmgptr <= 0)
*dmgptr = 1;

char nambuf[BUFSZ];
boolean u_saw_mon = (canseemon(mdef)
|| (u.uswallow && u.ustuck == mdef));

/* record the name before losing sight of monster */
Strcpy(nambuf, Monnam(mdef));
if (u_teleport_mon(mdef, FALSE) && u_saw_mon
&& !(canseemon(mdef) || (u.uswallow && u.ustuck == mdef)))
pline("%s suddenly disappears!", nambuf);
if (*dmgptr >= mdef->mhp) { /* see hitmu(mhitu.c) */
if (mdef->mhp == 1)
++mdef->mhp;
*dmgptr = mdef->mhp - 1;
{
char nambuf[BUFSZ];

if (otmp->oartifact == ART_ORIGIN) {
if (realizes_damage) {
if (youdefend && !Antimagic && !rn2(5)) {
tele();
if (!rn2(3))
make_confused(HConfusion + d(3, 4), FALSE);
return TRUE;
} else if (!rn2(5) && !resists_magm(mdef)
&& !defended(mdef, AD_MAGM)) {
if (*dmgptr <= 0)
*dmgptr = 1;


boolean u_saw_mon = (canseemon(mdef)
|| (u.uswallow && u.ustuck == mdef));

/* record the name before losing sight of monster */
Strcpy(nambuf, Monnam(mdef));
if (u_teleport_mon(mdef, FALSE) && u_saw_mon
&& !(canseemon(mdef) || (u.uswallow && u.ustuck == mdef)))
pline("%s suddenly disappears!", nambuf);
if (*dmgptr >= mdef->mhp) { /* see hitmu(mhitu.c) */
if (mdef->mhp == 1)
++mdef->mhp;
*dmgptr = mdef->mhp - 1;
}

if (!rn2(3))
mdef->mconf = 1;
return TRUE;
}

if (!rn2(3))
mdef->mconf = 1;
return TRUE;
}
}
}

/* Bradamante's Fury forces dismounts */
if (otmp->oartifact == ART_BRADAMANTE_S_FURY) {
if (youdefend) {
Expand Down Expand Up @@ -4081,7 +4085,7 @@ boolean
artifact_wet(obj)
struct obj *obj;
{
int ad_type, oprops;
int ad_type = 0, oprops;

/* Only weapons work this way ("attacking" the water) */
if (!((obj->oclass == WEAPON_CLASS) || is_weptool(obj)))
Expand Down
3 changes: 2 additions & 1 deletion src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,8 @@ changes_stat(otmp, prop)
long prop;
register struct obj *otmp;
{
for (int c = 0; c < A_MAX; c++) {
int c;
for (c = 0; c < A_MAX; c++) {
int old_attrib = ACURR(c);
if (calc_prop_bonus(old_attrib, prop) != old_attrib) {
otmp->oprops_known |= prop;
Expand Down

0 comments on commit 4bdab97

Please sign in to comment.