12 Nov, 2012, Liko wrote in the 1st comment:
Votes: 0
Hello guys,

I'm currently developing a socketing system for my Green Lantern Mud and plan to release it to the public for stock tbamud/circlemud codebases. I'm almost done, expect I'm running into a small bug. When the modifier modifies the weapon/armor instead of setting the correct bit location it sets it to none. Example:
Right way: +10 Max Hit
The Way I'm getting: +10 None

I know the exact line that is causing the bug, but I have spent hours and cannot fix it. I have pasted the code below. The line I believe that is causing the bug is line 10. Lines 8-15 should be getting the modifier object's bit location(MAX_HIT) and making sure that the weapon/armor's bit location is the same.

Hopefully, a fresh pair of eyes or someone can help me sort this little bug out.

bool socket_apply(struct obj_data *a, struct obj_data *b)
{
int i = 0, apply = -1, location = -1, mod = 0, empty = -1;




while (*socket_types[i] != '\n') {
if(socket_types[i]) { /* This is the line causing the bug*/
apply = i;
break;
}
i++;
}

if (apply == -1)
return FALSE;

for (i = 0; i < MAX_SOCKET_AFFECT; i++) {
if (b->bonus[i].location == apply) {
location = i;
mod = a->bonus[i].modifier;
break;
} else if (b->bonus[i].location == SOCKET_NONE && empty == -1) {
empty = i;
}
}

/* No slot already using SOCKET_XXX, so use an empty one… if available */
if (location == -1)
location = empty;

/* There is no slot already using our SOCKET_XXX type, and no empty slots either */
if (location == -1)
return FALSE;

b->bonus[location].modifier = mod;
b->obj_flags.num_sockets += 1;

/* Our modifier is set at 0, so lets just clear the SOCKET location so that it may
* be reused at a later point */
if (b->bonus[location].modifier != 0)
b->bonus[location].location = apply;
else
b->bonus[location].location = SOCKET_NONE;

return TRUE;
}
[code]
12 Nov, 2012, Exodus wrote in the 2nd comment:
Votes: 0
while (*socket_types[i] != '\n') {
if (is_abbrev(apply_types[i], arg)) {
if(socket_types[i]) { /* This is the line causing the bug*/
apply = i;
break;
}
i++;
}


I don't see where "arg" is declared anywhere, regardless of that, "if(socket_types) will always return true since "i" is initialized as "0" and it looks as if position "0" in the array is set to "none".
12 Nov, 2012, Liko wrote in the 3rd comment:
Votes: 0
see below
12 Nov, 2012, Liko wrote in the 4th comment:
Votes: 0
Arg isn't suppose to be there. That was a typo.

So what I'm needing it to do is to check object a's bit location, if found return true and that will set apply to i?
13 Nov, 2012, Liko wrote in the 5th comment:
Votes: 0
I was able to fix this finally. I decided it to make a variable grab modifier's bit location first. That solved everything.
0.0/5