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;
/* 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;
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".
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.