mirror of
https://github.com/tbamud/tbamud.git
synced 2026-01-27 11:26:10 +01:00
DG Scripts bug fixes (#44)
* Increase ID space DG Scripts uses tiny idspace that results in wacky bugs when the mud is running too long. * Overhaul script ids All references to GET_ID(ch/obj) were removed and replaced by char_script_id() and obj_script_id(), which don’t assign ids until they are needed. The ch->id and obj->id variable names were changed to script_id to prevent accidental errors for future programmers. This change greatly increases how long the mud can run before it runs out of ID space. * Fix extraction count This prevents an error log where it has over-counted the extractions pending. It now behaves correctly when the same mob is %purge%’d or extract_char()’d twice.
This commit is contained in:
parent
d7a50664ea
commit
41da68bdb0
14 changed files with 182 additions and 125 deletions
|
|
@ -92,7 +92,7 @@ int item_in_list(char *item, obj_data *list)
|
|||
long id = atol(item + 1);
|
||||
|
||||
for (i = list; i; i = i->next_content) {
|
||||
if (id == GET_ID(i))
|
||||
if (id == i->script_id)
|
||||
count ++;
|
||||
if (GET_OBJ_TYPE(i) == ITEM_CONTAINER)
|
||||
count += item_in_list(item, i->contains);
|
||||
|
|
@ -299,13 +299,13 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
if (!str_cmp(var, "self")) {
|
||||
switch (type) {
|
||||
case MOB_TRIGGER:
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID((char_data *) go));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, char_script_id((char_data *) go));
|
||||
break;
|
||||
case OBJ_TRIGGER:
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID((obj_data *) go));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id((obj_data *) go));
|
||||
break;
|
||||
case WLD_TRIGGER:
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, (long) ((room_data *)go)->number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, room_script_id((room_data *)go));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -539,7 +539,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
}
|
||||
|
||||
if (rndm)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(rndm));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, char_script_id(rndm));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -707,7 +707,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
} else if ((pos = find_eq_pos_script(subfield)) < 0 || !GET_EQ(c, pos))
|
||||
*str = '\0';
|
||||
else
|
||||
snprintf(str, slen, "%c%ld",UID_CHAR, GET_ID(GET_EQ(c, pos)));
|
||||
snprintf(str, slen, "%c%ld",UID_CHAR, obj_script_id(GET_EQ(c, pos)));
|
||||
}
|
||||
else if (!str_cmp(field, "exp")) {
|
||||
if (subfield && *subfield) {
|
||||
|
|
@ -721,7 +721,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
case 'f':
|
||||
if (!str_cmp(field, "fighting")) {
|
||||
if (FIGHTING(c))
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(FIGHTING(c)));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, char_script_id(FIGHTING(c)));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -729,7 +729,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
if (!c->followers || !c->followers->follower)
|
||||
*str = '\0';
|
||||
else
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(c->followers->follower));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, char_script_id(c->followers->follower));
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
|
|
@ -787,7 +787,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
break;
|
||||
case 'i':
|
||||
if (!str_cmp(field, "id"))
|
||||
snprintf(str, slen, "%ld", GET_ID(c));
|
||||
snprintf(str, slen, "%ld", char_script_id(c));
|
||||
/* new check for pc/npc status */
|
||||
else if (!str_cmp(field, "is_pc")) {
|
||||
if (IS_NPC(c))
|
||||
|
|
@ -810,7 +810,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
if(subfield && *subfield) {
|
||||
for (obj = c->carrying;obj;obj=obj->next_content) {
|
||||
if(GET_OBJ_VNUM(obj)==atoi(subfield)) {
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(obj)); /* arg given, found */
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(obj)); /* arg given, found */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -818,7 +818,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
*str = '\0'; /* arg given, not found */
|
||||
} else { /* no arg given */
|
||||
if (c->carrying) {
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(c->carrying));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(c->carrying));
|
||||
} else {
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -870,7 +870,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
if (!c->master)
|
||||
*str = '\0';
|
||||
else
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(c->master));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, char_script_id(c->master));
|
||||
}
|
||||
else if (!str_cmp(field, "maxhitp")) {
|
||||
if (subfield && *subfield) {
|
||||
|
|
@ -907,7 +907,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
|
||||
else if (!str_cmp(field, "next_in_room")) {
|
||||
if (c->next_in_room)
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, GET_ID(c->next_in_room));
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, char_script_id(c->next_in_room));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -993,7 +993,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
/* see note in dg_scripts.h */
|
||||
#ifdef ACTOR_ROOM_IS_UID
|
||||
snprintf(str, slen, "%c%ld",UID_CHAR,
|
||||
(IN_ROOM(c)!= NOWHERE) ? (long) world[IN_ROOM(c)].number + ROOM_ID_BASE : ROOM_ID_BASE);
|
||||
(IN_ROOM(c)!= NOWHERE) ? room_script_id(world + IN_ROOM(c)) : ROOM_ID_BASE);
|
||||
#else
|
||||
snprintf(str, slen, "%d", (IN_ROOM(c)!= NOWHERE) ? world[IN_ROOM(c)].number : 0);
|
||||
#endif
|
||||
|
|
@ -1206,14 +1206,14 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
|
||||
else if (!str_cmp(field, "carried_by")) {
|
||||
if (o->carried_by)
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, GET_ID(o->carried_by));
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, char_script_id(o->carried_by));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
||||
else if (!str_cmp(field, "contents")) {
|
||||
if (o->contains)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(o->contains));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(o->contains));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1256,11 +1256,11 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
break;
|
||||
case 'i':
|
||||
if (!str_cmp(field, "id"))
|
||||
snprintf(str, slen, "%ld", GET_ID(o));
|
||||
snprintf(str, slen, "%ld", obj_script_id(o));
|
||||
|
||||
else if (!str_cmp(field, "is_inroom")) {
|
||||
if (IN_ROOM(o) != NOWHERE)
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, (long) world[IN_ROOM(o)].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, room_script_id(world + IN_ROOM(o)));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1274,7 +1274,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
|
||||
else if (!str_cmp(field, "next_in_list")) {
|
||||
if (o->next_content)
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, GET_ID(o->next_content));
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, obj_script_id(o->next_content));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1292,7 +1292,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
case 'r':
|
||||
if (!str_cmp(field, "room")) {
|
||||
if (obj_room(o) != NOWHERE)
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, (long)world[obj_room(o)].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, room_script_id(world + obj_room(o)));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1348,7 +1348,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
|
||||
else if (!str_cmp(field, "worn_by")) {
|
||||
if (o->worn_by)
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, GET_ID(o->worn_by));
|
||||
snprintf(str, slen,"%c%ld",UID_CHAR, char_script_id(o->worn_by));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1412,7 +1412,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
for (obj = r->contents; obj; obj = obj->next_content) {
|
||||
if (GET_OBJ_VNUM(obj) == atoi(subfield)) {
|
||||
/* arg given, found */
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(obj));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(obj));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1420,7 +1420,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
*str = '\0'; /* arg given, not found */
|
||||
} else { /* no arg given */
|
||||
if (r->contents) {
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(r->contents));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(r->contents));
|
||||
} else {
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1429,14 +1429,14 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
|
||||
else if (!str_cmp(field, "people")) {
|
||||
if (r->people)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, GET_ID(r->people));
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, char_script_id(r->people));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
else if (!str_cmp(field, "id")) {
|
||||
room_rnum rnum = real_room(r->number);
|
||||
if (rnum != NOWHERE)
|
||||
snprintf(str, slen, "%ld", (long) world[rnum].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%ld", room_script_id(world + rnum));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1486,7 +1486,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
sprintbit(R_EXIT(r, NORTH)->exit_info ,exit_bits, str, slen);
|
||||
else if (!str_cmp(subfield, "room")) {
|
||||
if (R_EXIT(r, NORTH)->to_room != NOWHERE)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, (long) world[R_EXIT(r, NORTH)->to_room].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, room_script_id(world + R_EXIT(r, NORTH)->to_room));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1506,7 +1506,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
sprintbit(R_EXIT(r, EAST)->exit_info ,exit_bits, str, slen);
|
||||
else if (!str_cmp(subfield, "room")) {
|
||||
if (R_EXIT(r, EAST)->to_room != NOWHERE)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, (long) world[R_EXIT(r, EAST)->to_room].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, room_script_id(world + R_EXIT(r, EAST)->to_room));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1526,7 +1526,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
sprintbit(R_EXIT(r, SOUTH)->exit_info ,exit_bits, str, slen);
|
||||
else if (!str_cmp(subfield, "room")) {
|
||||
if (R_EXIT(r, SOUTH)->to_room != NOWHERE)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, (long) world[R_EXIT(r, SOUTH)->to_room].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, room_script_id(world + R_EXIT(r, SOUTH)->to_room));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1546,7 +1546,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
sprintbit(R_EXIT(r, WEST)->exit_info ,exit_bits, str, slen);
|
||||
else if (!str_cmp(subfield, "room")) {
|
||||
if (R_EXIT(r, WEST)->to_room != NOWHERE)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, (long) world[R_EXIT(r, WEST)->to_room].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, room_script_id(world + R_EXIT(r, WEST)->to_room));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1566,7 +1566,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
sprintbit(R_EXIT(r, UP)->exit_info ,exit_bits, str, slen);
|
||||
else if (!str_cmp(subfield, "room")) {
|
||||
if (R_EXIT(r, UP)->to_room != NOWHERE)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, (long) world[R_EXIT(r, UP)->to_room].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, room_script_id(world + R_EXIT(r, UP)->to_room));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
@ -1586,7 +1586,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
sprintbit(R_EXIT(r, DOWN)->exit_info ,exit_bits, str, slen);
|
||||
else if (!str_cmp(subfield, "room")) {
|
||||
if (R_EXIT(r, DOWN)->to_room != NOWHERE)
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, (long) world[R_EXIT(r, DOWN)->to_room].number + ROOM_ID_BASE);
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, room_script_id(world + R_EXIT(r, DOWN)->to_room));
|
||||
else
|
||||
*str = '\0';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue