Ah that came in handy! I followed the tutorial and managed to get some info on this crash.
Seems the crash occurs when damage is supposed to occur to a worn item, but the problem is there is no item worn on that location! Here is what gdb came up with.
Code:
(gdb) bt
#0 0x00482052 in hit (ch=0x80f107b0, victim=0x80adf088, type=-1)
at fight.c:1137
#1 0x00482e0d in perform_violence () at fight.c:1230
#2 0x004fa2aa in heartbeat (heart_pulse=180) at comm.c:991
#3 0x004fdd15 in game_loop (local_mother_desc=3) at comm.c:938
#4 0x004fee86 in init_game (local_port=4000) at comm.c:533
#5 main (argc=2, argv=0x28ac50) at comm.c:353
(gdb) list
1142 send_to_char(victim, "\trWith that final blow, %s that you were wearing fall apart!\tn\n", GET_OBJ_SHORT(headarm));
1143 send_to_room(IN_ROOM(victim), "\tr%s is less protected as %s falls apart after that last blow!\tn\n", GET_NAME(victim), GET_OBJ_SHORT(headarm));
1144 obj_to_char(unequip_char(victim, WEAR_HEAD), victim);
1145 }
1146 }
1147 break;
1148 default:
1149 break;
1150 }
1151
(gdb) info local
wielded = <optimized out>
bodyarm = 0x0
neckarm1 = 0x0
neckarm2 = 0x0
headarm = 0x0
shield = 0x0
legarmor = 0x0
feetarm = 0x0
handarm = 0x0
armarmor = 0x0
aboutarm = 0x0
waistarm = 0x0
rwristarm = 0x0
lwristarm = 0x0
w_type = 303
victim_ac = <optimized out>
calc_thaco = 0
dam = 12
diceroll = 5
wpnprof = <optimized out>
location = <optimized out>
(gdb) up
#1 0x00482e0d in perform_violence () at fight.c:1230
1230 hit(ch, FIGHTING(ch), TYPE_UNDEFINED);
(gdb) list
1225 /* have to implement a better way for number of attacks for mobs */
1226 num_of_attacks += ((int) GET_LEVEL(ch) / 5) - 1;
1227 }
1228
1229 for (loop_attacks = 1; loop_attacks < num_of_attacks && ch && FIGHTING(ch); loop_attacks++)
1230 hit(ch, FIGHTING(ch), TYPE_UNDEFINED);
1231
1232 if (GROUP(ch)) {
1233 while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) {
1234 if (tch == ch)
(gdb) info local
ch = 0x80f107b0
tch = <optimized out>
wielded = <optimized out>
num_of_attacks = 4
loop_attacks = <optimized out>
(gdb) up
#2 0x004fa2aa in heartbeat (heart_pulse=180) at comm.c:991
991 perform_violence();
(gdb) list
986
987 if (!(heart_pulse % PULSE_MOBILE))
988 mobile_activity();
989
990 if (!(heart_pulse % PULSE_VIOLENCE))
991 perform_violence();
992
993 if (!(heart_pulse % (SECS_PER_MUD_HOUR * PASSES_PER_SEC))) { /* Tick ! */
994 next_tick = SECS_PER_MUD_HOUR; /* Reset tick coundown */
995 weather_and_time(1);
Here's an example also of the variables I defined, and a little bit of the location code to boot.
Code:
struct obj_data *wielded = GET_EQ(ch, WEAR_WIELD);
struct obj_data *bodyarm = GET_EQ(victim, WEAR_BODY);
struct obj_data *neckarm1 = GET_EQ(victim, WEAR_NECK_1);
struct obj_data *neckarm2 = GET_EQ(victim, WEAR_NECK_2);
struct obj_data *headarm = GET_EQ(victim, WEAR_HEAD);
struct obj_data *shield = GET_EQ(victim, WEAR_SHIELD);
struct obj_data *legarmor = GET_EQ(victim, WEAR_LEGS);
struct obj_data *feetarm = GET_EQ(victim, WEAR_FEET);
struct obj_data *handarm = GET_EQ(victim, WEAR_HANDS);
struct obj_data *armarmor = GET_EQ(victim, WEAR_ARMS);
struct obj_data *aboutarm = GET_EQ(victim, WEAR_ABOUT);
struct obj_data *waistarm = GET_EQ(victim, WEAR_WAIST);
struct obj_data *rwristarm = GET_EQ(victim, WEAR_WRIST_R);
struct obj_data *lwristarm = GET_EQ(victim, WEAR_WRIST_L);
Code:
switch (location) {
case 1: // Feet Location
case 2:
if ((feetarm) && (GET_OBJ_MAX_DURAB(feetarm) != 0))
diceroll = rand_number(1, 100);
if (diceroll <= 10) {
send_to_char(ch, "\tRWith that blow, %s has been damaged!\tn\n", GET_OBJ_SHORT(feetarm));
GET_OBJ_DURABILITY(feetarm) -= rand_number(1, 6);
if (GET_OBJ_DURABILITY(feetarm) < 0)
GET_OBJ_DURABILITY(feetarm) = 0;
if (GET_OBJ_DURABILITY(feetarm) == 0) {
send_to_char(victim, "\trWith that final blow, %s that you were wearing fall apart!\tn\n", GET_OBJ_SHORT(feetarm));
send_to_room(IN_ROOM(victim), "\tr%s is less protected as %s falls apart after that last blow!\tn\n", GET_NAME(victim), GET_OBJ_SHORT(feetarm));
obj_to_char(unequip_char(victim, WEAR_FEET), victim);
}
}
break;
case 3: // Leg location
case 4:
case 5:
if ((legarmor) && (GET_OBJ_MAX_DURAB(legarmor) != 0))
diceroll = rand_number(1, 100);
if (diceroll <= 10) {
send_to_char(ch, "\tRWith that blow, %s has been damaged!\tn\n", GET_OBJ_SHORT(legarmor));
GET_OBJ_DURABILITY(legarmor) -= rand_number(1, 6);
if (GET_OBJ_DURABILITY(legarmor) < 0)
GET_OBJ_DURABILITY(legarmor) = 0;
if (GET_OBJ_DURABILITY(legarmor) == 0) {
send_to_char(victim, "\trWith that final blow, %s that you were wearing fall apart!\tn\n", GET_OBJ_SHORT(legarmor));
send_to_room(IN_ROOM(victim), "\tr%s is less protected as %s falls apart after that last blow!\tn\n", GET_NAME(victim), GET_OBJ_SHORT(legarmor));
obj_to_char(unequip_char(victim, WEAR_LEGS), victim);
}
}
break;
Thanks for showing me that link, I'll finish trying to find out what the problem is. I think the issue is when I check to see whether something is located on a wear slot; it shouldn't even be reaching the send_to_char reporting to the player that the non-existing item is damaged.
Very educational!