ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/utils.c
(Generate patch)

Comparing deliantra/server/common/utils.c (file contents):
Revision 1.1 by root, Fri Feb 3 07:11:41 2006 UTC vs.
Revision 1.2 by root, Wed Mar 8 18:28:54 2006 UTC

1/* 1/*
2 * static char *rcsid_utils_c = 2 * static char *rcsid_utils_c =
3 * "$Id: utils.c,v 1.1 2006/02/03 07:11:41 root Exp $"; 3 * "$Id: utils.c,v 1.2 2006/03/08 18:28:54 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
47 * and if goodbad is non-zero, luck increases the roll, if zero, it decreases. 47 * and if goodbad is non-zero, luck increases the roll, if zero, it decreases.
48 * Generally, op should be the player/caster/hitter requesting the roll, 48 * Generally, op should be the player/caster/hitter requesting the roll,
49 * not the recipient (ie, the poor slob getting hit). [garbled 20010916] 49 * not the recipient (ie, the poor slob getting hit). [garbled 20010916]
50 */ 50 */
51 51
52int random_roll(int min, int max, object *op, int goodbad) { 52int random_roll(int min, int max, const object *op, int goodbad) {
53 int omin, diff, luck, base, ran; 53 int omin, diff, luck, base, ran;
54 54
55 omin = min; 55 omin = min;
56 diff = max - min + 1; 56 diff = max - min + 1;
57 ((diff > 2) ? (base = 20) : (base = 50)); /* d2 and d3 are corner cases */ 57 ((diff > 2) ? (base = 20) : (base = 50)); /* d2 and d3 are corner cases */
83/* 83/*
84 * This is a 64 bit version of random_roll above. This is needed 84 * This is a 64 bit version of random_roll above. This is needed
85 * for exp loss calculations for players changing religions. 85 * for exp loss calculations for players changing religions.
86 */ 86 */
87 87
88sint64 random_roll64(sint64 min, sint64 max, object *op, int goodbad) { 88sint64 random_roll64(sint64 min, sint64 max, const object *op, int goodbad) {
89 sint64 omin, diff, luck, ran; 89 sint64 omin, diff, luck, ran;
90 int base; 90 int base;
91 91
92 omin = min; 92 omin = min;
93 diff = max - min + 1; 93 diff = max - min + 1;
132 * Generally, op should be the player/caster/hitter requesting the roll, 132 * Generally, op should be the player/caster/hitter requesting the roll,
133 * not the recipient (ie, the poor slob getting hit). 133 * not the recipient (ie, the poor slob getting hit).
134 * The args are num D size (ie 4d6) [garbled 20010916] 134 * The args are num D size (ie 4d6) [garbled 20010916]
135 */ 135 */
136 136
137int die_roll(int num, int size, object *op, int goodbad) { 137int die_roll(int num, int size, const object *op, int goodbad) {
138 int min, diff, luck, total, i, gotlucky, base, ran; 138 int min, diff, luck, total, i, gotlucky, base, ran;
139 139
140 diff = size; 140 diff = size;
141 min = 1; 141 min = 1;
142 luck = total = gotlucky = 0; 142 luck = total = gotlucky = 0;
266 266
267/* when doing transmutation of objects, we have to recheck the resistances, 267/* when doing transmutation of objects, we have to recheck the resistances,
268 * as some that did not apply previously, may apply now. 268 * as some that did not apply previously, may apply now.
269 */ 269 */
270 270
271void transmute_materialname(object *op, object *change) 271void transmute_materialname(object *op, const object *change)
272{ 272{
273 materialtype_t *mt; 273 materialtype_t *mt;
274 int j; 274 int j;
275 275
276 if (op->materialname == NULL) 276 if (op->materialname == NULL)
282 282
283 if (!IS_ARMOR(op)) 283 if (!IS_ARMOR(op))
284 return; 284 return;
285 285
286 mt = name_to_material(op->materialname); 286 mt = name_to_material(op->materialname);
287 if (!mt) {
288 LOG(llevError, "archetype '%s>%s' uses nonexistent material '%s'\n", op->arch->name, op->name, op->materialname);
289 return;
290 }
287 291
288 for (j=0; j < NROFATTACKS; j++) 292 for (j=0; j < NROFATTACKS; j++)
289 if (op->resist[j] == 0 && change->resist[j] != 0) { 293 if (op->resist[j] == 0 && change->resist[j] != 0) {
290 op->resist[j] += mt->mod[j]; 294 op->resist[j] += mt->mod[j];
291 if (op->resist[j] > 100) 295 if (op->resist[j] > 100)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines