Ok - I know I said I would provide code, but it is so ugly I feel bad sharing!
SO, instead, I will describe how to fix this and leave it as an exercise.
The problem, in a nutshell, is that the event structure has a pStruct field - This is set to a pointer to the room_data struct for the room the event is assigned to.
When you delete a room in OLC, all of the data for rooms with a HIGHER RNUM are moved down one. When you add a room, the opposite happens. Regardless, the pointer is now pointing to either the NEXT or the PREVIOUS room, depending on what you are doing and if the event is assigned to a room with an rnum above the changed room.
So for example:
Code:
--------------
|v1|v2|v3|v6|v9| <-- These are your rooms, with vnums 1,2, 3, 6 and 9
--------------
^ <-- This is the pointer that is saved with your event,
an event on the room with vnum 3.
^ <-- This is a pointer for a second event, on room with
vnum 1.
Now, we delete the room with vnum 2.
-----------
|v1|v3|v6|v9| <-- These are your rooms, with vnums 1,3, 6 and 9. The
----------- room with vnum 2 was deleted and all the higher rooms were adjusted.
^ <-- This is the pointer that is saved with your event,
which now points to the room with vnum 6!
^ <-- This is a pointer for a second event, on room with
vnum 1. This one is still fine because it is below the deleted
room.
This example shows how painful this can be to debug. Everything is fine with events of rooms that are lower in the world structure - Their data has not moved. Above the deleted room, however, the data has shifted downwards. The data LOOKS ok, but obviously we will run into some issues processing an event on a room other than the one it originally was assigned to.
To prevent this, you pass a pointer to the vnum (&world[rnum].number) to the event, and in mud_events.c change the add event function for rooms to make a copy of the data, allocating space and assigning the pStruct element of the event to this new data structure. When you delete room events you must also free this allocated memory.
This was my solution, and I hope this post clarified the issue a little.