ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/skills.C
(Generate patch)

Comparing deliantra/server/server/skills.C (file contents):
Revision 1.66 by root, Mon Oct 12 14:00:59 2009 UTC vs.
Revision 1.68 by root, Sat Oct 17 21:40:38 2009 UTC

1053} 1053}
1054 1054
1055/* remove_trap() - This skill will disarm any previously discovered trap 1055/* remove_trap() - This skill will disarm any previously discovered trap
1056 * the algorithm is based (almost totally) on the old command_disarm() - b.t. 1056 * the algorithm is based (almost totally) on the old command_disarm() - b.t.
1057 */ 1057 */
1058
1059int 1058int
1060remove_trap (object *op, int dir, object *skill) 1059remove_trap (object *op, int dir, object *skill)
1061{ 1060{
1062 object *tmp, *tmp2; 1061 object *tmp, *tmp2;
1063 int i, success = 0, mflags; 1062 int i, success = 0, mflags;
1096 } 1095 }
1097 } 1096 }
1098 if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1) 1097 if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1)
1099 { 1098 {
1100 trap_show (tmp, tmp); 1099 trap_show (tmp, tmp);
1100
1101 if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER)) 1101 if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER))
1102 { 1102 {
1103 tmp->stats.exp = tmp->stats.Cha * tmp->level; 1103 tmp->stats.exp = tmp->stats.Cha * tmp->level;
1104 success += calc_skill_exp (op, tmp, skill); 1104 success += calc_skill_exp (op, tmp, skill);
1105 } 1105 }
1131 /* Check all objects - we could stop at floor objects, 1131 /* Check all objects - we could stop at floor objects,
1132 * but if someone buries an altar, I don't see a problem with 1132 * but if someone buries an altar, I don't see a problem with
1133 * going through all the objects, and it shouldn't be much slower 1133 * going through all the objects, and it shouldn't be much slower
1134 * than extra checks on object attributes. 1134 * than extra checks on object attributes.
1135 */ 1135 */
1136 for (tmp = pl->below; tmp != NULL; tmp = tmp->below) 1136 for (tmp = pl->below; tmp; tmp = tmp->below)
1137 { 1137 {
1138 /* Only if the altar actually belongs to someone do you get special benefits */ 1138 /* Only if the altar actually belongs to someone do you get special benefits */
1139 if (tmp && tmp->type == HOLY_ALTAR && tmp->other_arch) 1139 if (tmp && tmp->type == HOLY_ALTAR && tmp->other_arch)
1140 { 1140 {
1141 sprintf (buf, "You pray over the %s.", &tmp->name); 1141 sprintf (buf, "You pray over the %s.", &tmp->name);
1234 } 1234 }
1235 1235
1236 if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill))) 1236 if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill)))
1237 return RESULT_INT (0); 1237 return RESULT_INT (0);
1238 1238
1239 char buf[1024]; 1239 STRLEN char_len = utf8_length ((U8 *)msg, (U8 *)(msg+len));
1240 1240
1241 if (len < sizeof (buf) - 2) 1241 if (char_len <= item->weight_limit)
1242 { 1242 {
1243 snprintf (buf, sizeof (buf), "%s\n", msg);
1244
1245 object *newbook = arch_to_object (item->other_arch); 1243 object *newbook = arch_to_object (item->other_arch);
1246 item->decrease (); 1244 item->decrease ();
1247 newbook->nrof = 1; 1245 newbook->nrof = 1;
1248 newbook->msg = buf; 1246 newbook->msg = shstr (msg);
1249 newbook->flag [FLAG_IDENTIFIED] = true; 1247 newbook->flag [FLAG_IDENTIFIED] = true;
1250 1248
1251 if (item->subtype == 1) // mailscrolls 1249 if (item->subtype == 1) // mailscrolls
1252 { 1250 {
1253 newbook->name = item->name; 1251 newbook->name = item->name;
1256 1254
1257 pl->insert (newbook); 1255 pl->insert (newbook);
1258 1256
1259 pl->contr->play_sound (sound_find ("inscribe_success")); 1257 pl->contr->play_sound (sound_find ("inscribe_success"));
1260 new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", &item->name); 1258 new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", &item->name);
1261 return strlen (msg); 1259 return char_len;
1262 } 1260 }
1263 else 1261 else
1264 new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s!", &item->name); 1262 new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s! H<It is only big enough for %d characters, your message had %d characters.>",
1263 &item->name, item->weight_limit, char_len);
1265 1264
1266 return 0; 1265 return 0;
1267} 1266}
1268 1267
1269/* write_scroll() - this routine allows players to inscribe spell scrolls 1268/* write_scroll() - this routine allows players to inscribe spell scrolls

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines