mirror of
https://github.com/tbamud/tbamud.git
synced 2026-02-11 10:34:20 +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
|
|
@ -420,9 +420,9 @@ void wld_command_interpreter(room_data *room, char *argument);
|
|||
* mob id's: MOB_ID_BASE to ROOM_ID_BASE - 1
|
||||
* room id's: ROOM_ID_BASE to OBJ_ID_BASE - 1
|
||||
* object id's: OBJ_ID_BASE and higher */
|
||||
#define MOB_ID_BASE 50000 /* 50000 player IDNUMS should suffice */
|
||||
#define ROOM_ID_BASE 1050000 /* 1000000 Mobs */
|
||||
#define OBJ_ID_BASE 1300000 /* 250000 Rooms */
|
||||
#define MOB_ID_BASE 10000000 /* 10000000 player IDNUMS should suffice */
|
||||
#define ROOM_ID_BASE (10000000 + MOB_ID_BASE) /* 10000000 Mobs */
|
||||
#define OBJ_ID_BASE (10000000 + ROOM_ID_BASE) /* 10000000 Rooms */
|
||||
|
||||
#define SCRIPT(o) ((o)->script)
|
||||
#define SCRIPT_MEM(c) ((c)->memory)
|
||||
|
|
@ -437,8 +437,18 @@ void wld_command_interpreter(room_data *room, char *argument);
|
|||
#define TRIGGER_CHECK(t, type) (IS_SET(GET_TRIG_TYPE(t), type) && \
|
||||
!GET_TRIG_DEPTH(t))
|
||||
|
||||
#define ADD_UID_VAR(buf, trig, go, name, context) do { \
|
||||
sprintf(buf, "%c%ld", UID_CHAR, GET_ID(go)); \
|
||||
|
||||
/* This formerly used 'go' instead of 'id' and referenced 'go->id' but this is
|
||||
* no longer possible since script ids must be referenced with char_script_id()
|
||||
* and obj_script_id().
|
||||
*/
|
||||
#define ADD_UID_VAR(buf, trig, id, name, context) do { \
|
||||
sprintf(buf, "%c%ld", UID_CHAR, id); \
|
||||
add_var(&GET_TRIG_VARS(trig), name, buf, context); } while (0)
|
||||
|
||||
// id helpers
|
||||
extern long char_script_id(char_data *ch);
|
||||
extern long obj_script_id(obj_data *obj);
|
||||
#define room_script_id(room) ((long)(room)->number + ROOM_ID_BASE)
|
||||
|
||||
#endif /* _DG_SCRIPTS_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue